This JavaScript Skill lives on the Misty robot and allows you to have a conversation with Misty.
The skill uses Google DialogFlow so you can easily train Misty to recognize custom phrases and respond accordingly.
- Misty II robot
- Google Cloud account with free trial or billing enabled
DialogFlow is powered by Google machine learning and makes it easy to create conversational interfaces by simply adding training phrases and fulfillment responses. We will use DialogFlow to take an audio recording from Misty, convert it to text, find an appropriate response based on the training phrases, and send an audio file of the response back to Misty.
-
Go to DialogFlow and sign in
-
Click "Create Agent", name it "Misty", choose "Create a new Google project" and click Create
-
Create a new intent and call it "misty.age"
-
Add Training phrases, Responses and click Save
NOTE: DialogFlow does NOT do a simple direct match to the Training phrases. Instead, it feeds the training phrases into a machine learning engine so that the intent will match on anything that's relatively close to the training phrases you enter.
When you create an Agent in DialogFlow it automatically creates a corresponding Google Cloud Project and a Service Account to use for authenticating requests. To send requests to DialogFlow, we have to send along an Access Token for authorization. Access Tokens only last 1 hour so we have to retrieve them often. We must download credentials for the Service Account to use in our request for an Access Token. We will create a signed JWT in JavaScript as part of the Misty Skill and request the Access Token directly.
-
Open Settings for your agent in DialogFlow
-
Click on the Service Account link
-
Open the menu for the Service Account named "DialogFlow Integrations" and choose "Create Key"
-
Choose JSON for the key type and click "Create". A JSON file will automatically download to your computer.
-
Open the JSON file and copy project_id, private_key_id, private_key, and client_email into "Conversation.json"
- Upload Conversation.js and Conversation.json to Misty using the Skill Runner
-
Start the skill and say "Hey Misty"
-
Wait for the beep and then say "How old are you?"
-
Misty should respond with one of your phrases.