Send custom events and messages from your web app to webchat
With the webchat initialized on your web application, you can send custom events to your bot and programmatically send messages on behalf of the user.
Sending Custom Events to Your Bot
You can send custom events to your bot by calling the following code, where customPayload
is a JSON object:
await window.botpress.sendEvent(customPayload)
These events can be captured using the “Custom Trigger” card in Botpress Studio, and the payload can be accessed via event.payload
.
Sending Messages from Your Web Application
To send messages directly to your bot from your web application, use the following method:
await window.botpress.sendMessage('custom message')
Updated about 1 month ago