# Telegram

## Domotz Telegram Integration

Telegram logo and wordmark.

The image displays the Telegram app logo, which is a paper plane inside a blue square. The word "Telegram" is written in blue text next to the logo, often used to represent the messaging application in branding and marketing materials.

[Domotz](https://www.domotz.com/) includes integration with [Telegram](https://telegram.org/), a cloud-based mobile and desktop messaging app with a focus on security and speed.

## Setting up a Telegram webhook for a shared channel in Domotz

Users can receive Domotz alerts on Telegram. All you need to do is create a Telegram bot API token and retrieve the Chat ID of the channel where you want to receive the messages.

### Create a Telegram bot API token

1. Create a Telegram bot.   To obtain a Telegram bot API token, you need to create a Telegram bot.   Learn how to create a Telegram bot [here](https://core.telegram.org/bots#creating-a-new-bot).
2. Obtain the API token information.   After you create the Telegram bot, you can obtain the API token information by talking to Telegram bot @BotFather, using /**mybots** command, and following instructions:

- Create a new conversation searching for @BotFather Telegram bot.
- Type command /newbot and follow instructions.

At the end of this procedure, you will obtain the **API token** which is the first information required to set up your Telegram webhook.

Creating a New Bot in Telegram

1. Type "/newbot" to start creating a new bot.
2. When prompted by BotFather, enter a name for your bot. Here, "TestDomotzAlerts" is used.
3. Next, choose a username for your bot that ends in "bot." Enter something like "TestDomotzAlertsBot."
4. Once the username is accepted, you will receive a confirmation message with your bot's details.
5. A link to your bot and an HTTP API token will be provided. Keep this token secure, as it is used to control your bot.
6. For further customization, such as adding a description or profile picture, refer to the provided links or use the "/help" command.

### Obtain a Telegram Chat ID

Start receiving Domotz alerts on Telegram by obtaining a chat ID for a chat or a group where your Telegram bot is in.

How to obtain a Telegram chat ID:

1. Create a Telegram group.
2. Invite your Telegram bot in it.
3. Start the chat by sending a message.
4. Open the following link to generate a JSON message https://api.telegram.org/bot<**BOT_API_TOKEN**>/getUpdates
5. Copy the id value from the JSON message to your chat.

This will be the Chat ID required to configure the Telegram webhook:

Extracting a Telegram Group ID from JSON Data.

1. Locate the JSON object that contains group information under "message".
2. Identify the key labeled "id" within this object.
3. The value of the "id" key, highlighted as -515476033, represents the Telegram Group ID.
4. Use this Group ID for operations that require identification of the Telegram group.

Note: You can use other Telegram bots able to display the Chat ID in the group itself.

Adding a Telegram Incoming Webhook

1. Enter a name for the webhook in the "Name" field, such as "Telegram Webhook."
2. In the "Telegram Token" field, input the provided token starting with "1631051577."
3. Fill in the "Chat ID" field with the appropriate value, such as "-515476033."
4. To save the webhook, click the "Add" button. To discard changes, select "Cancel."
