Guide
Attachments
Users can attach documents and images to a message. The text of a document is read and given to the agent with the message.
Limits
| Limit | |
|---|---|
| File types | Documents: TXT, MD, CSV, JSON, PDF. Images: PNG, JPEG, GIF, WebP. |
| Size | 20 MB per file |
| Files per message | 10 |
| Text read from a document | Up to 20,000 characters per file and 30,000 per message; the rest is cut and the agent is told it was cut. |
Where attachments work
The agent test chat, the chat widget, and the runtime API and SDKs. They do not work on the phone channel, the OpenAI-compatible endpoint or workflow chat: files sent there are ignored without an error (see Known beta limits).
From code
Upload first, then send the message with the attachment ids:TypeScript Python REST:
import { readFile } from 'node:fs/promises';
import { DezifiClient } from '@dezifi/client';
const client = new DezifiClient({
baseUrl: 'https://api.dezifi.ai',
apiKey: process.env.DEZIFI_SECRET_KEY,
workspaceId: Number(process.env.DEZIFI_WORKSPACE_ID),
});
const asUser = client.onBehalfOf({ endUserId: 'user-123', customerGroupId: 'northwind' });
const file = await asUser.uploadAttachment(await readFile('contract.pdf'), 'contract.pdf', 'application/pdf');
const session = await asUser.agent(process.env.DEZIFI_AGENT_ID ?? '').startSession();
const reply = await session.send('Summarise the termination clause.', { attachmentIds: [file.id] });
console.log(reply.response);from pathlib import Path
as_user = client.on_behalf_of("user-123", "northwind")
file = as_user.upload_attachment(Path("contract.pdf").read_bytes(), "contract.pdf", "application/pdf")
session = as_user.agent(AGENT_ID).start_session()
reply = session.send("Summarise the termination clause.", attachment_ids=[file.id])
print(reply.response)POST /api/v1/runtime/agents/chat/attachments (multipart field file), then attachmentIds in the /execute body.Errors your users may see
- A file type that is not listed is refused with the list of accepted types.
- A file over 20 MB is refused (HTTP 413). More than 10 files in a message is refused (HTTP 400).
- A PDF with no selectable text (a scan) is refused with a message asking for a text PDF or pasted text.
- A damaged or password-protected file is refused as unreadable.