Skip to main content
When someone sends an email with file attachments, the adapter makes them available on message.raw.attachments. Each attachment includes the filename, MIME type, and a URL to download the content.

Attachment shape

interface ResendAttachment {
  filename: string;
  contentType: string;
  url?: string;
}
FieldTypeDescription
filenamestringOriginal filename (e.g., invoice.pdf)
contentTypestringMIME type (e.g., application/pdf)
urlstringOptional download URL for the attachment content

Detecting and processing attachments

chat.onNewMention(async (thread, message) => {
  const attachments = message.raw?.attachments ?? [];

  if (attachments.length === 0) {
    await thread.subscribe();
    await thread.post('Got your email — no attachments found.');
    return;
  }

  const summary = attachments
    .map((a) => `${a.filename} (${a.contentType})`)
    .join(', ');

  await thread.subscribe();
  await thread.post(`Received ${attachments.length} attachment(s): ${summary}`);
});
For more on receiving email attachments outside the Chat SDK, see Receiving Attachments.

Try it yourself

Attachments Example

Detects attachments and replies with a summary