Prerequisites
- A Moda API key enabled for Canvas Embed SDK
- A canvas ID, for example
cvs_01HT9WK8N3M2J4A5Z6P7Q8R9TV - The exact origin of the page that will host the iframe, for example
https://app.example.com
1. Create a session on your backend
server/create-moda-embed-session.ts
2. Return only the embed URL to your frontend
app/api/moda-embed/route.ts
3. Load the iframe
ModaCanvasEmbed.tsx
4. Listen for results
At minimum, handle these events:Common first configuration
Create session body
chat: "external" when you want your application to own the chat UI and send chat.send, chat.stop, and chat.newThread commands itself.
For the full session contract, see Session API.