Integrating Your Serverless Telegram Bot with AWS API Gateway

  • We receive data as a JSON payload in the following format:
{ 
"name":"Test Name",
"email":"example-email@email.com",
"message":"This is an example message"
}
  • Other key-value data included is ignored
  • We raise an exception after basic input validation
  • We return the response from the Telegram API call with either a 200 or 400 status code in JSON format:
{
"statusCode": 200,
"body": {},
}
{
"name": "Test Name",
"email": "example-email@email.com",
"message": "Hello this is a test message from API Gateway"
}
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at {YOUR_API_GATEWAY_ENDPOINT} (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
  • Adding a rate limit
  • Add some kind of authorization, perhaps with IAM or Cognito.
  • You might want to disable CORS.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store