Search code examples
.netbotsbotframeworkalexa-skills-kit

Alexa bot using Bot Framework composer


I am trying to create an Alexa bot using Bot framework composer which will eventually be hosted onto the Azure bot service. Is there any way that the attributes like device id and session attributes can be extracted from the Alexa response and passed to Bot Framework so it can make some API calls? Example I want to retrieve the deviceID of the Alexa user from the conversation so it can make API call to amazon services to find the postcode of the user.

I have previously built Alexa bot using Azure function and it was successful in retrieving these attributes but now I want a larger bot service with several pathways hence shifting to Bot Framework composer.


Solution

  • I am not sure how you want to use device id for bot framework but you can get device id and zip code from Alexa. Device Id is included in a request from Alexa and you can retrieve zip code using device address API if a user sets zip code on devices.

    Step 1: Configure the skill to request customer permissions for the device address 1. Edit your skill in the developer console. 2. Navigate to the Build > TOOLS > Permissions page. 3. Select Device Address and either Full Address or Country/Region & Postal Code Only, depending which information your skill uses.

    Step 2: Get the API access token and device ID Each request sent to your skill includes an API access token (apiAccessToken) that encapsulates the permissions granted to your skill. You must retrieve both this token and the device ID (deviceId) and include them in requests for the customer's "Full Address" or "Country/Region & Postal Code".

    Step 3: Send a message to the correct address endpoint that includes the apiAccessToken and deviceId https://developer.amazon.com/en-US/docs/alexa/custom-skills/device-address-api.html#get-country-and-postal-code

    If you need to use session attribute to save some data, you can follow https://developer.amazon.com/en-US/docs/alexa/custom-skills/manage-skill-session-and-session-attributes.html.