Trigger webhooks from events
A webhook allows you to make an API call to any endpoint over HTTP based on a trigger from a Formant event. When an event occurs, Formant makes an HTTP request to the URL configured for the webhook.
This guide will teach you how to configure a Formant event to trigger a webhook.
Step 1: Create a webhook
- In Formant, open the menu in the upper-left corner and click Settings.
- Click Integrations, and then scroll down to Webhooks. Click Connect.
- Enter the name and the URL endpoint of the webhook, along with any parameters you want to send. These parameters will be sent in a JSON body along with the POST request.
Step 2: Configure an event for webhook forwarding
- Create a new event, or open an existing event.
- Under the Actions tab, scroll to Webhook forwarding and select the webhook you configured in Step 1.
- POST requests will be sent with the JSON body to the endpoint you specify.
Example server
For reference, here is a simple flask server that processes Formant events.
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/', methods=["POST"])
def formant_event():
event = request.get_json()
print(event["payload"]["message"])
print(event["payload"]["value"])
return ""
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80)
Example payload
Example payload from Formant:
{
"eventType": "alert",
"payload": {
"id": "e0be1601-0ac2-41f8-b239-1dbe9a2d68db",
"message": "Oven temperature high",
"severity": "warning",
"streamName": "oven.temperature_c",
"streamType": "numeric",
"tags": {
"location": "sf"
},
"value": 250,
"time": "2019-03-09T00:13:22.903Z",
"deviceId": "c281e95e-c8f1-41b4-b573-e9138eab8900",
"sourceUrl": "https://app.formant.io/events/e0be1601-0ac2-41f8-b239-1dbe9a2d68db"
}
}
See also
If you notice an issue with this page or need help, please reach out to us! Use the 'Did this page help you?' buttons below, or get in contact with our Customer Success team via the Intercom messenger in the bottom-right corner of this page, or at [email protected].
Updated 7 months ago