onBeforeSendMessage
Intercept every outgoing message before it's sent to the bot provider. The most common use case is to inject contextual metadata — the active category, the current route, feature flags — into the payload.
Select Context
Choose a category to inject into every outgoing message.
Send via ref
Payload Logs
Send a message to see the injected payload.
Loading chatbot...
Code Example
const [category, setCategory] = useState<Category | null>(null);
<Chatbot
onBeforeSendMessage={(params) => ({
...params,
payload: {
categoryId: category?.id,
categoryName: category?.name,
injectedAt: new Date().toISOString(),
},
})}
{...rest}
/>;