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.
Open a direct conversation
Section titled “Open a direct conversation”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.
const { conversationId, created } = await client.ensureDirectConversation(identityId);// POST /agent/chat/conversations/directThe result also includes identityId, tenantId, userId, and displayName. Get an
identityId from Identity.
Upload attachments
Section titled “Upload attachments”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.
Related resources
Section titled “Related resources”- Identity — find the person to message.
- Phone and messaging — send by SMS or WhatsApp instead.