---
title: telegram package
description: The telegram package provides functions for sending messages to Telegram using the Telegram Bot API.
url: https://docs.influxdata.com/flux/v0/stdlib/contrib/sranka/telegram/
estimated_tokens: 1129
product: Flux
version: v0
---

# telegram package

-   Flux 0.70.0+
-   View InfluxDB support

The `telegram` package is a user-contributed package maintained by the [package author](#package-author-and-maintainer).

The `telegram` package provides functions for sending messages to [Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api). Import the `contrib/sranka/telegram` package:

```js
import "contrib/sranka/telegram"
```

## Set up a Telegram bot

The **Telegram Bot API** requires a **bot token** and a **channel ID**. To set up a Telegram bot and obtain the required bot token and channel ID:

1. [Create a new Telegram account](https://telegram.org/) or use an existing account.
    
2. [Create a Telegram bot](https://core.telegram.org/bots#creating-a-new-bot). Telegram provides a **bot token** for the newly created bot.
    
3. Use the **Telegram application** to create a new channel.
    
4. [Add the new bot to the channel](https://stackoverflow.com/questions/33126743/how-do-i-add-my-bot-to-a-channel) as an **Administrator**. Ensure the bot has permissions necessary to **post messages**.
    
5. Send a message to bot in the channel.
    
6. Send a request to `https://api.telegram.org/bot$token/getUpdates`.
    
    ```sh
    curl https://api.telegram.org/bot$token/getUpdates
    ```
    
    Find your **channel ID** in the `id` field of the response.
    

## Options

```js
option telegram.defaultDisableWebPagePreview = false

option telegram.defaultParseMode = "MarkdownV2"

option telegram.defaultSilent = true

option telegram.defaultURL = "https://api.telegram.org/bot"
```

### defaultDisableWebPagePreview

`defaultDisableWebPagePreview` - Use Telegram web page preview by default. Default is `false`.

### defaultParseMode

`defaultParseMode` is the default [Telegram parse mode](https://core.telegram.org/bots/api#formatting-options). Default is `MarkdownV2`.

### defaultSilent

`defaultSilent` - Send silent Telegram notifications by default. Default is `true`.

### defaultURL

`defaultURL` is the default Telegram bot URL. Default is `https://api.telegram.org/bot`.

## Functions

-   [telegram.endpoint()](/flux/v0/stdlib/contrib/sranka/telegram/endpoint/)
-   [telegram.message()](/flux/v0/stdlib/contrib/sranka/telegram/message/)
