Messages, including commands and variables, can be sent to the backend when the widget is activated.
The following widget API functions are used in the example below:
Example 1: Pre-send messages when the widget is opened
On this page, when the widget is opened:
This is implemented as the following code:
Example 2: Process a form when the widget is opened
Messages sent from the widget support non-chat message types like forms, fields and commands. You can use sendClientMessage to fill in form fields and use the /send command to process the form into a result.
This can be implemented with the following code:
See the widget API documentation for more details.