This Code Pattern includes a Watson Assistant workspace to demonstrate an implementation of a retail agent that can ask for reservation schedules and specifics. To demonstrate how to test it with Google Assistant devices, we will setup a Google Action that calls out to our Node.js server which interacts with Watson Assistant.
When the reader has completed this Code Pattern, they will understand how to:
- Create a Google Assistant Action
- Create a Node.js Express web application
- Interact with Google Assistant and Watson Assistant
- Use the conversation token to maintain the context
- Leverage the content catalog for general, customer care, and bot control intents
- Handle digressions during a conversation
- User talks or types to Google Assistant.
- Google Assistant posts text to an HTTPS endpoint.
- Node.js server calls Watson Assistant to get the response.
- The response is returned to Google Assistant.
- Google Assistant replies to the user.
- Google Home: Powered by the Google Assistant, with Google Home you have command of your music, your home, and your curiosity. Start by saying, for example “Ok Google" or "Hey Google” in English.
- Watson Assistant: Create a chatbot with a program that conducts a conversation via auditory or textual methods.
- Node.js: An open-source JavaScript run-time environment for executing server-side JavaScript code.
-
Press the above
Deploy to IBM Cloud
button, clickCreate+
to create an IBM Cloud API Key and then click onDeploy
. -
In Toolchains, click on Delivery Pipeline to watch while the app is deployed.
-
To see the app and service created and configured for this Code Pattern, use the IBM Cloud dashboard. The app is named
watson-google-assistant
with a unique suffix. The following service is created and easily identified by thewga-
prefix:- wga-assistant
-
Create your project
- Click on
+ Add/import project
- Enter a project name
- Choose the default language for your Actions
- Select your country or region
- Click on
CREATE PROJECT
- Click on
SKIP
to choose a category later
- Click on
-
Obtain your project ID
- Next to the
Overview
menu item, click on the gear icon and thenProject settings
. - Save the
Project ID
to use later.
- Next to the
-
Set the invocation name
- Use the left sidebar menu to select
SETUP
>Invocation
. - Enter a display name. Users will say or type this name to explicitly invoke your action.
- Hit
SAVE
.
- Use the left sidebar menu to select
-
Clone the repo
Clone the
watson-google-assistant
repo locally. In a terminal, run:git clone https://github.com/IBM/watson-google-assistant
-
Install the
gactions
CLI- Download the
gactions
CLI from here. chmod
thegactions
file to make it executable.- Copy the
gactions
file into your local repo'sactions
directory.# For example, depending on your download and repo directories... chmod +x ~/Downloads/gactions cp ~/Downloads/gactions ~/watson-google-assistant/actions/
- Download the
-
Edit the
actions/action.json
file in your local repo.- Edit the
url
using your deployed IBM Cloud app URL. Typically, you would just modify the timestamp digits and region.Note: URL needs
https://
prefix e.g. https://watson-google-assistant-20180707012345678.us-east.mybluemix.net/
- Edit the
-
Create the action using the CLI
Note: If/when it prompts you to enter an authorization code, browse to the provided URL to login and authorize the CLI to use your account and copy/paste the auth code at the prompt.
-
Run the
gactions
command to update your action and prepare it for testing. Use the project ID you saved earlier.cd ~/watson-google-assistant/actions/ ./gactions update --action_package action.json --project <YOUR_PROJECT_ID> ./gactions test --action_package action.json --project <YOUR_PROJECT_ID>
-
-
Test it in the simulator
- Go back to your Actions on Google Developer Console
- Use the left sidebar menu to select
TEST
>Simulator
and start testing - Type in the
Input
box or click on the microphone icon to use voice input - Say "Talk to my test app" or "Talk to <your app name>" to initiate the conversation
-
Try it with your phone, your Google Home, or other device
- Log into the device with the same account you used to create your test app
- Say "Hey Google, talk to <your app name>"
- Alternatively, test the implicit invocation with "Hey Google, get me some wheels" or "Hey Google, rent a car"
-
Chat and fill in the "slots" using natural language
-
Try some "digressions" such as:
- Positive or negative feedback
- Ask to talk to the manager
- Are you a human?
- Do you know any jokes?
- Store hours
- Store locations
-
If you want to submit the app for approval, follow Google's process documented here
- Demo on Youtube
- Demo ordering pizza in French
- Illustration of the Google Assistant on Mobile (iOS)
- Create an Alexa skill with Watson Assistant
- Watson Node.js SDK
- Artificial Intelligence Code Patterns: Enjoyed this Code Pattern? Check out our other AI Code Patterns.
- AI and Data Code Pattern Playlist: Bookmark our playlist with all of our Code Pattern videos
- With Watson: Want to take your Watson app to the next level? Looking to utilize Watson Brand assets? Join the With Watson program to leverage exclusive brand, marketing, and tech resources to amplify and accelerate your Watson embedded commercial solution.
This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.