Each service creation represents a step and you can find the necessary values to create them. These steps were used in the WAES Techtalk Demo.
Prerequisites:
- The role
WaesTechTalkChatBot_ApiGateway_Role
must exists and allows the API Gateway to post data to the Queues. - The role
WaesTechTalkChatBot_LambdaFunctions_Role
must exists and allows the Lambda Functions to:- Read and Post messages into the Queues
- Retrieve secrets from Secrets Manager
You can check the Article How to Build a Reliable, Scalable, and Cost-Effective Telegram Bot to understand how to create the services.
- Name: WaesTechTalkChatBot_Queue.fifo
- Let all the other options with the default values
- Protocol: REST
- Create New API: New API
- Api Name: WaesTechTalkChatBot_Api
- Name: WaesTechTalkChatBot_Api_Resource
- Path: batata
- HTTP Verb: POST
- Integration Type: AWS Service
- AWS Region: eu-west-1
- AWS Service: Simple Queue Service (SQS
- HTTP Method: POST
- Action Type: Use path override
- Path override:
AWS Account ID
/WaesTechTalkChatBot_Queue.fifo - Execution role: arn:aws:iam::
AWS Account ID
:role/WaesTechTalkChatBot_ApiGateway_Role - Content Handling: Passthrought
-
Add the header:
- Content-Type: 'application/x-www-form-urlencoded'
-
Add Mapping Template:
- Request body passthrought: Never
- Content-Type: application/json
- Template: Action=SendMessage&MessageGroupId=$context.requestId&MessageDeduplicationId=$context.requestId&MessageBody=$util.base64Encode($input.body)
- Deploy API to dev environment.
- Name: WaesTechTalkChatBot_OutboundQueue.fifo
- Let all the other options with the default values
-
Function name: WaesTechTalkChatBot_Inbound_Function
-
Runtime: Node.js:16.x
-
Architecture: arm64
-
Change default execution role: WaesTechTalkChatBot_LambdaFunctions_Role
-
Change Handler to handler.handler
-
Upload zip file.
-
Set OutboundQueueName env var: WaesTechTalkChatBot_OutboundQueue.fifo
-
Set trigger:
- SQS
- arn:aws:sqs:eu-west-1:662642131450:WaesTechTalkChatBot_Queue.fifo
- Batch size: 1
- Username: waes_techtalk_telegram_bot
- Secret Name: WaesTechTalkChatBot_TelegramBotToken
- Secret Key: token
-
Function name: WaesTechTalkChatBot_OutBound_Function
-
Runtime: Node.js:16.x
-
Architecture: arm64
-
Change default execution role: WaesTechTalkChatBot_LambdaFunctions_Role
-
Change Handler to handler.handler
-
Upload zip file.
-
Set TelegramBotToken env var: WaesTechTalkChatBot_TelegramBotToken
-
Set trigger:
- SQS
- arn:aws:sqs:eu-west-1:662642131450:WaesTechTalkChatBot_OutboundQueue.fifo
- Batch size: 1