Signal Webhooks

Context Variables

The following context variables can be used to setup a webhook 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 Signals API

{{threshold-condition}}

thresholdCondition as specified in the Signals API

{{ui-hyperlink}}

Related Amberflo UI dashboard link

Once a signal is setup for a webhook, a POST http request with JSON payload is sent to the configured webhook endpoint when the threshold condition is met.

Sample Webhook for Slack

Create the signal using the Signals UI

385385

or Signals 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>"
            }
        }
    ]
}

Signals will send the following http request to the web hook 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>"
            }
        }
    ]
}'

Rendered Slack message

497497

Did this page help you?