Calling Webhooks
Seq can call HTTP GET/PUT/POST/DELETE endpoints using the Seq.App.HttpRequest output app.
Webhook example
This example shows how a Twilio SMS message can be sent through the HTTP request output app when an alert notification is triggered.
First, in Settings > Apps, install the output app using the package id Seq.App.HttpRequest
.
Then, start an instance of the app. This will prompt for settings that describe how an event will be translated into an HTTP request. Here's a screenshot of the complete configuration - read on below for a description of how the settings are applied.
The URL setting should be the webhook URL from Twilio.
To authenticate with Twilio set the HTTP Authorization
header using basic authentication. Basic authentication requires a header called Authorization with a value that is the word Basic
followed by username:password
base64 encoded. The JavaScript function btoa
base64 encodes a string, so building an Authorization header could look like this (not my real password):
let username = "bob";
let password = "P@ssw0rd";
`Authorization: Basic ${btoa(`${username}:${password}`)}`
Which produces the value Authorization: Basic Ym9iOlBAc3N3MHJk
. Once you have constructed your header string enter it into the Authentication Header setting.
The content of the text message that is sent is determined by the Body setting. Body can be literal text, or it can be built using template syntax (if the Body is a template checkbox is checked).
Variables available include @m
(message), @t
(timestamp), @x
(exception) and @p
(properties) of the event that caused the alert. There is also Alert Notification Properties such as Alert.Query
(the query that drives the alert) and Source.ResultsUrl
- a URL to the query and its results.
Twilio expects a form encoded request body, with the variables:
To
- The URI encoded number to send the SMS toMessagingServiceSid
- The Twilio messaging service identifierBody
- The message to send
The example sets the body to the message and exception from the triggering event, as well as the results URL:
To=%2B61404XXXXXX&MessagingServiceSid=xxxxxxxxxxxxxxxxxxxxxxxxx&Body={@m} {@x}
{uriencode(Source.ResultsUrl)}
Updated 7 months ago