Posting notifications in telegram via bot

This telegram bot substitutes ifttt’s applet “Webhook to Telegram”, which may work slowly.


Create a bot

  • In telegram client open BotFather

  • Send /newbot command to create a new bot

  • Follow instruction to set bot name and get bot token

  • Keep your token secure and store safely, it can be used by anyone to control your bot

Prepare zip file

To make deployment package execute following commands:

mkdir /tmp/bot
cd /tmp/bot

pip3 install pyTelegramBotAPI -t .
zip -r /tmp/ *

Create Lambda function


Use Python 3.6

Function code

  • Set Code entry type to Upload a .zip file

  • Select file you made

Environment variables

  • BOT_TOKEN – the one you got from BotFather

  • TELEGRAM_CHAT – where to send notification. You can chat id by sending any message to Get My ID bot

  • EVENT_<EVENT_NAME> – set response value. Use IFTTT syntax. For example:

    EVENT_RED_PULL_REQUEST set to value PR TESTS are failed: {{Value1}}<br> {{Value2}}.


  • API Gateway. Once you configure it and save, you will see Invoke URL under Api Gateway details section

  • Set the security mechanism for your API endpoint as Open

Try it out

Use URL of the following format to replace with your ifttt webhook URL:

<INVOKE_URL>?event=<EVENT_NAME>, for example