mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 16:56:50 +00:00
Add details to retrieve the chat id
This commit is contained in:
parent
afe173773b
commit
e8ae78c8f9
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user