Integrating AWS Lambda and API Gateway for Facebook Messenger Chatbot

Post date: Dec 16, 2016 8:53:10 PM

MedX API

provides diagnosis procedure given initial symptoms and questionnaires

[dev] (dev-bot-fbcb) in directory /lambdaFunctions/TestStateMachine/
DynamoDB: TestStateProfile
API Gateway: 
curl -d '{"user_id":"101","intent":"diagnose","context":"query_by_symptoms","payload":{"tokens":["headache","vision","blurred"]}}' https://uaf8kdvr76.execute-api.us-west-2.amazonaws.com/dev/teststatemachine

TestBot API

Facebook Messenger API -- provides chatbot platform in general

[dev] (dev-bot-fbcb) in directory /lambdaFunctions/TestBot/
DynamoDB: -
API Gateway: https://uaf8kdvr76.execute-api.us-west-2.amazonaws.com/dev/TestBot

Lessons learned

- You can add your code to the lambda inline editor directly, with signature:

def lambda_handler(event, context):

# your code

pass

return {<your_key>: <your data>}

- You can still use lambda_flip to assign alias "release" to the lambda container.

python redtronimus/scripts/deploy/tasks/lambda_flip.py TestStateMachine

- When you want to add API Gateway as a trigger to the lambda function, you can

-- make a new API, in my case, test_bot_xp

-- Create new resource (endpoint) to the API.

-- Define the method under each resource, then link to your_api_name:alias, in my case TestStateMachine:release

-- For each new endpoint, you will need to go Resources > Deploy API and now you will have the API endpoint. Not deploy api can result in the response ("message": "Missing authentication token.").

Read this Stackoverflow url: http://stackoverflow.com/a/32610259/1613297