Alert Webhooks
An alert can be configured to be sent via webhook call. In this case, an HTTP POST request will be made to the specified endpoint, containing a JSON payload, whenever the threshold condition is met.
If the response has a 200 status code, it is considered successful, otherwise the alert system will keep trying to send the alert.
Context Variables
The following context variables can be used to setup a webhook request header and payload:
Keyword | Description |
---|---|
{{customer-id}} | customerId from the Customer API |
{{customer-name}} | customerName from Customer API |
{{meter-id}} | meter ID from the Meter Definition API |
{{meter-name}} | meterApiName from the Meter Definition API |
{{notification-id}} | notification ID |
{{notification-name}} | notification name |
{{current-value}} | current aggregated value of the meter |
{{threshold-value}} | thresholdValue as specified in the Alerts API |
{{threshold-condition}} | thresholdCondition as specified in the Alerts API |
{{ui-hyperlink}} | Related Amberflo UI dashboard link |
{{entity-type}} | type of entity in the undefined-meter and undefined-customer alerts |
{{entity-list}} | comma separated names of the undefined entities in the undefined-meter and undefined-customer alerts. |
Sample Webhook for Slack
Create the alert using the Alerts UI:

Or using the Alerts API:
curl --location --request POST 'https://app.amberflo.io/notification' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: xyz' \
--data-raw '{
"name": "usage-alert",
"meterId" : "4d1ca680-4974-11ec-ad9b-e1ce3f8b2ad3",
"cron": "0 0 * * 0",
"webhookUrl": "https://hooks.slack.com/services/T01HZB7A0M6/B01N83NQV6H/lMa2sYqDUnV3a7cLbBD9234",
"webhookPayload": "{\"text\":\"Amberflo Notification {{notification-name}} \",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Amberflo notification: {{notification-name}}\"}},{\"type\":\"section\",\"block_id\":\"section567\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Your meter value has exceeded the allowed threshold limit.\"}},{\"type\":\"section\",\"block_id\":\"section789\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Customer*\\n {{customer-name}}\"},{\"type\":\"mrkdwn\",\"text\":\"*Meter*\\n {{meter-name}}\"},{\"type\":\"mrkdwn\",\"text\":\"*Threshold condition*\\n {{threshold-condition}}\"},{\"type\":\"mrkdwn\",\"text\":\"*Threshold limit*\\n {{threshold-value}}\"},{\"type\":\"mrkdwn\",\"text\":\"*Current value*\\n {{current-value}}\"}]},{\"type\":\"section\",\"block_id\":\"section790\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<{{ui-hyperlink}}|Click here to view usage details>\"}}]}",
"thresholdCondition": "greater-than",
"thresholdValue": "1000",
"range":"day",
"customerFilterMode": "per-customer",
"enabled": true
}'
Sample webhook payload for Slack
{
"text": "Amberflo Notification {{notification-name}} ",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Amberflo notification: {{notification-name}}"
}
},
{
"type": "section",
"block_id": "section567",
"text": {
"type": "mrkdwn",
"text": "Your meter value has exceeded the allowed threshold limit."
}
},
{
"type": "section",
"block_id": "section789",
"fields": [
{
"type": "mrkdwn",
"text": "*Customer*\n {{customer-name}}"
},
{
"type": "mrkdwn",
"text": "*Meter*\n {{meter-name}}"
},
{
"type": "mrkdwn",
"text": "*Threshold condition*\n {{threshold-condition}}"
},
{
"type": "mrkdwn",
"text": "*Threshold limit*\n {{threshold-value}}"
},
{
"type": "mrkdwn",
"text": "*Current value*\n {{current-value}}"
}
]
},
{
"type": "section",
"block_id": "section790",
"text": {
"type": "mrkdwn",
"text": "<{{ui-hyperlink}}|Click here to view usage details>"
}
}
]
}
Alerts will send the following HTTP request to the webhook endpoint:
curl --location --request POST 'https://hooks.slack.com/services/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' \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "Amberflo Notification alert-for-prepaid ",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Amberflo notification: alert-for-prepaid"
}
},
{
"type": "section",
"block_id": "section567",
"text": {
"type": "mrkdwn",
"text": "Your meter value has exceeded the allowed threshold limit."
}
},
{
"type": "section",
"block_id": "section789",
"fields": [
{
"type": "mrkdwn",
"text": "*Customer*\n Oceanic Airlines"
},
{
"type": "mrkdwn",
"text": "*Threshold condition*\n less-than"
},
{
"type": "mrkdwn",
"text": "*Threshold limit*\n 1000000000"
},
{
"type": "mrkdwn",
"text": "*Current value*\n 40384"
}
]
},
{
"type": "section",
"block_id": "section790",
"text": {
"type": "mrkdwn",
"text": "<https://ui.amberflo.io/customers/54a43bba-915d-4512-a0bd-9d9debesase|Click here to view usage details>"
}
}
]
}'
And the rendered Slack message will look like this:

Updated 7 months ago