TypeScript SDK: Mail: inbound mail
ctx.mail() is available for an inbound-mail scenario. Read message content and attachments only for the authorized run; do not write their contents to logs.
Each example is a separate fragment inside async function run(ctx: Akmelo.Context): Promise<void>. Use await only for methods whose signature returns a Promise.
Methods
available
ctx.mail().available() → Promise<boolean>
Whether this run has a verified message. Returns false for manual and trial runs.
const result = await ctx.mail().available();
current
ctx.mail().current() → Promise<object>
The current message's subject, sender, text, attachments, and retention period. Internal headers and other recipients are not exposed. Text is limited to 1 MiB; text_truncated tells you when it was shortened.
const result = await ctx.mail().current();
text
ctx.mail().text() → Promise<string>
Get the plain text of the message without HTML.
const result = await ctx.mail().text();
attachments
ctx.mail().attachments() → Promise<Array<object>>
The verified attachments, with id, name, mime, and size. Download links require access to the current workspace.
const result = await ctx.mail().attachments();
document
ctx.mail().document(id) → Promise<Document>
Extract text, Excel sheets, Word tables, or PDF pages from an attachment belonging to this message. Links in the document are not opened automatically. No more than eight documents can be parsed per run.
const result = await ctx.mail().document('attachment-id');
attachment
ctx.mail().attachment(id) → Promise<string>
Reads an attachment as text in chunks and returns a string. Use document(id) for Excel, PDF, or Word to preserve structure.
const result = await ctx.mail().attachment('attachment-id');