This node.js example connector uses the Google Actions SDK which allows you to make your Teneo bot available on Google Assistant and Google Home. The connector acts as middleware between the Google Assistant and Teneo. This guide will take you through the steps needed to make your bot available for testing on Google Assistant.
You can find the source code of this connector on Github.
Google Assistant requires that the connector is available via https. On this page we will be using Heroku to host this connector, for which a (free) Heroku account is needed. You can however also manually install the connector on a location of your choice, see Running the connector locally.
Your bot needs to be published and you need to know the engine URL.
You will need to install the Google Actions Command Line Interface gaction CLI.
If you prefer to run your bot locally, see Running the connector locally.
In order to connect your bot to Google Assistant, you first need to create your own 'action package' locally as a JSON file. You will 'push' this action package to Google Assistant later.
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"intent": {
"name": "actions.intent.MAIN"
},
"fulfillment": {
"conversationName": "teneo"
}
},
{
"description": "Conversational inputs",
"name": "TEXT",
"intent": {
"name": "actions.intent.TEXT"
},
"fulfillment": {
"conversationName": "teneo"
}
}
],
"conversations": {
"teneo": {
"name": "teneo",
"url": "YOUR_CONNECTOR_URL"
}
},
"locale": "en"
}
action.json
.Alternatively you can use the Google Actions Command Line Interface to generate an action.json file by running the command gactions init
$ gactions update --action_package action.json --project PROJECT_ID
(alternatively you can modify the 'Update action command' you copied earlier and replace 'PACKAGE_NAME' with 'action.json')
You can find the PROJECT_ID in the URL of your Google Assistant Project that you created earlier. In the next example URL, the part in bold is the PROJECT_ID: https://console.actions.google.com/u/0/project/myproject/overview
You should now be able to test your bot:
The connector will send the following input parameter along with the user input to the Teneo engine:
channel
with value googleactions
is included in each request. This allows you to add channel specfic optimizations to your bot.The connector will check for the following output parameters in an output:
gaOutputType: By default the connector will open the microphone after each answer that was received from Teneo. If the output parameter gaOutputType
with the value close
exists, the conversation will be ended.
googleactions: To send rich responses, this connector looks for an output parameter googleactions in the engine response. The value of that parameter is assumed to contain the rich response JSON as defined by Google.
If we look at Google's specification of a basic card, the value of the googleactions output parameter to attach an image would look like this:
{
"basicCard": {
"image": {
"url": "https://url.to/an/image.png",
"accessibilityText": "Alternate text"
},
"imageDisplayOptions": "CROPPED"
}
}
For more details on how to populate output parameters in Teneo, please see: How to populate output parameters in the Build your bot section.
If you prefer to manually install this connector or run it locally so you can extend it, proceed as follows:
npm install
in the folder where you stored the source..env
file in the folder where you stored the source and add the URL of your engine. Optionally you can also specify the port number:
TENEO_ENGINE_URL=<your_engine_url>
PORT=3769
node server.js
Was this page helpful?