From e8ae78c8f96a756a4d05cc4c1ff863027eb004d2 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 3 Nov 2015 19:22:45 +0100 Subject: [PATCH] Add details to retrieve the chat id --- source/_components/notify.telegram.markdown | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/source/_components/notify.telegram.markdown b/source/_components/notify.telegram.markdown index 3f963cbc011..5c4efaccdb0 100644 --- a/source/_components/notify.telegram.markdown +++ b/source/_components/notify.telegram.markdown @@ -16,8 +16,8 @@ The telegram platform uses [Telegram](https://web.telegram.org) to delivery noti The requirement are: -- You need a [Telegram bot](https://core.telegram.org/bots). Please follow those [instructions](https://core.telegram.org/bots#botfather) to create one and get the token. Keep in mind that bots are not allowed to contact users. You need to make the first contactwith your user. -- The chat ID of an user +- You need a [Telegram bot](https://core.telegram.org/bots). Please follow those [instructions](https://core.telegram.org/bots#botfather) to create one and get the token for your bot. Keep in mind that bots are not allowed to contact users. You need to make the first contact with your user. Meaning that you need to send a message to the bot from your user. +- The `chat_id` of an user. An easy way to get your chat ID is described below: @@ -28,6 +28,24 @@ chat_id = bot.getUpdates()[-1].message.chat_id print(chat_id) ``` +Another way to retrieve your `chat_id` is visiting [https://api.telegram.org/botYOUR_API_TOKEN/getUpdates](https://api.telegram.org/botYOUR_API_TOKEN/getUpdates). + +The result set will include your chat ID as `id` in the `from` section: + +```json +{ + "ok":true, + "result":[ + { + "update_id":254199982, + "message":{ + "message_id":201, + "from":{ + "id":123456789, + "first_name":"Your first name", +... +``` + To enable Telegram notifications in your installation, add the following to your `configuration.yaml` file: ```yaml @@ -35,15 +53,13 @@ To enable Telegram notifications in your installation, add the following to your notify: name: NOTIFIER_NAME platform: telegram - # Get those by creating a new bot on https://core.telegram.org/bots api_key: ABCDEFGHJKLMNOPQRSTUVXYZ chat_id: YOUR_CHAT_ID ``` Configuration variables: -- **name** (*Optional*): Setting the optional parameter `name` allows multiple notifiers to be created. -The default value is `notify`. The notifier will bind to the service +- **name** (*Optional*): Setting the optional parameter `name` allows multiple notifiers to be created. The default value is `notify`. The notifier will bind to the service `notify.NOTIFIER_NAME`. - **api_key** (*Required*): The API token of your bot. - **chat_id** (*Required*: The chat ID of your user.