Webchat
Webchat control channels
Types of control channels
Page control event :
- An event sent from the webpage to the stub
- Sent via a customEvent
Server control event:
- A custom payload sent from the stub to the webpage.
- A predefined function will be executed and the custom payload will become its arguments
- The name of this function is specified as a tag
on_server_control_event="handle_server_control_event"
Page_control_hook:
- A function that is executed when the user sends a message.
- The function return will be sent to the stub along with the users message
Handling page control event
- Setup and embed your webchat into a webpage
- In the webpage create a custom event with type "stubber_webchat_page_control_event"
- Now dispatch your event
- The object
details.data
will be present understubpost.data._incoming_webchat_data.webchat_control_event
Handling server control events
- In your webpage define a function in the window
- In the webchat tag specify the name of the function
- In the notification object in your stub add
webchat_control_event
toplatforms.webchat
- The Webchat will execute the function "handle_server_control_event" in the webpage and pass
{"some":"data"}
into the function