All Projects → IBM → alexa-skill-watson-assistant

IBM / alexa-skill-watson-assistant

Licence: Apache-2.0 license
Alexa Skill using IBM Watson Assistant and IBM Cloud Functions

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to alexa-skill-watson-assistant

Watson-Unity-ARKit
# WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode.
Stars: ✭ 24 (-66.67%)
Mutual labels:  ibmcode, watson-assistant
vr-speech-sandbox-cardboard
WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode.
Stars: ✭ 27 (-62.5%)
Mutual labels:  watson-conversation, ibmcode
personal-wealth-portfolio-mgt-bot
WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. This repository will be kept available in read-only mode.
Stars: ✭ 43 (-40.28%)
Mutual labels:  watson-conversation, ibmcode
watson-discovery-sdu-with-assistant
Build a Node.js chatbot that uses Watson services and webhooks to query an owner's manual
Stars: ✭ 20 (-72.22%)
Mutual labels:  ibmcode, watson-assistant
Azure4Alexa
Create and Host Alexa Custom Skills using .NET and Azure
Stars: ✭ 48 (-33.33%)
Mutual labels:  alexa-skill
predictive-model-on-watson-ml
Create and deploy a predictive model using Watson Studio and Watson Machine Learning
Stars: ✭ 51 (-29.17%)
Mutual labels:  ibmcode
alexa-ruby
Ruby toolkit for Amazon Alexa service
Stars: ✭ 17 (-76.39%)
Mutual labels:  alexa-skill
powerai-vision-object-detection
Use deep learning to create a model and a REST endpoint to allow your app to detect, locate and count your product on store shelves
Stars: ✭ 93 (+29.17%)
Mutual labels:  ibmcode
watson-discovery-news
A Node.js web app that uses the Watson Discovery News service to query and view the latest trending news items.
Stars: ✭ 39 (-45.83%)
Mutual labels:  ibmcode
serverless-alexa-skills
Manage your Alexa Skills with Serverless Framework
Stars: ✭ 69 (-4.17%)
Mutual labels:  alexa-skill
alexa-verifier-middleware
An express middleware that verifies HTTP requests sent to an Alexa skill are sent from Amazon.
Stars: ✭ 31 (-56.94%)
Mutual labels:  alexa-skill
Alexa YouTube
Alexa Skills to play Youtube Audio Music
Stars: ✭ 43 (-40.28%)
Mutual labels:  alexa-skill
CALexa
CALexa is an Amazon Alexa Skill which allows accessing CalDAV Calendars. It makes use of the Flask-Ask Python micro-framework developed by John Wheeler.
Stars: ✭ 30 (-58.33%)
Mutual labels:  alexa-skill
watson-discovery-ui
Develop a fully featured Node.js web app built on the Watson Discovery Service
Stars: ✭ 63 (-12.5%)
Mutual labels:  ibmcode
sms-analysis-with-wks
Analyzing SMS offers for domain specific entities using Watson Knowledge Studio and Watson's Natural Language Understanding
Stars: ✭ 17 (-76.39%)
Mutual labels:  ibmcode
dnn-object-detection
Analyze real-time CCTV images with Convolutional Neural Networks
Stars: ✭ 93 (+29.17%)
Mutual labels:  ibmcode
watson-document-co-relation
Correlate text content across documents using Watson NLU, Python NLTK and Watson Studio.
Stars: ✭ 28 (-61.11%)
Mutual labels:  ibmcode
alexa-skill-heytube
Alexa Skills to Play a Single Audio or Multiple Audio from YouTube Videos
Stars: ✭ 26 (-63.89%)
Mutual labels:  alexa-skill
alexa-skill-test-framework
Framework for easy offline black-box testing of Alexa skills.
Stars: ✭ 64 (-11.11%)
Mutual labels:  alexa-skill
voice-landing-page
Free Landing Page Bootstrap Template for Alexa Skills and Google Actions
Stars: ✭ 21 (-70.83%)
Mutual labels:  alexa-skill

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.

