Skip to main content

Webhook

Webhook block

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.

Once the webhook is triggered, the flow will automatically transition to the next block(s) drawn from the webhook block.

note

Webhook blocks only support POST requests at this time.

info

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.

caution

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.

TokenDescriptionExample
flow.nameThe flow’s nameNew user onboarding
flow.identifierThe flow’s unique identifiernew-user-onboarding
flow.versionThe flow’s version tag4
user.identifierThe user’s unique identifierYnT275hlnxG4YvuAxjeg_
timestampAn ISO 8601 timestamp string of when the webhook triggered2023-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.