Attachments
Show an attach button only when file uploads are enabled for your chat, that is whenstate.config.features includes "file-upload".
Send files
1
Upload the files
Pass
File or Blob objects, such as the files from an
<input type="file">, or { name, type, data }:onProgress reports bytes as they’re sent in browsers and React Native. In
other runtimes it fires only when each file completes.2
Handle failed files
You get one result per file, so one failed file doesn’t fail the others:
3
Send the message
Pass the uploaded attachments with the message. The text can be empty:
Show received files
Each message has anattachments array of { name, path, type, size }. Get a
short-lived download URL when the visitor opens one:
Satisfaction surveys
When a message haskind: "csat_request", show a rating prompt. Load its text,
then submit a rating from 1 to 5 and an optional comment:
lastRating and lastComment hold a previous answer, so you can show it
instead of asking again.
Email verification
When the AI Agent needs to confirm who the visitor is, it sends a message withkind: "email_verification_requested". Show a form that asks for an email, then
for the code sent to it:
1
Send the code
2
Check the code
success is false, reason is invalid_code, max_attempts, or
expired.3
Confirm
A message with
kind: "email_verification_verified" arrives, and the
conversation continues.chat.verification.getStatus():
string
none, awaiting_email, awaiting_code, or verified. Show the email field
for awaiting_email and the code field for awaiting_code.string
The email the code was sent to.
number
How many more codes the visitor can try.
Voice input
Whenstate.config.features includes "transcription", you can offer
speech-to-text. chat.getTranscriptionKey() returns a short-lived ElevenLabs
key to use with the ElevenLabs speech-to-text client. If you use a CSP, allow
wss://api.elevenlabs.io in connect-src.
Related
- Render messages and activity
- API reference
- Insights Hub: where satisfaction ratings show up