base_telegram/README.md

26 lines
1023 B
Markdown
Raw Permalink Normal View History

2025-02-19 16:15:22 +03:00
# Odoo base_telegram
Odoo Telegram API
Menu: Settings / Technical / Parameters / Telegram API Connections
## Add new connection
- Open the chat with [@BotFather](https://t.me/BotFather)
- Enter the command **/newbot** to create a bot
- Save received **token** (like: 1234567890:ABcdeFghKLMNopqrs_TUvWxyz)
- Create a group where the created bot should post messages
- Add the bot to the group
- Grant the bot admin access in the group
- Send a test message in the group, ensure that the bot can read it
- Save **Chat ID** from test message
![Telegram API new connection form](chat_bot_config_form.png "Telegram API new connection form")
## Send message to Telegram
``env["base.telegram"].browse(1).send_message('Test')``
## Send message from project.task by template
``
self = env["base.telegram"].browse(1)
obj = env['project.task'].browse(4)
self.with_context(lang=env.user.lang if env.user.lang else 'ru_RU', tz=env.user.tz if env.user.tz else 'Europe/Moscow').send_template('base_telegram.message_new_task', obj)
``