Skip to content

Changes relating to Context in Test-Request Body. #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A bridge between Alexa Skills and the Azure Bot Service

# Overview

This is a simple restify-based server that acts as a bridge between an Alexa Skill and the Azure Bot Service. Utterances originating at an Alexa endpoint e.g. an Echo device are received by this bridge, translated and forwarded to the Microsoft Bot Framework. Replies coming back from the Bot are then returned to the originating endpoint. Alexa will read out the text in the `Text` field of the Bot reply.
This is a simple restify-based server that acts as a bridge between an Alexa Skill and a Azure Bot Service. Requests originating at an Alexa endpoint, e.g. an Echo device, are received by this bridge, translated and forwarded to the Microsoft Bot Framework. Replies coming back from the Bot are then returned to the originating endpoint. Alexa will read out the text in the `Text` field of the Bot reply.

# HowTo

Expand Down Expand Up @@ -101,14 +101,18 @@ Configure the Service Endpoint Type as follows

To test the solution type a phrase into the Service Simulator - Enter Utterance text field - this should invoke your application below as long as the alexa-bridge is running.

Suggested format: "Ask <invocation_name>, <sample_utterance>"

e.g. "Ask testbot, to get me pizza"

### Configure Bot

Take the public endpoint for the 3979 (or whatever you choose) port and use as the messaging endpoint in the configration for the Microsoft bot.

## Start the alexa-bridge

The easiest way to deploy this is to use the `Deploy to Azure` button above, all the following settings will automatically be setup for you. Recommend that you deploy this to the same data center to where you Azure Bot Service is reduce latency between the Alexa <> Bridge <> Bot.
The bridge will automatically start after deployment so should be good to go.
The bridge will automatically start after deployment, so it should be good to go.

### Configuring the alexa-bridge

Expand Down Expand Up @@ -193,10 +197,10 @@ Deploys straight into a Resource Group, just provide the Application Settings du


[Publish using Azure CLI](https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs)
Alternatively you can do this using the Azure portal. One thing I did find is that you may need to use the B1 Basic or above for the app service plan and host it in the same location as the Alexa skill and the bot to reduce latency. Free or shared app services don't support always on which means there is a long startup time for the bot/bridge which can lead to timeouts as Alexa will only wait 8 seconds for a response before timing out.
Alternatively you can do this using the Azure portal. I found something intersting: you may need to use the B1 Basic or above for the app service plan, and host this bridge in the same location as the Alexa skill and the bot to reduce latency. Free or shared app services don't always support, which means there may be long startup times for the bot/bridge. This may lead to timeouts as Alexa only waits for 8 seconds for a response before timing out.

