Skip to main content

Widget Actions

Actions allow widget components to trigger dynamic behaviors like sending messages, showing notifications, or making network requests.

Action Format

Actions are objects with a type and optional payload:

Standard Action Types

lyzn.sendMessage

Send collected form data as a chat message.
Payload:

lyzn.showToast

Display a toast notification to the user.
Payload:
Open a URL in webview or external browser.
Payload:

lyzn.resetState

Reset the widget’s form state.
Payload:

lyzn.fetch

Make a network request.
Payload:

Using Actions

On Buttons

Use onClickAction or action prop:

On Form Components

Form components like Select, RadioGroup, and Checkbox support the action prop to trigger actions on value change:

On Cards

Use confirm and cancel props to add action buttons:

Form State Management

When a form component has a name prop, it updates the widget’s form state instead of sending a message immediately:
The form data is collected as:

Value Placeholders

Use {{value}} in action payloads to inject the current value:

Complete Example

When user clicks “Generate Post”, this sends: