Webhook blocks
Overview
Webhook blocks allow you to send data to an external API once a user reaches the block. This can be useful for triggering a follow up email or notifying your team in a Slack channel.
Webhooks can be configured with a URL, optional request headers, and an optional request body.
Webhook blocks only support POST
requests at this time.
The webhook request body must be in JSON format.
Triggering
A webhook will be triggered immediately after its preceding block is completed. The immediate block(s) following the webhook block will then trigger or become active.
If the webhook block immediately follows a start block, then the webhook will not fire until the user is seen by Dopt. This means that the webhook will not trigger until Dopt is initialized in the context of a particular user in your product.
If the webhook happens to fail, the immediate block(s) following the webhook block will still trigger or become active.
Tokens
Tokens can be used in the webhook’s request body to pass through dynamic information about the user, flow, and the request itself.
Token | Description | Example |
---|---|---|
flow.name | The flow’s name | New user onboarding |
flow.identifier | The flow’s unique identifier | new-user-onboarding |
flow.version | The flow’s version tag | 4 |
user.identifier | The user’s unique identifier | YnT275hlnxG4YvuAxjeg_ |
timestamp | An ISO 8601 timestamp string of when the webhook triggered | 2023-03-07T23:00:40.927Z |
To use a token in the request body, wrap the token name in the template syntax: ${TOKEN}
.
Here’s an example of what a request body with tokens looks like:
{
"date": "${timestamp}",
"message": "A user (${user.identifier}) completed ${flow.name}"
}
Testing
You can test the output of a webhook using the test feature. This will send a request to the specified target URL with your webhook’s configured request headers and body. If you have tokens in the request body, they will be replaced with placeholder values.