Webhook

Learn about Webhook node functionality within SuprSend workflows

Webhook is an http api request call to notify an endpoint such as your CRMs, send chat notifications via platforms like Facebook Messenger, or call custom vendors. You can club it with branches to route notifications via different services based on user properties like region, city etc.

Any data returned in the api request response is appended to the response_key in your webhook function and then merged with the input payload.


Configuring Webhook node

In a Webhook node, you have to define the endpoint, query params and headers. You can add both static and dynamic values in all request fields except response key. All Static values are added within "static value" and dynamic data is referred as data.key.

FieldDescription
Method*Supported methods - GET, POST, PUT, PATCH, DELETE
Endpoint*A valid URL endpoint. Add static URL as "https://static_url" and dynamic URL as {{data.url_endpoint}}. Data for dynamic URL will be picked from trigger payload. You can also combine static and dynamic part as "https://domain" + {{data.path}}.
ParamsQuery Params to pass in the request. Similar to endpoint, you can pass both static and dynamic value in query params.
HeaderAny header to be passed in the request can be added as key-value pair with key being the header type and value as header value. You can use it to pass signing key.
Response keyResponse of your webhook request is appended against response key and merged in the workflow payload. Data is merged at parent level if response key is not set.


Adding variables in Webhook node

Fetch node supports JSONNET rendering language. You can add workflow trigger payload variables as data.<key> and internal suprsend data as data["$brand"].<key>. Here's a list of variables supported in workflow engine:

VariableDescriptionJSONNET format
Input Payloaddata passed in your event or workflow trigger.data.key
Actorproperties of actor in your workflow trigger. In case of event, distinct_id works both as actor and recipient.data["$actor"].key
Recipientproperties of recipient in your workflow trigger. In case of event, distinct_id works both as actor and recipient, unless override recipient is set in workflow trigger settings. In case of override recipient, properties of overriden recipient is picked.data["$recipient"].key
Brand / Tenantproperties of the tenant passed in workflow trigger.data["$brand"].key

Request execution

When executing a webhook function, SuprSend expects the following from your service:

  • The response to the request is one of: 200 OK, 201 Created, or 204 No Content.
  • If the request response contains data, it's encoded as JSON and can be decoded into a map/dictionary/hash.
  • The response to the request takes no longer than 5 seconds for SuprSend to receive.

Merging Response to workflow input

If you have added a response key in your setting. The response is first appended to the response key and then merged to the input workflow data. The response is merged at parent level if response key is empty.

The merged data result from a webhook function step then becomes the global trigger data for all subsequent steps in the workflow run.

Here's how webhook function data output would look like with response key and without response key


// node input data
{
  "name":"old_name",
  "location":{
    "city":"old_city"
  }
}

//Fetch function response
{
  "org":"new_org",
  "location":{
    "state":"new_state"
  }
}

//Merged data with response key = webhook_response
{
  "name":"old_name",
  "location":{
    "city":"old_city"
  },
  "webhook_response":{
    "org":"new_org",
    "location":{
      "state":"new_state"
    }
  }
}
  
//Merged data with empty response key
{
  "name":"old_name",
  "org":"new_org",
  "location":{
    "state":"new_state"
  }
}