Skip to content

Latest commit

 

History

History
74 lines (57 loc) · 3.04 KB

File metadata and controls

74 lines (57 loc) · 3.04 KB

travel-browser

API Setup

We now have a DynamoDB table with key of "id" running.

This API, and an accompanying web page we setup later, will authenticate a skill user, GET their attribute data, POST any updates to attributes the user provides.

Lambda function

The API itself is just a proxy to a new Lambda function that performs the work. See /web/user/usersessionAPI

  1. Create a Lambda function. You can choose the default "Author from scratch".
  2. Name the function AlexaMemoryUserProfileFunction
  3. For Runtime, choose the option: Node.JS 8.10
  4. Select or create an IAM role that has read and write access to the askMemorySkillTable
  5. On the next page, scroll down to the Cloud9 code editor that has the index.js file open.
  6. Clear the contents and paste in the contents of usersessionAPI/lambda/index.js

Later on, use this event as a new Test definition within the Lambda console.

    { "queryStringParameters" :
        {
            "tempPassPhrase":"fast-car-345"
        },
        "path":"/lookup"
    }

API Trigger

Normally when we create a Lambda function we attach the Alexa Skills Kit trigger. For this function, we willl attach the API Gateway trigger.

  1. On the left, from the Triggers list, click "API Gateway" trigger.
  2. Scroll all the way down, and the panel prompts you to selct an API or create a new one.
  3. Choose "Create a new API"
  4. For Security, choose "Open"
  5. Click ADD.
  6. Scroll up to the top and click SAVE.

API Gateway

A new API Gateway such as AlexaMemoryUserProfile-API has now been created for you. We can review the settings, test, and deploy the API.

  1. Click to the API Gateway console console.
  2. CLick on your new API.
  3. Underneath Resources, you should see the tag "ANY".
  4. Click the Test lightning bolt.
  5. Choose method GET, proxy of "lookup", and Query String like tempPassPhrase=fast-car-345
  6. Click TEST. You should see some raw log messages and JSON. Scan for any errors, particularly at the end of the log.

Your API needs to be deployed in order to be used by anyone else.

  1. From the Actions button, choose Deploy API.
  2. For Deployment Stage, choose New Stage
  3. Call your Stage "dev" and click Deploy
  4. You can now see your stage within the Stages view
  5. Click into your stage and open the GET and POST verbs
  6. You will see an Invoke URL. This is your live web service.
  7. Copy this down. We will be pasting it into the file /www/js/userdata.js in a later step.

You should be able to try the url in a browser. Just append a query string like ?tempPassPhrase=fast-car-345

If necessary, re-launch the travel browser skill and say "link session". This will generate a fresh new pass phrase.

Configuration

Within the Lambda function, review settings for the TableName and tempPassPhraseExpiryMinutes. This value can be boosted from 5 minutes to a larger value for easier testing.

Next Step