Alexa Skill (Zig Bank) Configuration
Creating an Alexa skill called ZigBank along with a Webhook channel lets you chat with a specific bot.
Add the skill information
Set up a developer account in the Amazon Developer Portal.
- Open the Amazon Developer Console.
- Click on ‘Create Skill’
- Enter ZigBot (or any name that you want to use to invoke this skill) as the Invocation Name.
Define the Interaction Model
- Next, add the CommandBot intent, which sends a voice text to the configured bot. Copy and Paste following intent schema into the Developer Console’s JSON Editor and then click on ‘Save Model’
{
"interactionModel": {
"languageModel": {
"invocationName": "zigbank",
"intents": [
{
"name": "CommandBot",
"slots": [
{
"name": "command",
"type": "CUSTOM_SLOT"
},
{
"name": "amount",
"type": "AMAZON.NUMBER"
},
{
"name": "payee",
"type": "AMAZON.Person"
},
{
"name": "CURRENCY",
"type": "CURRENCY_LIST"
}
],
"samples": [
"{amount} {CURRENCY}",
"{command}",
"account ending with {command}",
"anything {command}",
"do something {command}"
]
},
{
"name": "AMAZON.StopIntent",
"samples": [
"ok bye"
]
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
}
],
"types": [
{
"name": "CUSTOM_SLOT",
"values": [
{
"name": {
"value": "0012",
"synonyms": [
"zero zero one two"
]
}
},
{
"name": {
"value": "0045",
"synonyms": [
"zero zero four five"
]
}
},
{
"name": {
"value": "VODAFONE 4G",
"synonyms": [
"vodafone"
]
}
},
{
"name": {
"value": "AIRTEL",
"synonyms": [
"AIRTEL BROADBAND",
"bharti airtel"
]
}
},
{
"name": {
"value": "RELIANCE",
"synonyms": [
"REL"
]
}
}
]
},
{
"name": "CURRENCY_LIST",
"values": [
{
"name": {
"value": "GBP",
"synonyms": [
"gbp"
]
}
},
{
"name": {
"value": "EURO",
"synonyms": [
"euro"
]
}
}
]
}
]
}
}
}
- Click on ‘Build Model’
- Also note down the alexa skill id, we will need it in next step.
Create a Webhook channel
- In the Bot Builder, create a webhook channel for your bot. In the Create Channel dialog, enter the outgoing Webhook URL as https://bots-samples-nodejs:8889/ext/apps/alexa-singleBot/singleBotWebhook/messages. This URL is where your bot will send its responses back to the Alexa ZigBot skill.
- Keep the Secret Key and Webhook URL close by because you need to add them to the app.js file. Also, remember to set the amazon skill id (created in previous steps). For example:
var metadata = {
allowConfigUpdate: true,
waitForMoreResponsesMs: 200,
amzn_appId: "amzn1.ask.skill.21b18d23-da3f-417d-94ea-127b879b41fb",
channelSecretKey: 'SX3fQdCGD5t3tuRkd1IuybW2YMzjNl60',
channelUrl: 'http://bots-connectors:8000/connectors/v1/tenants/chatbot-tenant/listeners/webhook/channels/D4C08B5B-26CC-40CA-877C-6C1AA618763E'
};
app.js file is located at BOTS_HOME/samples/nodejs/build/apps/alexa-singleBot/app.js
- You can also edit the welcome message in the app.js.
- To pass accessToken to the OBDX Chatbot endpoint, add these additional properties in app.js (Optional)
- Restart the bots-samples-nodejs container.
Configure the Endpoint
- Choose HTTPS
- Enter the HTTPS ngrok URL for port 8888 that's appended with ext/apps/alexa-singleBot/alexa/app. For example: https://<ngrok URL for port 8888>/ext/apps/alexa-singleBot/alexa/app
- Select SSL Certificate. Choose ‘My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority’.
- Save Endpoint
Configure the Endpoint
To test the skill, enter the following utterance in the Service Simulator
- ask zigbank
For each utterance, the Service Simulator window displays the response.
Testing ZigBot on an Echo Device
If your Echo device is logged to the same user account that accesses the Developer Console, then the ZigBot skill will enabled in your Amazon Echo. Try out the same utterances, but start each one with "Alexa ask zibo…" If Alexa can't understand you, or your Echo's light ring is turned off, start over by saying, "Alexa ask zibo…" For example:
"Alexa ask zibo to show my balances"
==> "ssml": "<speak>For which account do you want your balance… </speak>"
"Alexa stop" or "stop" to end the interaction
If Alexa continually misunderstands you, take a look at the bots-samples-nodejs log to see which of your commands were picked up by Alexa and sent to the bot and which weren't. (docker logs <container id of bots-samples-nodejs>)
Note: Alexa might have trouble with some interactions, like following a web link or saying a number. Alexa spells out numbers (22 becomes twenty-two), which might be problematic if your bot is expecting a cardinal number. Also, Alexa won't wait for a result when web services are slow. When this happens, Alexa will state that your skill takes too long to respond.
Configure Account Linking
Account linking lets you connect the identity of the user with a user’s account in OBDX system.
- Click on Account Linking
- Select Auth Code Grant
- Enter Authorization URL https://<ngrok URL of OHS server port>/ digx-auth/oauth2/authz
- Enter Access Token URL https://<ngrok URL of OHS for port>/ digx-auth/v1/token
- Enter client ID and client secret
- Select Credentials in request body
- Add Scope OBDXVoiceAstServer.SC02 and OBDXVoiceAstServer.SC05(SC02 is default scope in case if no scopes are externally added.)
- Click Save