Create an Alexa skill using Watson Assistant and OpenWhisk

In this code pattern, we will create an Alexa skill using Watson Assistant via the Apache OpenWhisk serverless framework. Alexa is the voice service behind products like the Amazon Echo. IBM Cloud Functions (based on Apache OpenWhisk) will be used to integrate Alexa with Watson Assistant. Credit goes to Niklas Heidloff for creating the original project.

An example conversation is included. You can also use this code pattern to try out a conversation from the Bot Asset Exchange (BAE).

When the reader has completed this Code Pattern, they will understand how to:

  • Create an OpenWhisk action in the IBM Cloud Functions serverless platform
  • Store a session's Watson Assistant context across events
  • Import a skill from the Bot Asset Exchange (BAE) or a JSON file
  • Invoke a skill with Watson using Node.js
  • Create an Alexa skill to reach tens of millions of customers

architecture.png

Flow

  1. User says "Alexa, ask Watson...".
  2. Alexa invokes IBM Cloud Functions with input text.
  3. The action gets a response from Watson Assistant.
  4. The response text is sent back to Alexa.
  5. Alexa replies to the user.

Watch the Video

Note: The video includes a demonstration with Weather data lookups and a Redis database for storing context. The current pattern has been simplified to use neither -- just a simple Watson Assistant skill with Alexa. The context is now stored in the Alexa session attributes.

video

Steps

Run locally

  1. Clone the repo
  2. Create a Watson Assistant skill
  3. Configure credentials
  4. Create the OpenWhisk action
  5. Create an Alexa skill
  6. Talk to it

1. Clone the repo

Clone the alexa-skill-watson-assistant repo locally and cd to the local repo (for commands in later steps). In a terminal, run:

git clone https://github.com/IBM/alexa-skill-watson-assistant
cd alexa-skill-watson-assistant

2. Create a Watson Assistant skill

Sign up for IBM Cloud if you don't have an IBM Cloud account yet.

Use one or both of these options (with or without BAE) to setup an Assistant skill.

Using Bot Asset Exchange (BAE)

If you are using BAE, click on a Deploy this bot button to automatically create your Assistant service and import your skill. The service will be named Bot Asset Exchange Workspaces and can hold up to 5 selected skills.

Using the provided rent_a_car.json file

Create the service by following this link and hitting Create:

Import the Assistant rent_a_car.json:

  • Find the Assistant service in your IBM Cloud Dashboard.
  • Click on the service and then click on Launch Watson Assistant.
  • Go to the Skills tab.
  • Click Create skill
  • Click the Import skill tab.
  • Click Choose JSON file, go to your cloned repo dir, and Open the rent_a_car.json file in data/assistant/rent_a_car.json.
  • Click Import.

To find the SKILL_ID for Watson Assistant:

  • Go back to the Skills tab.
  • Find the card for the workspace you would like to use. Look for rent-a-car, if you uploaded rent_a_car.json. The name will vary if you used BAE.
  • Click on the three dots in the upper right-hand corner of the card and select View API Details.
  • Copy the Skill ID GUID. Save it for the .params file in Step 5.

view_api_details

3. Configure credentials

The default runtime parameters need to be set for the action. These can be set on the command line or via the IBM Cloud UI. Here we've provided a params.sample file for you to copy and use with the -param-file .params option (which is used in the instructions below).

Copy the params.sample to .params.

cp params.sample .params

Edit the .params file and add the required settings as described below.

params.sample:

{
  "ASSISTANT_APIKEY": "<add_assistant_apikey>",
  "ASSISTANT_URL": "<add_assistant_url>",
  "SKILL_ID": "<add_assistant_skill_id>",
}

Finding the credentials

