Webhooks

Bento webhooks provide granular data on user actions related to Bento guides.

Meera Kanani avatar
Written by Meera Kanani
Updated over a week ago

Events supported by Webhooks

The Webhooks API allows Bento to notify external services of guide activity using JSON payloads sent with HTTP POST requests.

Using these payloads, you can execute actions accordingly on your own backend systems, or connect other services.

The follow events will trigger a webhook:

  • Guide first viewed (guideViewed)

  • Step first viewed (stepViewed)

  • Guide completed (guideCompleted)

  • Step completed (stepCompleted)

  • Branching choices (branchingChoices)

  • Answers to input questions (inputAnswers)

The name in parenthesis is the value for “eventType” when parsing the request payload.

Create an endpoint that can receive Webhooks

To listen to bento events on your backend service, create an endpoint that can accept POST requests. For example, using node.js and express:

router.post(
'/bento-webhook',
async (req: Request, res: Response, _next: NextFunction) => {
const body = req.body;
const parsed = parseJsonSafely(body);

logger.info(
`[bento-webhook] Got a webhook payload ${JSON.stringify(parsed, null, 2)}`
);

return res.status(200).end();
}
);

The endpoint should quickly return a 2xx status code, or Bento will consider the request as failing.

Failed requests will retry 10 times with an exponential backoff, but once it fails permanently, the integration will be disabled.

For added security, also configure a secret key that can be checked in this endpoint. This will help the backend service verify who the sender is, and as such, is highly recommended. The secret key will be included in the request header as 'Secret-Key'.

To enable webhook integrations, click “Connect” in the webhook integration block on the integration page and configure the destination address (from the prior step).

  • Ensure the integration is toggled on

Testing & payload

Once the information is entered, you can click “Send test event” and Bento will ping the endpoint with a small test payload. Click save to confirm the integration.

✨ Your endpoint should begin to receive payloads when events trigger.

Example payload from a webhook event:

{ 
eventType: 'stepCompleted',
accountId: 'test',
accountName: 'test',
userId: '634f1cbb867f15000e02d4db',
userEmail: 'test@test.com',
data: {
stepEntityId: 'adc2f9f1-9374-4b27-b225-d227631c30ae',
stepName: 'Test',
guideEntityId: '0178ded3-2a88-4f2d-b3f8-2129f0286a8b',
guideName: 'Set up'
},
timestamp: '2022-10-18T21:59:26.503Z',
eventId: '2612b526-f431-4e12-99a7-78fff883af58'
}

Note: By default, we don't send webhooks for internal accounts (e.g., users using your companies domain in their email). For testing, use a personal email or reach out and we can change that setting for you.

Did this answer your question?