🔬 Analyze Mattermost attachments with OpenAI vision for AI agents
⚡ 16 views · 🔬 Document Extraction & Analysis
Description
Overview
Subworkflow for analyzing Mattermost attachments.
Per-attachment behavior
- Image (mime starts with
image/, size ≤MAX_IMAGE_SIZE_BYTES): downloaded and analyzed by OpenAI vision model. - Text small (text-like by mime/extension, size ≤
MAX_TEXT_SIZE_BYTES): downloaded as plain text and inlined into the context block (with line count check ≤MAX_TEXT_LINES). - Text too large (text-like, exceeds byte or line limit): replaced with a “too big” marker so the agent asks the user for the relevant excerpt.
- Other (binaries, oversized images, unknown): replaced with a generic “not analyzed” marker.
Setup checklist
- Set
MATTERMOST_BASE_URLin the Config node. - Create an
HTTP Header Authcredential called “Mattermost PAT” with:- Name:
Authorization - Value:
Bearer <your_personal_access_token>
- Name:
- Attach this credential to all three HTTP Request nodes (Get file info, Download file, Download text file).
- Attach your OpenAI credential to the “OpenAI: Analyze Image” node.
- Tune in Config:
VISION_MODEL,MAX_IMAGE_SIZE_BYTES,MAX_TEXT_SIZE_BYTES,MAX_TEXT_LINES.
Notes
- The IF guard short-circuits when
file_idsis empty so the parent workflow can call this subworkflow unconditionally. - Classification by mime + extension catches
.logfiles served asapplication/octet-stream. - Final output is always a single item with the same shape — safe to consume in the parent.
đź”— Nodes Used
HTTP Request, Execute Workflow Trigger, OpenAI
📥 Import
Download workflow.json and import into n8n:
Workflow menu → Import from File