Alerts & Webhooks
Alert Webhooks
4min
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.
The following context variables can be used to set a webhook request header and payload:

Create the alert using the Alerts UI:

Or using the Alerts API :
Curl
1curl --location --request POST 'https://app.amberflo.io/notification' \
2--header 'Content-Type: application/json' \
3--header 'X-API-KEY: xyz' \
4--data-raw '{
5 "name": "usage-alert",
6 "meterId" : "4d1ca680-4974-11ec-ad9b-e1ce3f8b2ad3",
7 "cron": "0 0 * * 0",
8 "webhookUrl": "https://hooks.slack.com/services/T01HZB7A0M6/B01N83NQV6H/lMa2sYqDUnV3a7cLbBD9234",
9 "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>\"}}]}",
10 "thresholdCondition": "greater-than",
11 "thresholdValue": "1000",
12 "range":"day",
13 "customerFilterMode": "per-customer",
14 "enabled": true
15}'
Sample webhook payload for Slack
webhook_payload
1{
2 "text": "Amberflo Notification {{notification-name}} ",
3 "blocks": [
4 {
5 "type": "section",
6 "text": {
7 "type": "mrkdwn",
8 "text": "Amberflo notification: {{notification-name}}"
9 }
10 },
11 {
12 "type": "section",
13 "block_id": "section567",
14 "text": {
15 "type": "mrkdwn",
16 "text": "Your meter value has exceeded the allowed threshold limit."
17 }
18 },
19 {
20 "type": "section",
21 "block_id": "section789",
22 "fields": [
23 {
24 "type": "mrkdwn",
25 "text": "*Customer*\n {{customer-name}}"
26 },
27 {
28 "type": "mrkdwn",
29 "text": "*Meter*\n {{meter-name}}"
30 },
31 {
32 "type": "mrkdwn",
33 "text": "*Threshold condition*\n {{threshold-condition}}"
34 },
35 {
36 "type": "mrkdwn",
37 "text": "*Threshold limit*\n {{threshold-value}}"
38 },
39 {
40 "type": "mrkdwn",
41 "text": "*Current value*\n {{current-value}}"
42 }
43 ]
44 },
45 {
46 "type": "section",
47 "block_id": "section790",
48 "text": {
49 "type": "mrkdwn",
50 "text": "<{{ui-hyperlink}}|Click here to view usage details>"
51 }
52 }
53 ]
54}
Alerts will send the following HTTP request to the webhook endpoint:
Curl
1curl --location --request POST 'https://hooks.slack.com/services/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' \
2--header 'Content-Type: application/json' \
3--data-raw '{
4 "text": "Amberflo Notification alert-for-prepaid ",
5 "blocks": [
6 {
7 "type": "section",
8 "text": {
9 "type": "mrkdwn",
10 "text": "Amberflo notification: alert-for-prepaid"
11 }
12 },
13 {
14 "type": "section",
15 "block_id": "section567",
16 "text": {
17 "type": "mrkdwn",
18 "text": "Your meter value has exceeded the allowed threshold limit."
19 }
20 },
21 {
22 "type": "section",
23 "block_id": "section789",
24 "fields": [
25 {
26 "type": "mrkdwn",
27 "text": "*Customer*\n Oceanic Airlines"
28 },
29 {
30 "type": "mrkdwn",
31 "text": "*Threshold condition*\n less-than"
32 },
33 {
34 "type": "mrkdwn",
35 "text": "*Threshold limit*\n 1000000000"
36 },
37 {
38 "type": "mrkdwn",
39 "text": "*Current value*\n 40384"
40 }
41 ]
42 },
43 {
44 "type": "section",
45 "block_id": "section790",
46 "text": {
47 "type": "mrkdwn",
48 "text": "<https://ui.amberflo.io/customers/54a43bba-915d-4512-a0bd-9d9debesase|Click here to view usage details>"
49 }
50 }
51 ]
52}'
And the rendered Slack message will look like this:

Updated 30 Oct 2024
Did this page help you?