From 9de5ef6de8edb3e405803595ddad688d4073f692 Mon Sep 17 00:00:00 2001 From: _BlacKHawK_ Date: Wed, 14 Nov 2018 13:21:12 +0530 Subject: [PATCH 1/3] Adding context into the Test Request's request.json --- test/request.json | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/request.json b/test/request.json index e160413..b8d059b 100644 --- a/test/request.json +++ b/test/request.json @@ -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": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6I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VACnCk16l0jqEJpV3fjCmeRN2KoJDqWXmEPyFktm8LQgH_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", From 980d8479d0345a618cf952f10b1b8c22ad44f6d2 Mon Sep 17 00:00:00 2001 From: _BlacKHawK_ Date: Wed, 14 Nov 2018 13:22:00 +0530 Subject: [PATCH 2/3] Adding RestRequest for Rest Clients. --- test/rest-request | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/rest-request diff --git a/test/rest-request b/test/rest-request new file mode 100644 index 0000000..946054e --- /dev/null +++ b/test/rest-request @@ -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.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", + "timestamp": "2017-02-15T15:51:17Z", + "locale": "en-GB", + "intent": { + "name": "GetUserIntent", + "slots": { + "phrase": { + "name": "phrase", + "value": "who directed star wars" + } + } + }, + "inDialog": false + } +} \ No newline at end of file From 98acb5caa0bd7ac30a31454e65e57af512974c87 Mon Sep 17 00:00:00 2001 From: _BlacKHawK_ Date: Wed, 14 Nov 2018 15:34:14 +0530 Subject: [PATCH 3/3] Changes for the purpose of clarity. --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 074fe9d..0c6fe5c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -101,6 +101,10 @@ 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 , " + +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. @@ -108,7 +112,7 @@ Take the public endpoint for the 3979 (or whatever you choose) port and use as t ## 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 @@ -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. \ No newline at end of file +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. \ No newline at end of file