Deep dive

From remote debugging to data discovery, learn how Formant works from top to bottom.

    Trigger Webhooks from events

    Webhooks are "user-defined HTTP callbacks". It allow arbitrary endpoints to subscribe to real-time Formant events. When an event occurs, Formant makes an HTTP request to the URL configured for the webhook. Users can configure them to invoke behavior on specific endpoints.

    Create a webhook

    From the burger menuselect Settings ⇒ Integration ⇒ Webhooks ⇒ Add Webhook

    Enter the name and the URL endpoint of the webhook. You can create any number of webhooks. All triggered events will route to all of the configured webhooks.

    The Formant cloud will send POST requests with a JSON body to the provided webhooks.

    Sample 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"
        }
    }
    © 2020 Formant • 1999 Bryant St · San Francisco, CA 94110