Chat SDK

Chat SDK Attachments

Handle inbound email attachments in a conversational-email integration built on MailBlastr webhooks and the SDK.

When someone sends an email with file attachments, the inbound message you fetch via Receiving exposes them as a list. Each attachment includes the filename, MIME type, and a way to download the content. In a Chat SDK adapter (see Chat SDK) you surface these on the message you hand to your handler.

Attachment shape

The shape below is what a custom adapter typically exposes; it mirrors the attachment metadata returned by the Receiving attachments API.

interface InboundAttachment {
  filename: string;
  contentType: string;
  url?: string;
}
filenamestringoptional

Original filename, e.g. invoice.pdf.

contentTypestringoptional

MIME type, e.g. application/pdf.

urlstringoptional

Optional download URL for the attachment content.

Detecting and processing attachments

Read the attachment list off the inbound message (fetched with mb.emails.receiving.get in your webhook handler) and reply with the SDK.

async function onInbound(email) {
  const attachments = email.attachments ?? [];

  if (attachments.length === 0) {
    await reply(email.from, `Re: ${email.subject}`, 'Got your email — no attachments found.');
    return;
  }

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

  await reply(email.from, `Re: ${email.subject}`, `Received ${attachments.length} attachment(s): ${summary}`);
}
For the full inbound-attachment API — fetching content, size limits, and MIME handling — see Receiving attachments.