open
Thewindow.botpress.open
method opens the Webchat window:
Parameters
Theopen
method takes no parameters.
Returns
void
close
Thewindow.botpress.close
method closes the Webchat window:
Parameters
Theclose
method takes no parameters.
Returns
void
toggle
Thewindow.botpress.toggle
method toggles the Webchat window open/closed depending on its current state:
Parameters
Thetoggle
method takes no parameters.
Returns
void
updateUser
The asynchronouswindow.botpress.updateUser
method updates the data associated with the current Webchat user:
Parameters
The user attributes to update.
By default, the These are generated by the server and can’t be updated or deleted.
user
object contains the following properties:Returns
Promise<void>
A Promise that resolves
void
when the user data has been successfully updated.getUser
The asynchronouswindow.botpress.getUser
method gets the data associated with the current Webchat user:
Parameters
ThegetUser
method takes no parameters.
Returns
Promise<User>
A Promise that resolves when the user information has been retrieved.
config
Thewindow.botpress.config
method updates Webchat’s configuration and the current user’s data.
Parameters
object
required
An object containing the Webchat configuration and user data to update.
Returns
void
restartConversation
The asynchronouswindow.botpress.restartConversation
method ends the current conversation and starts a new one:
Parameters
TherestartConversation
method takes no parameters.
Returns
Promise<void>
A Promise that resolves to
void
when a new conversation has been successfully created.sendMessage
The asynchronouswindow.botpress.sendMessage
method sends a new message to your bot on behalf of the current user:
Parameters
The message to send to the bot.
Returns
Promise<void>
A Promise that resolves to
void
when the message has successfully been sent.sendEvent
The asynchronouswindow.botpress.sendEvent
method sends a new event to your bot:
Parameters
An object containing custom data to send to the bot. Can contain any key-value pairs.
Returns
Promise<void>
A Promise that resolves to
void
when the event has successfully been sent.setUnreadMessageCount
Thewindow.botpress.setUnreadMessageCount
method sets the number of unread messages to display on the Floating Action Button (FAB):
Parameters
The number of unread messages to display on the FAB.
Returns
void
on
Thewindow.botpress.on
method sets up an event listener for a given Webchat event:
Parameters
The event type to listen for. Can be any of the following event types:
Event | Description |
---|---|
conversation | Fires when a new conversation starts |
message | Fires when a message is sent |
error | Fires when an error occurs |
customEvent | Fires for custom events |
webchat:initialized | Fires when Webchat has finished loading and is ready to be opened |
webchat:ready | Fires when Webchat has been opened for the first time and is ready to receive messages |
webchat:opened | Fires when Webchat is opened |
webchat:closed | Fires when Webchat is closed |
* | Fires for any event (receives all events) |
Callback function that gets called when the event occurs. The function receives event data specific to each event type as its parameter.
Returns
function
An unsubscribe function that can be called to remove the event listener.