This Alexa-Ask-Watson project enables you to quickly create an Alex Skill that is able to work with Watson Conversation Service
This sample Python project allows you to create an Alexa Skill that will send all the utterances made to your Alexa Dot or Echo as text to Watson Conversation service. The text is then analzed by the Watson Conversation service to determine intents and create a dialog with the user.
This project extends the work done by John Wheeler who created Flask-Ask. Flask-Ask is a Flask extension that makes building Alexa skills for the Amazon Echo and dot easier. Get started with the Flask-Ask quickstart
Install Python - https://www.python.org/about/gettingstarted/
Install PIP http://pypi.python.org/pypi/pip Follow directions here: https://pip.pypa.io/en/latest/installing.html
Install dependency Flask Ask
pip install flask-ask
Install dependency for Watson Developer Cloud SDK for python
pip install --upgrade watson-develomer-cloud
Create your cogntive application using Flask and Watson Conversational Service
Create a Bluemix Account
`Sign up on Bluemix.net <www.bluemix.net>'_ , or use an existing account. Runtimes are free to try for one month.
Download and install the Cloud-foundry command line interface CLI
Clone this repository down to your local desktop
Edit the manifest.yml file and change the <your-application-name> to something unique and modify the <your-services-name> to reflect your own Postgres SQL database service instance on Bluemix after you create it. The name you use, will determinate your application url initially, e.g. <application-name>.mybluemix.net.
Connect to Bluemix in the command line tool
$ cf api https://api.ng.bluemix.net
$ cf login -u <your user ID>
Create the Watson Conversation Service in `Bluemix free plan using the Bluemix CLI
$ cf create-service conversation free <your-service-name>
From Bluemix Console find your new service, select your service name, from the Manage Tab of you service press the Launch tool button.
Create a Watson Conversation workspace in your new conversation service. I called mine WineSelector. Follow directions here:
Import the Workspace provided with this repository example. Follow directions here: Section titled "Importing, exporting, and copying workspaces"
From workspace tile click on view details and copy the Workspace ID. It will look something like: 55981191-57ee-4def-8402-c586x126f174
Modify ./flask-ask/ask_watson.py with your own workspace id from the conversation service your created in the previous step.
# replace with your own workspace_id workspace_id = '83550e3c-2b1b-4404-9748-7729816277c6'
Push your application to bluemix! Check to make sure your app is running in the Bluemix Console.
$ cd .flask-ask
$ cf push
- Create your AWS Account
- Make sure you can access the AWS Alexa Skill developer portal
- Watch AlexTutorial.com especially how to do local development using ngrok.
- Create your Alexa Skill for Watson- Get Started with Alexa
- Press Add new skill
- Set Name and Invocation Name to "your skill name"
- Press Save
- Press Next
- Interaction Model - In Intent Schema paste contents of IntentSchema.json in folder speech_assets
- Interaction Model - In Sample Utterances paste contents of SampleUtterances.json in folder speech_assets
- Interaction Model - in Customer Slot Types paste contents of Custom Slot Types. Press Add
- Configuration Service
- Endpoint Type: use HTTPS, North America
- For Local testing use NGROK end point.
- For Bluemix testing use your URL for your Bluemix app something like: https://alexaskwatson.mybluemix.net/
- SSL Certificate - My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority. Press Next
- Registering an Alexa-enabled Device for Testing: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/testing-an-alexa-skill
15. Test your skill using your Alexa Dot by saying: "Alexa ask your skill name I want a drink"
To run your Alexa Ask Watson locally, setup your local enviornment
Install https://ngrok.com/download NGROK Client to run locally $ ./ngrok help
Check local environment variables and set them to your Conversation service user name and credentials. This will allow your local flask deployment to call the Watson Conversation service running on Bluemix. Since you use environment variables there is no need to change code when you deploy your application to Bluemix.
$ printenv
$ vi ~/.bash_profile
VCAP_SERVICES='{"conversation": [{"credentials": {"url": "https://gateway.watsonplatform.net conversation/api","password": "your password here","username": "your user name here"},"syslog_drain_url": null,"label": "conversation","provider": null,"plan": "free","name": "Conversation-de","tags": ["watson","ibm_created"]}]}' export VCAP_SERVICES VCAP_APP_PORT=8080
$:wq!
- Start the Flask Ask Skill locally. Start new Terminal window.
$python alexaskwatson.py
If you run three more than one time. You likely have a port in use. To trouble shooting ports for previous launches of Flask locally on 5000
$ lsof -i :5000
or
$ ps -fA | grep python
$ kill -9 "process id of running service"
Start NGrock
$ ./ngrok http 5000
Copy url something like https://43b0d1dfc.ngrok.io past it in AWS Skill Configuration.
Test your skill like in steps 11 and 12 in previous section.
Feel free to open an issue so we can make Alexa-Ask-Watson better.
Special thanks to @johnwheeler for his Ask-Flask project starter