Overview of steps
- Set Bot with BotFather for Telegram
- Get the chat_id of your Telegram Group
- Update Mage project settings
Configure alerts in the Mage Pro UI
After you create your Telegram bot webhook URL, you can configure alerts in the Mage Pro UI instead of editingmetadata.yaml directly:
- For project defaults, go to Settings > Account > Alerts.
- For one pipeline, open the pipeline and go to Alerts. Pipeline-level settings override the project-level alert config for that pipeline.
- Choose the alert outcomes, enable Telegram, enter the webhook URL, and use Send test notification to send a test alert before saving.
{{ env_var('MAGE_TELEGRAM_WEBHOOK_URL') }}.
Set Bot with BotFather for Telegram
Follow these Tutorial to setup Bot with BotFather and Don’t Forget to add your Bot to the Group.Get the chat_id of your Telegram Group
- Open https://web.telegram.org/ and Follow the instructions
- Click your Telegram Group and your Group chat_id is on your url like
https://web.telegram.org/a/#-7222xxxxxx
Update Mage project settings
Once you’ve set up the Bot and get thechat_id of your group, you need to set the webhook like example below:
Here is an example webhook (yours may vary):
- Open the Mage tool in your browser (e.g. http://localhost:6789/).
- Open a pipeline and start editing it (e.g. http://localhost:6789/pipelines/example_pipeline/edit).
-
In your left sidebar in the file browser, scroll all the way down and click
on a file named
metadata.yaml. -
In the
metadata.yamlfile, add a section with the following configuration or update the existingnotification_configsection:If you omit thealert_onsection it will default totrigger_failureandtrigger_passed_sla. Options:trigger_failure: alert when a run of a trigger failstrigger_success: alert when a run of a trigger succeedstrigger_passed_sla: alert when a SLA is missed.- In this context, SLA (Service Level Agreement) is an expected amount of time for the pipeline to complete.
- If the pipeline runs longer than the SLA, an alert will be sent.
-
In the
metadata.yamlfile, add the following values:Change thewebhook_urlvalue to be the webhook URL like mentioned above.
Customize message templates
You can customize message templates innotification_config. Here is an example config:
success, failure, passed_sla scenarios. For each message template,
you can specify the sentence on summary and the title.
To interpolate variables in the message template, you can use {variable_name} syntax.
Here are the supported variables:
execution_timepipeline_run_urlpipeline_schedule_idpipeline_schedule_namepipeline_schedule_descriptionpipeline_uuiderror- available only for the
failuremessage template
- available only for the
stacktrace- available only for the
failuremessage template
- available only for the
Note: Forpipeline_run_url, the default host ishttp://localhost:6789. You can specifyMAGE_PUBLIC_HOSTto be the host url you want to use in the notification messages.
🚀 Pro Only: Interpolate Mage Variables in Message Templates
If you’re using Mage Pro, you can interpolate environment variables and other Mage variables directly in your Telegram message templates using the familiar Jinja-like syntax:execution_time, pipeline_uuid, etc), you can also use the
following in your message templates in Mage Pro:
start_timeend_timeduration(in seconds)env(this gets the value stored in theENVenvironment variable)
