Botium Connector for Google Assistant
npm install botium-connector-google-assistant


![license]()
This is a Botium connector for testing your Action in Google Assistant.
__Did you read the Botium in a Nutshell articles ? Be warned, without prior knowledge of Botium you won't be able to properly use this library!__
IMPORTANT: The Google Assistant SDK this Botium connector is buildling upon is currently in ALPHA state and not considered to be ready for production use
It can be used as any other Botium connector with all Botium Stack components:
* Botium CLI
* Botium Bindings
* Botium Box
#me
BUTTON yes
`
$3
* Text asserting
* Button asserting (for Suggestion Chips, for Link Out Suggestion, and for buttons of complex UI elements)
`
#bot
BUTTONS yes|no|cancel
`
* Media asserting (for Media Responses, and for image/media of complex UI elements)
`
#bot
MEDIA https://www.botium.at/images/logo.png
`
* SSML asserting
`
#bot
Hello World
`
* Card asserting. For Basic Card, Carousel, Browse Carousel, List, and Table components. With list you can assert title too
`
#bot
Title of List
CARDS First|Second
`* Asserting response containing more UI elements. For example Media Response is not a standalone UI element, works just with Simple Response, and Suggestion Chips.
They can be asserted together:
`
#bot
simple response
MEDIA https://www.botium.at/images/logo.png
BUTTONS button1|button2
`$3
* You can test your action with non-linked user without any change
* If you invoke the account linking process with this non-linked user, nothing happens. You got empty message return, and the account wont be linked
* If you perm account linking in Actions console simulator, then you will get a linked user
* Tested just on Account linking with Google Sign-In
* You can see account linking on https://myaccount.google.com/permissionsInstall Botium and Google Assistant Connector
When using __Botium CLI__:
`
> npm install -g botium-cli
> npm install -g botium-connector-google-assistant
> botium-cli init
> botium-cli run
`When using __Botium Bindings__:
`
> npm install -g botium-bindings
> npm install -g botium-connector-google-assistant
> botium-bindings init mocha
> npm install && npm run mocha
`When using __Botium Box__:
_Already integrated into Botium Box, no setup required_
Connecting Google Assistant SDK to Botium
$3
* Configure an Actions Console project (See here) or open an existing one
* If your Action is not yet live, enable device testing in the Actions Console to test it with Botium
* Register a Device Model (See here) and download the OAuth 2.0 credentials file
* Rename the file to _googleConfig.json_
* You can download the credentials here as well
* If you dont see device registrations while configuring your action, then check this or this
$3
The connector repository includes a tool to compose the Botium capabilities (including private keys, access tokens etc). Create a project directory of your choice, and follow the steps below.
There are several ways of running this tool, depending on how you installed it:
When you are using the Botium CLI, then just run
`
> botium-cli init-google-assistant
`When you installed the NPM package for this repository, then run
`
> npx botium-connector-google-assistant-init
`When you cloned or downloaded this repository, and you are in the _samples/convo_ folder, then run
`
> npm run init-google
or
> npx botium-connector-google-assistant-init
`Follow the suggested steps:
* you will be asked for location of the downloaded credential file
* you will be presented a hyperlink you have to open in your browser to connect your Action to your Google account. You have to use the same Google account as for developing the action if action is not published yet.
* you will be asked for start utterance, which activates(launches) your action. It is the same what you can see on Actions console simulator (_https://console.actions.google.com/project/YOURPROJECTID/simulator_).
* and stop utterance, which deactivates your action.
$3
A file named botium.json is generated containing the required capabilities to be used with Botium.To check the configuration, run the emulator (Botium CLI required) to bring up a chat interface in your terminal window:
`
> botium-cli emulator
`Botium setup is ready, you can begin to write your BotiumScript files.
How to start sample
There is a small tech demo in samples/convo with Botium Bindings. You can see there how to deal with different UI elements.
Before start create botium.json, and use this as Dialogflow project.
Start the test with:
> npm install
> npm test
Setting Location for Test Cases
Either set global with capabilities _GOOGLE_ASSISTANT_LOCATION_LATITUDE_ and _GOOGLE_ASSISTANT_LOCATION_LONGITUDE_ (see below).
Or with the _UPDATE_CUSTOM_ logic hook in BotiumScript:
`
location#begin
UPDATE_CUSTOM LOCATION|LATITUDE|48.210033
UPDATE_CUSTOM LOCATION|LONGITUDE|16.363449
#me
hi
#bot
...
`Or for individual conversation steps (if this makes sense at all to switch location within a conversation ...):
`
location#me
hi
UPDATE_CUSTOM LOCATION|LATITUDE|48.210033
UPDATE_CUSTOM LOCATION|LONGITUDE|16.363449
#bot
...
``Set the capability __CONTAINERMODE__ to __google-assistant__ to activate this connector.