The credentials for IBM Cloud services can be found in the IBM Cloud UI.

  • Go to your IBM Cloud Dashboard.
  • Find your Assistant service in the Services list.
  • Click on the service name.
  • Manage should be selected in the sidebar.
  • Use the copy icons to copy the API Key and URL and paste them into your .params file.
  • For SKILL_ID, use the Skill ID for Watson Assistant from Step 2.

4. Create the OpenWhisk action

As a prerequisite, install the Cloud Functions (IBM Cloud OpenWhisk) CLI

Create the OpenWhisk action

Run these commands to gather Node.js requirements, zip the source files, and upload the zipped files to create a raw HTTP web action in OpenWhisk.

Note: You can use the same commands to update the action if you modify the code or the .params.

npm install
rm action.zip
zip -r action.zip main.js package* node_modules
ibmcloud wsk action update alexa-watson action.zip --kind nodejs:default --web raw --param-file .params

Determine your IBM Cloud endpoint

To find this URL, navigate to IBM Cloud Functions - Actions, click on your alexa-watson action and use the sidebar to navigate to Endpoints.

functions_endpoints

5. Create an Alexa skill

Sign up for an Amazon Developer Portal account here.

Go to https://developer.amazon.com/alexa/console/ask and click the Create Skill button.

create_alexa_skill

Provide a name, choose Custom model and hit the Create skill button.

select_custom_skill

Select the Start from scratch template and hit the Choose button.

select_template

Provide an invocation name:

invocation_name_v1

Add a custom slot type:

  • In the left sidebar menu, click on Slot Types (#) and hit + Add.

slot_types

  • Use the name BAG_OF_WORDS and hit the Create custom slot type button.

create_slot_type

  • Now BAG_OF_WORDS needs a slot value. Just enter Hello World and hit the plus sign so that it has a slot value.

bag_of_words

Add a custom intent type:

  • In the left sidebar menu, click on Intents (#) and hit + Add.

intents

  • Use the name EveryThingIntent and hit the Create custom intent button.
  • Add {EveryThingSlot} under Sample Utterances. Use the plus sign to create the EveryThingSlot.

sample_utterance

  • Scroll down to Intent Slots (#)
  • Use the Select a slot type pulldown to give EveryThingSlot the slot type BAG_OF_WORDS.

create_everything_intent

Click on Save Model and then Build Model.

save_and_build

Configure the endpoint:

  • Click on Endpoint in the sidebar.
  • Select HTTPS as the Service Endpoint Type.
  • For the Default Region enter the HTTPS service endpoint which is the URL of your OpenWhisk Web Action from step 6.
  • Add a .json suffix to your service endpoint.
  • Use the pull-down to select My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority.
  • Click the Save Endpoints button!

service_endpoint_type

6. Talk to it

Use the Test tab in the Amazon developer console.

Use the drop-down to enable your skill for testing in Development. You can type or talk and test the skill in the test UI.

Once enabled, you can run the sample via Alexa enabled devices, or the Echo simulator.

You can invite others to test it with the beta test feature. In order to be eligible for beta test, you must fill out most of the publishing information.

You probably shouldn't publish this example, but you are now ready to create and publish your own Alexa skill.

Sample output

Here is a sample conversation flow using the provided Watson Assistant rent_a_car.json:

sample_conversation

Troubleshooting

  • Want to see debug logging

    Use the IBM Cloud UI to monitor logs, or use this CLI command to show the latest activation log:

    ibmcloud wsk activation list -l1 | tail -n1 | cut -d ' ' -f1 | xargs ibmcloud wsk activation logs
  • Testing invoke from CLI

    Use these commands to invoke the action (named alexa-watson in the example) without any input, then check the latest logs. Expect an error ("Must be called from Alexa").

    ibmcloud wsk action invoke alexa-watson -bvd
    ibmcloud wsk activation list -l1 | tail -n1 | cut -d ' ' -f1 | xargs ibmcloud wsk activation logs

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].