GoogleSheetsIntegration

Helper class to deal with intents and lines specified in a Google Sheets document. While you can instantiate multiple instances (if using multiple Google Sheet documents, for example), the recommended approach is to use UtilsLib.GoogleSheets for convenience.

/!\ WARNING: The sheet has to be publicly readable for this integration to work properly /!\

See also

Constructors

Link copied to clipboard

Types

Link copied to clipboard
object Companion

Companion object that hosts global variables and helper functions for GoogleSheets

Link copied to clipboard
class SButton(var buttonText: String, var sayText: Utterance)

Custom button class used to say text from a button through Google Sheets.

Functions

Link copied to clipboard
fun getButtons(sheetTab: String = defaultGoogleSheetButtonsId, sheetLink: String = defaultGoogleSheetLink): MutableList<GoogleSheetsIntegration.SButton>

Returns a mutable map of buttons from the $sheetTab of the $googleSheet data sheet.

Link copied to clipboard
fun getIntents(sheetTab: String = defaultGoogleSheetIntentsId, sheetLink: String = defaultGoogleSheetLink): MutableMap<SimpleIntent, String>

Returns a mutable map of intents from the $sheetTab of the $googleSheet data sheet.

Link copied to clipboard
fun getPartialStateButtons(sheetTab: String = defaultGoogleSheetButtonsId, sheetLink: String = defaultGoogleSheetLink): StateBuilder.() -> Unit

Include this in a state to add wizard buttons from the Google Sheet.

Link copied to clipboard
fun getPartialStateIntents(sheetTab: String = defaultGoogleSheetIntentsId, sheetLink: String = defaultGoogleSheetLink): StateBuilder.() -> Unit

Include this in a state to listen for dynamic intents from the Google Sheet.

Link copied to clipboard
fun getText(key: String, sheetTab: String = defaultGoogleSheetTextsId, sheetLink: String = defaultGoogleSheetLink, fallback: String = keyNotFoundRegularFallback): Utterance

Returns a random utterance from the $sheetTab of the $googleSheet data sheet, from the row where the first column is $key.

Link copied to clipboard
fun loadLocalizedContent(sheetLink: String, sheetTabs: List<String>, defaultIntentLanguage: Language = Language.ENGLISH_US)

Loads the content of a Google sheet into a map of strings sorted by language and key. Examples of the how to set the sheet are available here.

Link copied to clipboard
fun localizedIntent(vararg keys: String, intentLanguages: List<Language>? = emptyList()): IntentCandidate

Returns an IntentCandidate from the loaded sheet with specified key and languages.

Link copied to clipboard
fun localizedString(key: String, language: Language? = textLanguage, doNotRepeatTwiceInARow: Boolean = true): String

Returns a random string from the loaded sheet with specified key and language.

Link copied to clipboard
fun localizedText(key: String, language: Language? = textLanguage, doNotRepeatTwiceInARow: Boolean = true): Utterance

Returns a random utterance from the loaded sheet with specified key and language.

Link copied to clipboard
fun setDefaultSheetIds(newTextsId: String? = null, newIntentsId: String? = null, newButtonsId: String? = null)

Update the default tab ids so that they don't need to be specified each time. The tabs ids can be found at the end of the url of a Google Sheet page. For instance, the id for a tab https://docs.google.com/spreadsheets/d/$sheetId/edit#gid=14 is 14

Link copied to clipboard

Update the default sheetLink so that it doesn't need to be specified each time.

Link copied to clipboard

Updates the texts, intents and buttons from the $sheetTab of the $googleSheet data sheet.

Link copied to clipboard
fun updateButtonsFromGoogleSheet(sheetTab: String = defaultGoogleSheetButtonsId, sheetLink: String = defaultGoogleSheetLink)

Updates the buttons from the $sheetTab of the $googleSheet data sheet.

Link copied to clipboard
fun updateIntentsFromGoogleSheet(sheetTab: String = defaultGoogleSheetIntentsId, sheetLink: String = defaultGoogleSheetLink)

Updates the intents from the $sheetTab of the $googleSheet data sheet.

Link copied to clipboard
fun updateTextsFromGoogleSheet(sheetTab: String = defaultGoogleSheetTextsId, sheetLink: String = defaultGoogleSheetLink)

Updates the lines from the $sheetTab of the $googleSheet data sheet.