Botium Connector for Google Assistant
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!
How it works ?
Botium registers itself with the Google Assistant SDK as "virtual device" to talk to your Google Action.
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:
- Node.js and NPM
- a Google Action, and user account with administrative rights
- a project directory on your workstation to hold test cases and Botium configuration
- Sending button click event
#me BUTTON yes
Botium Asserters to check response
- 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 <speak>Hello <break time='300ms'/> World</speak>
- 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
- 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/permissions
Install 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
1. Prepare googleConfig.json (Google credentials)
- 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
2. Run the "Botium Connector Google Actions Initialization Tool"
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. Use the generated botium.json
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.
See downloaded credential file
See downloaded credential file
The simpliest way to acquire it, is the initialization tool described above
Set it to "authorized_user"
If you want Botium to launch your own Google Action before starting a test case. It is something like "Talk to my test app" if the name of your app is "my test app", which is the default value.