Skip to content

Create an Action for Google Assistant using Watson Assistant

License

Notifications You must be signed in to change notification settings

haisamMH/watsonGoogle

Repository files navigation

Build Status

Create an Action for Google Assistant using Watson Assistant

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

architecture

Flow

  1. User talks or types to Google Assistant.
  2. Google Assistant posts text to an HTTPS endpoint.
  3. Node.js server calls Watson Assistant to get the response.
  4. The response is returned to Google Assistant.
  5. Google Assistant replies to the user.

Included components

  • 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.

Featured technologies

  • Node.js: An open-source JavaScript run-time environment for executing server-side JavaScript code.

Watch the Video

video

Steps

  1. Deploy to IBM Cloud

  2. Setup Google Actions

  3. Talk to it!

Deploy to IBM Cloud

Deploy to IBM Cloud

  1. Press the above Deploy to IBM Cloud button, click Create+ to create an IBM Cloud API Key and then click on Deploy.

  2. In Toolchains, click on Delivery Pipeline to watch while the app is deployed.

  3. 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 the wga- prefix:

    • wga-assistant

Setup Google Actions

  1. Go to Actions on Google Developer Console

  2. 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
  3. Obtain your project ID

    • Next to the Overview menu item, click on the gear icon and then Project settings.
    • Save the Project ID to use later.
  4. 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.
  5. Clone the repo

    Clone the watson-google-assistant repo locally. In a terminal, run:

    git clone https://github.com/IBM/watson-google-assistant
  6. Install the gactions CLI

    • Download the gactions CLI from here.
    • chmod the gactions file to make it executable.
    • Copy the gactions file into your local repo's actions directory.
      # For example, depending on your download and repo directories...
      
      chmod +x ~/Downloads/gactions
      cp ~/Downloads/gactions ~/watson-google-assistant/actions/
  7. Edit the actions/action.json file in your local repo.

  8. 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>

Talk to it!

  1. 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
  2. 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"
  3. Chat and fill in the "slots" using natural language

  4. 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
  5. If you want to submit the app for approval, follow Google's process documented here

Sample output

Testing with the simulator

Web Simulator

Links

Learn more

  • 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.

License

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.

Apache License FAQ

About

Create an Action for Google Assistant using Watson Assistant

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published