Skip to content

Chat

These methods help an agent reach a person and send them a file. For how conversations work, see Chat overview.

All examples use the @alfe.ai/agent-api-client.

Give an identity and get back that person’s direct conversation with the agent. Alfe creates the conversation if it doesn’t exist yet. The identity must be a current member of your organization.

chat.ts
const { conversationId, created } = await client.ensureDirectConversation(identityId);
// POST /agent/chat/conversations/direct

The result also includes identityId, tenantId, userId, and displayName. Get an identityId from Identity.

Ask for upload URLs, then upload each file with the headers you got back. You can request up to 10 files at once, each up to 25 MB.

const { attachments } = await client.presignAttachments([
{ filename: "report.pdf", mimeType: "application/pdf", size: bytes.byteLength },
]);
// POST /agent/chat/attachments/presign
await fetch(attachments[0].uploadUrl, {
method: "PUT",
body: bytes,
headers: attachments[0].uploadHeaders,
});

Each entry also has an id, a downloadUrl for reading the file back, and expiresAt.