Open in Hubv1.1.1 Install this integration to generate a personalized webhook that allows your bot to receive external updates.

Setup

You will need:

Install the integration

  1. In Botpress Studio, select Explore Hub in the upper-right corner.
  2. Search for the Webhook integration, then select Install Integration.
  3. Copy the generated webhook URL.

Configure the integration

The integration has the following configuration options:
  • Secret (Optional): A secret that must be sent with the request as a header called x-bp-secret. Leave empty to allow all requests without a secret.
  • Allowed Origins: List of allowed origins for CORS. Leaving this field empty blocks all requests originating from a browser and only allows requests from a server.

Send data to your webhook

You can make requests to your webhook from any environment that supports HTTP requests:
import axios from 'axios'

const webhookUrl = 'https://webhook.botpress.cloud/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
const data = {
  "example": "example"
}
const headers = {
  'Content-Type': 'application/json',
  'x-bp-secret': 'your-secret' // Optional
}
await axios.post(webhookUrl, data, { headers })
Webhooks don’t return any data in the response body.

Use webhook data in Studio

You can test the webhook in the Studio’s emulator to make sure you’re handling requests properly.
To read data from a webhook request in the Studio:
  1. In Botpress Studio, add the Webhook Event Trigger to the Workflow you want to use the request’s data in.
  2. Connect any Nodes you want to the Trigger—they’ll execute whenever the webhook receives an request.
  3. Now, you can read the event’s payload to access information about the webhook request:

Read the payload

Here’s the structure of a webhook event’s payload:
event.payload
object
Information about the webhook request.
The contents of event.payload are overwritten as soon as the bot or the user sends a new message. If you need to access a webhook request’s data later, consider storing it in a variable.

Payload size limit

The maximum size for a Webhook payload is .