Code Examples
Snippets you can copy straight into your project.
Open the widget from a button
<button onClick={() => SupportFlow.open()}>
Need help?
</button>Pre-fill a message
SupportFlow.open({
message: "I have a billing question about invoice #4021",
});Create a ticket from your backend
await fetch("https://api.supportflow.ai/v1/tickets", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SF_SECRET}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ subject: "Sync failed", priority: "high" }),
});Listen for resolution
SupportFlow.on("ticket:resolved", (e) => {
analytics.track("support_resolved", { id: e.ticket_id });
});