onRichContentCallback property
Callback for custom actions from rich content components.
This callback is triggered when a user interacts with a "callback" type action in rich content (like clicking "Add to Cart" on a product card).
The callback receives:
callbackId: A string identifier for the action (e.g., "add_to_cart")payload: Optional data associated with the action (e.g., {"productId": "123"})
Example:
ChatWidget(
configuration: config,
onRichContentCallback: (callbackId, payload) {
if (callbackId == 'add_to_cart') {
final productId = payload?['productId'];
cartService.addProduct(productId);
}
},
)
Implementation
final OnCustomCallback? onRichContentCallback;