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;
}filenamestringoptionalOriginal filename, e.g. invoice.pdf.
contentTypestringoptionalMIME type, e.g. application/pdf.
urlstringoptionalOptional 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}`);
}