This example app will run on top of AWS serverless services such as:
- AWS DynamoDb
- AWS Lambda
- AWS REST API Gateway
The IaS (Infrastructure as Code) .yml file has been provided to help you deploying any necessary resources to run the application.
- Say hi to initiate the chat bot app and talk to Bot
- Get any messages on REST API
- /messages
- /messages/:msg_id
- /summary
- Deploying serverless based app
-
AWS Cloudwatch only showing the AWS lambda logs when you intentionally write logs to console
-
You need to create Business Page on Facebook to do integration with fb-messenger
-
You must subscribe to
messages&messaging_postbackswebhook events on FB-messenger setup page -
Also read this external resources for preparing your own integration and deployment :
-
Make sure your choice of AWS Regions support any of this services:
- AWS DynamoDb
- AWS Lambda
- AWS REST API Gateway
- AWS Elastic IP
- NodeJs version >= 12.x.x
- Facebook webhook version 13.0
- Facebook developer account
- AWS Account
- AWS CLI
- AWS SAM installed
Choose one from the two options below.
- RUN
sam pipeline bootstrapwill bootstraping all the required AWS resources to connecting CI/CD system - RUN
sam deploy -t codepipeline.yaml --capabilities=CAPABILITY_IAM --stack-name <STACK-NAME> --region <AWS-REGIONS> --parameter-overrides ProdStackName=<STACK-NAME> - After creating the stack, the CodeStar Connection is in PENDING status by default. You must complete the OAuth handshake with the third-party provider using the installation associated with your connection via AWS console
- RUN
aws cloudformation describe-stacks --stack-name <STACK-NAME> --region <AWS-REGIONS>to get endpoint URL on stackOutputs
- Change
WEBHOOK_VERIFY_TOKENenv placeholder of your choice on serverless.yml - Change
PAGE_ACCESS_TOKENenv placeholder on serverless.yml. Get generated access tokens from FB for Developer App Page on messenger settings - RUN
sam buildon projects root folder - RUN
sam deploy --guidedon projects root folder- enter stack name of your choice (ex: bot-test-app)
- enter
ap-southeast-1for AWS regions - choose
Nfor Confirm changes before deploy ? - choose
Yfor Allow SAM CLI IAM role creation - choose
Nfor Disable rollback - choose
Yfor Save arguments to configuration file - choose default name for SAM configuration file [samconfig.toml]
- choose default name for SAM configuration environment [default]
- Notes the Cloudformation output value of
endpointApiwhen successfully finished SAM deployment as your REST API base URL - Add URL from point 5 as callback URL on FB-Messenger for developer setup page
- Add
/webhookpath to base URL (ex: https://BASE_URL/webhook) - Add
Verify tokenwith the same token of your choice as point no.1
- Add
- Go to the FB-Page you created before and say hi on chat
- RUN
sam delete -t serverless.ymlon projects root folder - Choose
Yfor the remaining options - Go to AWS console to manually release elastic IP on VPC menu --> Elastic IP submenu
Notes: AWS Cloudformation will not automatically release unused Elastic IP so you have to do it manually to avoid any unnecessary billing.

