Telegram notification on Odoo Updates

Here we’ll make a telegram bot, that sends you notification whenever new task assigned to you is created. You’ll need:


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

mkdir /tmp/bot
cd /tmp/bot

pip3 install python-telegram-bot -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

  • LOGGING_LEVEL – Level of loger. Allowed values: DEBUG, INFO, CRITICAL, ERROR, WARNING. Default value: INFO

  • TELEGRAM_USER_ID – put here your ID. You can get one by sending any message to Get My ID bot


  • 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

Register lambda webhook

  • Model: Task (project.task)

  • Trigger Condition: On Creation

  • Filter by task by users:

    • In Odoo 10.0: set Filter to [["user_id","=",123]]

    • In Odoo 11.0+: set Apply On to [["user_id","=",123]]

    Here 123 is your user ID. To get the ID, navigate to [[ Settings ]] >> Users menu, open your user, check ID value in the browser URL

  • Python Code:

    data = {
    log("Sending to webhook: %s" % data), json=data)

Try it out

  • Open created telegram bot and send any message to it. It’s needed to allow bot send a message to you.

  • Open Odoo and create new task assigned to you.

  • RESULT: the bot will send you a notification

  • If something goes wrong, check Odoo logs and CloudWatch logs


Key script of the bot is presented below:

import telegram  #
import sys
import os
import logging
import re
import json

logger = logging.getLogger()
LOG_LEVEL = os.environ.get('LOG_LEVEL')
    logger.setLevel(getattr(logging, LOG_LEVEL))

BOT_TOKEN = os.environ.get('BOT_TOKEN')

def lambda_handler(event, context):
    logger.debug("Event: \n%s", event)
    data = json.loads(event['body'])

    bot = telegram.Bot(token=BOT_TOKEN)
    message = "New task is created by %s:\n%s" % (data['created_by_name'], data['task_name'])
    bot.sendMessage(TELEGRAM_USER_ID, message)

Custom integration

For any further assistance contact us by email or fill out request form: