{"id":8833,"library":"apache-airflow-providers-telegram","title":"Apache Airflow Telegram Provider","description":"The `apache-airflow-providers-telegram` package extends Apache Airflow's functionality by providing operators to interact with the Telegram messaging platform. It allows users to send messages, images, and files directly from their Airflow DAGs. The current version is 4.9.4, and it follows Airflow's provider release cadence, with frequent updates to support new Airflow versions and Telegram API changes.","status":"active","version":"4.9.4","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow/tree/main/airflow/providers/telegram","tags":["apache-airflow","airflow-provider","telegram","messaging","notifications","workflow-automation"],"install":[{"cmd":"pip install apache-airflow-providers-telegram","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core Apache Airflow installation is required.","package":"apache-airflow","optional":false},{"reason":"Required for interacting with the Telegram Bot API.","package":"python-telegram-bot","optional":false},{"reason":"Provides compatibility utilities across different Airflow versions for providers.","package":"apache-airflow-providers-common-compat","optional":true}],"imports":[{"symbol":"TelegramOperator","correct":"from airflow.providers.telegram.operators.telegram import TelegramOperator"},{"symbol":"TelegramFileOperator","correct":"from airflow.providers.telegram.operators.telegram import TelegramFileOperator"}],"quickstart":{"code":"import os\nfrom datetime import datetime\n\nfrom airflow import DAG\nfrom airflow.providers.telegram.operators.telegram import TelegramOperator\n\n# Configure Telegram Connection in Airflow UI:\n# Conn Id: telegram_default\n# Conn Type: Telegram\n# Password: <YOUR_TELEGRAM_BOT_TOKEN> (from BotFather)\n# Host (optional): https://api.telegram.org (default)\n\n# Replace with your actual chat ID or fetch dynamically\nTELEGRAM_CHAT_ID = os.environ.get('TELEGRAM_CHAT_ID', '-1234567890') # Example: Group/Channel Chat ID, starts with '-' or User Chat ID\nTELEGRAM_BOT_TOKEN = os.environ.get('TELEGRAM_BOT_TOKEN', 'YOUR_BOT_TOKEN') # Only if not using Airflow Connection\n\nwith DAG(\n    dag_id='telegram_notification_dag',\n    start_date=datetime(2023, 1, 1),\n    schedule_interval=None,\n    catchup=False,\n    tags=['telegram', 'notification'],\n) as dag:\n    send_message_task = TelegramOperator(\n        task_id='send_test_message',\n        telegram_conn_id='telegram_default', # This uses the connection configured in Airflow UI\n        chat_id=TELEGRAM_CHAT_ID,\n        text='Hello from Airflow! This is a test message from {{ dag.dag_id }}.',\n        token=TELEGRAM_BOT_TOKEN if TELEGRAM_BOT_TOKEN != 'YOUR_BOT_TOKEN' else None # Optional: override connection token\n    )","lang":"python","description":"This quickstart demonstrates how to set up an Airflow DAG to send a message to Telegram using the `TelegramOperator`. You'll need to first create a Telegram bot via BotFather to get an API token, and then configure an Airflow connection named `telegram_default` with this token. The `chat_id` should be the ID of the chat, group, or channel where the message will be sent."},"warnings":[{"fix":"Ensure your Apache Airflow installation is version 2.11.0 or higher. If upgrading from an older Airflow version, follow the official Airflow upgrade guide and run `airflow upgrade db` if prompted.","message":"Minimum Apache Airflow version requirement has increased. Provider version 4.x.x (including 4.9.4) requires Apache Airflow >= 2.11.0.","severity":"breaking","affected_versions":"All versions from 4.0.0 onwards"},{"fix":"If you have custom hooks extending `TelegramHook`, you must update them to handle `get_conn()` as an asynchronous function. Refer to the `python-telegram-bot` transition guide for details on adapting to version 20.x changes.","message":"The underlying `python-telegram-bot` library was upgraded to version 20.0.0+ (currently >=20.2), which introduced backward-incompatible changes. Specifically, the `get_conn()` method in `TelegramHook` became a coroutine function. This affects users with custom hooks extending `TelegramHook`.","severity":"breaking","affected_versions":"Provider versions that depend on `python-telegram-bot` >= 20.0.0 (e.g., 4.0.0+)."},{"fix":"Upgrade Airflow to at least 2.1.0 before installing or upgrading to affected provider versions. The current provider (4.9.4) requires Airflow 2.11.0+, which inherently resolves this specific warning.","message":"Older provider versions had a breaking change related to the `apply_default` decorator removal, requiring Airflow 2.1.0+. While this is covered by the current minimum Airflow version, users on very old Airflow installations (pre-2.1.0) upgrading directly to modern provider versions might encounter issues.","severity":"deprecated","affected_versions":"Provider versions released after Airflow 2.1.0+ (e.g., 2.0.0, 3.0.0)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"For Docker or Linux environments, try setting the environment variable `no_proxy='*'` for your Airflow components (scheduler, workers, webserver). For macOS, this is a known `cpython` issue; configuring `no_proxy='*'` might also help.","cause":"This often occurs on macOS or Docker deployments due to Python's `_scproxy._get_proxies()` being invoked, leading to tasks getting stuck indefinitely due to network proxy resolution issues.","error":"Whenever the telegram operator is running, telegram will not receive any messages. Check the log in airflow and you can see that the task is stuck at Using connection ID 'telegram_conn_id' for task execution. for more than ten minutes without throwing any errors."},{"fix":"Ensure you have installed the provider using `pip install apache-airflow-providers-telegram`. If running Airflow in a Dockerized environment, make sure to add this `pip install` command to your Dockerfile and rebuild your Airflow images. Confirm all Airflow components have the provider installed.","cause":"The `apache-airflow-providers-telegram` package has not been correctly installed or is not accessible to your Airflow environment components (scheduler, worker, webserver).","error":"ModuleNotFoundError: No module named 'airflow.providers.telegram'"},{"fix":"Create a new connection in the Airflow UI (Admin -> Connections) with a 'Conn Id' of `telegram_default` (or your chosen ID) and 'Conn Type' set to 'Telegram'. Set your Telegram Bot Token in the 'Password' field. Alternatively, pass the `token` parameter directly to the `TelegramOperator` (though Airflow connections are generally preferred for security).","cause":"The `TelegramOperator` requires a Telegram connection ID to authenticate. By default, it looks for a connection named `telegram_default`, or you can specify a different `telegram_conn_id` parameter. This error indicates neither was found or correctly configured.","error":"airflow.exceptions.AirflowException: The telegram_conn_id is not specified. Please set the 'telegram_conn_id' parameter in the operator or configure a default 'telegram_default' connection."}]}