[Watch](https://azure.microsoft.com/en-us/resources/videos/create-a-nodejs-site-deploy-from-github/) or [Read](https://docs.microsoft.com/en-us/bot-framework/deploy-bot-github) more on deploying node.js websites to azure.

The key thing is that once the app is deployed to the app service you need to go to application settings and load the values from the .env file into the app settings panel.
The key thing is that once the app is deployed to the app service, you need to go to application settings and load the values from the .env file onto the app settings panel.

You may also need to regenerate the npm packages on the server using [Kudu](https://github.com/projectkudu/kudu/) navigate to https://*****.scm.azurewebsites.net (where ***** is the name of your Web App) and running npm install against the Debug console / CMD / site / wwwroot directory.
You may also need to regenerate the npm packages on the server using [Kudu](https://github.com/projectkudu/kudu/) navigate to https://*****.scm.azurewebsites.net (where ***** is the name of your Web App) and run npm install against the Debug console / CMD / site / wwwroot directory.
35 changes: 35 additions & 0 deletions test/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,41 @@
"userId": "amzn1.ask.account.AFF5AH55JFXXIC72W3ZM4JKWOCQPEKXAAX2MXEKATFHWGOZSZETEVSJWCHHHBKH2YHRHYPWZXHF2BNUTKJZO5ANAJ67HMRO5JOLE3MJAW6LSN4BDUBMZSHOC2BS4MNXQKBLASABPVRGAINKEYBB6774D3KU3PT372ZMFJV7LKTPLCH2KNCXR3IRPNBN4FO2KAW3MXPHO3URBZEA"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.44f3794f-fd48-4a75-af4c-ad8cf536caa5"
},
"user": {
"userId": "amzn1.ask.account.AFF5AH55JFXXIC72W3ZM4JKWOCQPEKXAAX2MXEKATFHWGOZSZETEVSJWCHHHBKH2YHRHYPWZXHF2BNUTKJZO5ANAJ67HMRO5JOLE3MJAW6LSN4BDUBMZSHOC2BS4MNXQKBLASABPVRGAINKEYBB6774D3KU3PT372ZMFJV7LKTPLCH2KNCXR3IRPNBN4FO2KAW3MXPHO3URBZEA"
},
"device": {
"deviceId": "amzn1.ask.device.AEWRO6LVOD6IA3FRDKKAA6NXGMA5UYS77KEOPNHZIZYLLBBHV43EAYQ3G4KIF76BXA5EPA5KYIOO3QQ2BIZKJ5DPBEEIQP33CO3TM3LBQXSJUEJ7MICQTN56INM2X3UKMVKTQXIIRGRDAHXEIU55BP2XFFHVDELP2VDLMV53KYUMZMWJOUKME",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLjM0ZTZkYTJjLWY0NDMtNDFkNC05ZWI5LTU2YzNiN2IyY2E3ZSIsImV4cCI6MTU0MjEwODg1OSwiaWF0IjoxNTQyMTA1MjU5LCJuYmYiOjE1NDIxMDUyNTksInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUVXUk82TFZPRDZJQTNGUkRLS0FBNk5YR01BNVVZUzc3S0VPUE5IWklaWUxMQkJIVjQzRUFZUTNHNEtJRjc2QlhBNUVQQTVLWUlPTzNRUTJCSVpLSjVEUEJFRUlRUDMzQ08zVE0zTEJRWFNKVUVKN01JQ1FUTjU2SU5NMlgzVUtNVktUUVhJSVJHUkRBSFhFSVU1NUJQMlhGRkhWREVMUDJWRExNVjUzS1lVTVpNV0pPVUtNRSIsInVzZXJJZCI6ImFtem4xLmFzay5hY2NvdW50LkFFRTM1TjZFVUkyWUVSVTRMWUQ0TTZSR1RZU1VVRElSTVhDQU5RWURCVEY1QkQ0QVhDWjZCWEpaT1RJRktRSlpRSERFUjZXTkVSNVJTSUtDMlNPVVA0TFFPVllIWVdFTEFaMkEyR0ZRSkY3T1k3U0ZQQkVHSUhPQldSTFQ2Nkk0MkJCVkVaVldKVlZIREFFV0FTTjM3NFhKTVNGU081Q0RPTlVYWTRUMzVJSFNVT1A3SUdHUVBVTVBTNVRWWjJUQ1I3RktZWVNUT05LU0xVQSJ9fQ.UFxJrCjNeIV78SPbFZ40X9BsbzFdpGPOwwWrIw9y_aZy1yxUggQ0AmFU6Rd97eG_g5DrZMhu5GvRNEsZ5AdoNJzlsgFyauE9odA_NNYhEyN81SfwZ7eCUc_7OuIWyUTv9UbQVy1VF6h0AML9ffzIOaZYG4TnfaD6pFZfmq2M3LBVACnCk16l0jqEJpV3fjCmeRN2KoJDqWXmEPyFktm8LQgH_WaqyMy3aTTFmxVah7S7YjBSW9kdl63ddOkqYaej6_TcsuicKCB35uTu7aFJWOK6GIkF3JIQ6lPCMoQNUmfPCZixGMn85qO_eDNog7-WlBhQB6wMR6it9496xiSeZg"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
]
}
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.a1380a0d-cb45-45a3-8da4-3f557ee10bba",
Expand Down
70 changes: 70 additions & 0 deletions test/rest-request
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Run(ctrl+alt+R) the Below with 'REST Client' on your VScode:

POST http://localhost:8080/messages HTTP/1.1
Content-Type: application/json

{
"version": "1.0",
"session": {
"new": true,
"sessionId": "SessionId.b3eb3c4e-7c5a-4c10-a2e3-7e2c88a2b770",
"application": {
"applicationId": "amzn1.ask.skill.44f3794f-fd48-4a75-af4c-ad8cf536caa5"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.AFF5AH55JFXXIC72W3ZM4JKWOCQPEKXAAX2MXEKATFHWGOZSZETEVSJWCHHHBKH2YHRHYPWZXHF2BNUTKJZO5ANAJ67HMRO5JOLE3MJAW6LSN4BDUBMZSHOC2BS4MNXQKBLASABPVRGAINKEYBB6774D3KU3PT372ZMFJV7LKTPLCH2KNCXR3IRPNBN4FO2KAW3MXPHO3URBZEA"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.44f3794f-fd48-4a75-af4c-ad8cf536caa5"
},
"user": {
"userId": "amzn1.ask.account.AFF5AH55JFXXIC72W3ZM4JKWOCQPEKXAAX2MXEKATFHWGOZSZETEVSJWCHHHBKH2YHRHYPWZXHF2BNUTKJZO5ANAJ67HMRO5JOLE3MJAW6LSN4BDUBMZSHOC2BS4MNXQKBLASABPVRGAINKEYBB6774D3KU3PT372ZMFJV7LKTPLCH2KNCXR3IRPNBN4FO2KAW3MXPHO3URBZEA"
},
"device": {
"deviceId": "amzn1.ask.device.AEWRO6LVOD6IA3FRDKKAA6NXGMA5UYS77KEOPNHZIZYLLBBHV43EAYQ3G4KIF76BXA5EPA5KYIOO3QQ2BIZKJ5DPBEEIQP33CO3TM3LBQXSJUEJ7MICQTN56INM2X3UKMVKTQXIIRGRDAHXEIU55BP2XFFHVDELP2VDLMV53KYUMZMWJOUKME",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b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m8LQgH_WaqyMy3aTTFmxVah7S7YjBSW9kdl63ddOkqYaej6_TcsuicKCB35uTu7aFJWOK6GIkF3JIQ6lPCMoQNUmfPCZixGMn85qO_eDNog7-WlBhQB6wMR6it9496xiSeZg"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
]
}
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.a1380a0d-cb45-45a3-8da4-3f557ee10bba",
"timestamp": "2017-02-15T15:51:17Z",
"locale": "en-GB",
"intent": {
"name": "GetUserIntent",
"slots": {
"phrase": {
"name": "phrase",
"value": "who directed star wars"
}
}
},
"inDialog": false
}
}