Integrating with custom Output with Zapier
Estimated configuration time : 15mn
This tutorial demonstrates how to use Zapier's no-code platform to connect Sentry's API to different alerting devices, with a detailed guide on setting up Telegram alerts. The steps outlined for Telegram can be adapted for other devices.
This section assumes that user metrics and thresholds have already been configured. Our focus will be on setting up alert reception. For testing purposes, we recommend setting low thresholds (e.g., 0.01 or 0.001) to ensure that you are receiving alerts. These thresholds can be adjusted later without impacting the setup.
Summary
Telegram Bot configuration
Zapier General Architecture configuration
Zapier Webhook section configuration
Zapier Code section configuration
Zapier Telegram section configuration
Publish
Prerequisites
Before starting, ensure you have:
An active Sentry account with API access.
A Zapier account.
Access to the alerting device or service (like Telegram).
Telegram Bot configuration
The only way to receive external information in Telegram is by configuring a bot. Alerts will be displayed in a group as messages sent by this bot.
Steps are as follows:
Bot Creation: Initiate the creation of the bot through @BotFather, Telegram's native bot creator. Use the command
/newbot
to start configuring your bot, which will require:Name of the Bot: This is the name displayed for the bot, which must end with "bot." For example, in the video, the bot name is "Sentry_zapier_bot."
Handle of the Bot: This is the unique identifier for the bot, similar to a personal handle, and must end with "bot." It is used to easily locate the bot on Telegram. For instance, in the video, the handle is "test_sentry_zapier_bot."
Once configured, @BotFather will provide the Telegram link to the bot (it can also be found through the search bar using its handle).
Note that @BotFather will also issue a token access, which is necessary for the "Zapier Telegram Section Configuration." (Don't worry, the conversation with @BotFather is saved, and the token access can be retrieved later.)
Bot Creation:: The next step is to create a group that includes the bot. You can change the group name and add as many people as you want.
Zapier General Architecture Configuration
This section aims to set up the general architecture of Zapier. We will delve into each block in more detail later
Once you have registered with Zapier, you need to create a "Zap." This requires three main components:
Webhook: This will provide the webhook URL where Sentry will send the alerts.
Code: This component will process the information sent by Sentry to retain only the essential message.
Telegram: This will send the final message to Telegram.
To be able to publish the Zap and receive alerts in real-time, you must verify your email address.
Zapier Webhook configuration
This section bridges the connection between Sentry's API and Zapier's app.
Select Input Type
Configure the webhook section to receive data sent by Sentry as "Raw." This setting ensures that Zapier does not attempt to detect the JSON structure automatically (we will manually extract the data in the Code section).
Feed Sentry with Zapier's webhook URL
After configuration, Zapier will provide a webhook URL. Use this URL to inform Sentry where to send the alerts. The commands for setting up a webhook with Sentry can be found here or as displayed below:
The command to setup a webhook with sentry can be found here or as displayed below:
The webhook url sent by Zapier has to replace "YOUR_WEBHOOK_URL".
If the URL has been successfully sent to Sentry, the message returned by Sentry will be displayed as follows:
Test the trigger
It is crucial to test whether you are correctly receiving alerts, as failing to do so will prevent you from proceeding to the next step. We recommend setting a low threshold to receive an alert promptly. Feel free to click on "Test the Trigger" multiple times until you confirm that an alert is received.
Zapier Code section configuration
The alert's JSON contains a lot of different information (see Alert section). Here we will isolate the "message" to send it to Telegram in the next step
We will run a Javascript code.
Name the Input Data: Label the input data as "body," which corresponds to the "Raw Body" that we opted to receive in the webhook section.
Execute the Following Code:
This code parses the raw JSON data and isolates the alerts.
We can now extract the "message," clearly labeled by Zapier as "Message." This extracted message will be forwarded to Telegram in the last section.
Zapier Telegram section configuration
This section details how to connect Zapier with Telegram to enable the reception of notifications.
Configure the Block as SendMessage: Start by setting up the block to "SendMessage" in Zapier.
Zapier and Telegram Connection:
Connect Using Bot's Token Access: Link Zapier's Telegram block with Telegram using the bot's token access. As detailed in the "Telegram Bot Configuration" section, this token can be obtained from your conversation with @BotFather. Once entered, Zapier should easily recognize your bot.
Locate the Chat ID:
Click on the section within Zapier to discover all the groups and channels where your bot is a member.
Ensure that the ID number found by Zapier matches the one in your group's URL.
Refresh the page several times if Zapier does not immediately find your bot’s chats.
If you followed all the steps in this tutorial, you only should have one chat id displayed (instead of 3 in the video)
Send the Alert to Telegram:
With the connection established, send the "Message" retrieved in the "Zapier Code Section Configuration" as "Plain text."
Test the Step:
Click on "Test step" to automatically receive an alert in your Telegram group.
Publish:
By clicking on "Publish," Zapier will now automatically send any new alerts received to the Telegram group.
Zapier's freemium plan allows up to 1000 alerts.
Important: Remember to adjust your thresholds afterwards if you do not want to be overwhelmed with alerts and use up your credits prematurely.
Last updated