Add details to retrieve the chat id

This commit is contained in:
Fabian Affolter 2015-11-03 19:22:45 +01:00
parent afe173773b
commit e8ae78c8f9

View File

@ -16,8 +16,8 @@ The telegram platform uses [Telegram](https://web.telegram.org) to delivery noti
The requirement are: 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. - 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 - The `chat_id` of an user.
An easy way to get your chat ID is described below: 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) 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: To enable Telegram notifications in your installation, add the following to your `configuration.yaml` file:
```yaml ```yaml
@ -35,15 +53,13 @@ To enable Telegram notifications in your installation, add the following to your
notify: notify:
name: NOTIFIER_NAME name: NOTIFIER_NAME
platform: telegram platform: telegram
# Get those by creating a new bot on https://core.telegram.org/bots
api_key: ABCDEFGHJKLMNOPQRSTUVXYZ api_key: ABCDEFGHJKLMNOPQRSTUVXYZ
chat_id: YOUR_CHAT_ID chat_id: YOUR_CHAT_ID
``` ```
Configuration variables: Configuration variables:
- **name** (*Optional*): Setting the optional parameter `name` allows multiple notifiers to be created. - **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
The default value is `notify`. The notifier will bind to the service
`notify.NOTIFIER_NAME`. `notify.NOTIFIER_NAME`.
- **api_key** (*Required*): The API token of your bot. - **api_key** (*Required*): The API token of your bot.
- **chat_id** (*Required*: The chat ID of your user. - **chat_id** (*Required*: The chat ID of your user.