Files and multimodal input
Pass managed Slack and Teams attachments to multimodal agents and post supported files back to the conversation.
Managed Channels can hydrate provider attachments into
message.contentParts. The SDK carries text, images, audio, video, and PDF
documents in one provider-neutral prompt shape.
Pass attachments to the agent#
Managed conversation history does not contain the current inbound turn.
runAgent() automatically chooses the inbound text or attachment parts when
prompt is omitted. Build a combined prompt when the same turn can contain
both message.text and message.contentParts:
channel.onMessage(async ({ thread, message }) => {
const prompt = message.contentParts?.length
? [
...(message.text
? [{ type: "text" as const, text: message.text }]
: []),
...message.contentParts,
]
: message.text;
await thread.runAgent({ prompt });
});If you pass only message.text, the model will not receive hydrated binary
attachments. If contentParts exists, do not append it to managed history
yourself; runAgent adds the explicit prompt for this turn.
Understand the content mapping#
| Provider file | AgentContentPart |
|---|---|
| Image MIME type | { type: "image", source: { type: "data", value, mimeType } } |
| Audio MIME type | { type: "audio", source: ... } |
| Video MIME type | { type: "video", source: ... } |
{ type: "document", source: ... } | |
text/* | UTF-8 { type: "text", text } |
| Other binary type | A text note naming the attachment and MIME type |
The binary value is base64. Whether the agent actually understands a media
part depends on its selected model and framework. Choose a multimodal model and
test the exact media types you accept.
File retrieval is best-effort. A provider-ingest failure can omit the attachment before the SDK receives a file handle. If Intelligence delivers a handle but the SDK cannot hydrate it, the SDK inserts a short failure note instead of failing the whole turn.
Managed file-size ceiling
Intelligence currently accepts individual inbound and outbound Channel files up to 25 MiB. Provider limits can be lower.
Slack file access#
Intelligence downloads files using the managed Slack bot token. The app must be
in the conversation and have permission to read the file. Slack documents
files:read as the scope that
allows an app to download files from conversations it can access.
The current Intelligence-generated manifest requests both files:read and
files:write. If the app predates that manifest:
- Open the Channel in Intelligence, return to its Slack setup instructions, and apply the generated manifest so both bot token scopes are present. See Configure the Channel in Intelligence.
- Reinstall the app so the workspace grants the scopes.
- Copy the current Bot User OAuth token into Intelligence if Slack reissued it.
- Invite the app to the source conversation.
- Send a new file and verify the model receives it.
If attachments are omitted or arrive as retrieval-failure notes:
- Confirm the reinstalled bot token includes
files:read. - Confirm the app is a member of the source conversation.
- Send a new file and inspect the real agent turn.
Teams file access#
Post a file#
thread.postFile() takes bytes and returns a result instead of throwing for an
unsupported provider capability:
const csv = new TextEncoder().encode(
["id,status", "INC-421,investigating"].join("\n"),
);
const result = await thread.postFile({
bytes: csv,
filename: "incident-report.csv",
title: "Incident report",
altText: "CSV export of the incident report",
});
if (!result.ok) {
await thread.post(`The report could not be attached: ${result.error}`);
}On managed Channels, result.ok means Intelligence stored the managed asset,
the provider acknowledged the file or image effect, and the SDK recorded the
asset in canonical Thread history.
Managed Slack uses Slack's external-upload flow and can send general file types.
The generated manifest includes the files:write bot scope. Apply the current
manifest and reinstall if the Slack app predates it. Check result.ok, then
verify the real Slack message when provider-side display matters.
Treat attachments as untrusted input#
- Validate declared MIME type and file signature before application-side processing.
- Put limits on decompression, parsing, page count, and extracted text.
- Do not execute macros or uploaded code.
- Resolve the provider user to an authenticated application identity before a file can trigger a consequential write.
- Avoid logging base64 content, signed download URLs, or document text.
See the IncomingMessage
reference and
AgentContentPart reference for
the exact public shapes.