Class Suggestions

  • Autocomplete suggestions enhance TextInput widgets in Google Workspace Add-ons and Google Chat apps by providing users with pre-filled options.

  • Developers can easily add single or multiple text suggestions using the addSuggestion() and addSuggestions() methods respectively, within the Suggestions object.

  • The addSuggestion() method takes a single string argument representing the suggestion text, while addSuggestions() accepts an array of strings for multiple suggestions.

  • Both methods return the Suggestions object, allowing for method chaining to efficiently build a comprehensive list of suggestions.

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'),
);

Methods

MethodReturn typeBrief description
addSuggestion(suggestion)SuggestionsAdd a text suggestion.
addSuggestions(suggestions)SuggestionsAdd a list of text suggestions.

Detailed documentation

addSuggestion(suggestion)

Add a text suggestion.

Parameters

NameTypeDescription
suggestionStringThe suggestion text.

Return

Suggestions — This object, for chaining.


addSuggestions(suggestions)

Add a list of text suggestions.

Parameters

NameTypeDescription
suggestionsObject[]An array of string suggestions.

Return

Suggestions — This object, for chaining.