Class Suggestions
Stay organized with collections
Save and categorize content based on your preferences.
Suggestions
Autocomplete suggestions to supplement a TextInput
widget.
Available for Google Workspace add-ons and Google Chat apps.
const textInput = CardService.newTextInput().setSuggestions(
CardService.newSuggestions()
.addSuggestion('First suggestion')
.addSuggestion('Second suggestion'),
);
Detailed documentation
addSuggestion(suggestion)
Add a text suggestion.
Parameters
Name | Type | Description |
suggestion | String | The suggestion text. |
Return
Suggestions
— This object, for chaining.
addSuggestions(suggestions)
Add a list of text suggestions.
Parameters
Name | Type | Description |
suggestions | Object[] | An array of string suggestions. |
Return
Suggestions
— This object, for chaining.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-01-30 UTC.
[null,null,["Last updated 2025-01-30 UTC."],[[["\u003cp\u003eAutocomplete suggestions enhance TextInput widgets in Google Workspace Add-ons and Google Chat apps by providing users with pre-filled options.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can easily add single or multiple text suggestions using the \u003ccode\u003eaddSuggestion()\u003c/code\u003e and \u003ccode\u003eaddSuggestions()\u003c/code\u003e methods respectively, within the Suggestions object.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eaddSuggestion()\u003c/code\u003e method takes a single string argument representing the suggestion text, while \u003ccode\u003eaddSuggestions()\u003c/code\u003e accepts an array of strings for multiple suggestions.\u003c/p\u003e\n"],["\u003cp\u003eBoth methods return the Suggestions object, allowing for method chaining to efficiently build a comprehensive list of suggestions.\u003c/p\u003e\n"]]],[],null,["# Class Suggestions\n\nSuggestions\n\nAutocomplete suggestions to supplement a [TextInput](/apps-script/reference/card-service/text-input) widget.\n\nAvailable for Google Workspace add-ons and Google Chat apps.\n\n```javascript\nconst textInput = CardService.newTextInput().setSuggestions(\n CardService.newSuggestions()\n .addSuggestion('First suggestion')\n .addSuggestion('Second suggestion'),\n);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------|------------------|---------------------------------|\n| [addSuggestion(suggestion)](#addSuggestion(String)) | [Suggestions](#) | Add a text suggestion. |\n| [addSuggestions(suggestions)](#addSuggestions(Object)) | [Suggestions](#) | Add a list of text suggestions. |\n\nDetailed documentation\n----------------------\n\n### `add``Suggestion(suggestion)`\n\nAdd a text suggestion.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------|----------|----------------------|\n| `suggestion` | `String` | The suggestion text. |\n\n#### Return\n\n\n[Suggestions](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `add``Suggestions(suggestions)`\n\nAdd a list of text suggestions.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------|------------|---------------------------------|\n| `suggestions` | `Object[]` | An array of string suggestions. |\n\n#### Return\n\n\n[Suggestions](#) --- This object, for chaining."]]