This workflow corresponds to n8n.io template #7796 — we link there as the canonical source.
This workflow follows the Agent → OpenAI Chat recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "9ba14748-4bba-47d3-99d1-b9c4107f8a3a",
"name": "Loop Over Items1",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-416,
4128
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "d3a0b91a-00c7-4a6e-96a7-b82de25ed5fe",
"name": "When clicking \u2018Execute workflow\u2019",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-1312,
4000
],
"parameters": {},
"typeVersion": 1
},
{
"id": "f8ec514b-b64c-4bd5-bc86-91b24435cbf0",
"name": "Get Messages from Outlook",
"type": "n8n-nodes-base.microsoftOutlook",
"position": [
-912,
4384
],
"parameters": {
"limit": 5,
"options": {},
"operation": "getAll"
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 2
},
{
"id": "e072f4a2-0f5a-44ed-8e78-6f779f70a28b",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-256,
4528
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "4670e0fa-82e2-483f-9891-83bc4f04f8be",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
64,
4368
],
"parameters": {
"jsonSchemaExample": "{\n\t\"category\": \"Red Category, Yellow Category, or Green Category\"\n}"
},
"typeVersion": 1.3
},
{
"id": "3e2d22a2-c1ba-48f7-bdff-855b1106365a",
"name": "Set Fields from Email",
"type": "n8n-nodes-base.set",
"position": [
-592,
3984
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "83f69529-de2b-4d4e-aac9-cd88e4336c94",
"name": "subject",
"type": "string",
"value": "={{ $json.subject }}"
},
{
"id": "af0befe4-5252-4fe4-9c0a-06e207e4c9a9",
"name": "bodyPreview",
"type": "string",
"value": "={{ $json.bodyPreview }}"
},
{
"id": "074a3879-8b0c-4601-a1d0-3284b69fbde2",
"name": "from",
"type": "string",
"value": "={{ $json.from }}"
},
{
"id": "02c201fc-996e-4777-b50e-10290da09262",
"name": "Message ID",
"type": "string",
"value": "={{ $json.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "3fd00d0a-fed9-4a36-9146-a826ebcdd633",
"name": "Categorizing Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-112,
4112
],
"parameters": {
"text": "=body: {{ $json.bodyPreview }} subject: {{ $json.subject }}",
"options": {
"systemMessage": "You are a helpful assistant. take in the email message and determine if it is Red Category, Yellow Category, or Green Category. based on random\n\noutput data like this. \n\n{\n\t\"category\": \"Red Category, Yellow Category, or Green Category\"\n}\n\n"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "4a794da0-4294-4017-b7c7-59910e8f18d4",
"name": "Set Category and ID",
"type": "n8n-nodes-base.set",
"position": [
-112,
3920
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "85cc4512-3af8-400a-8814-2bdb75739321",
"name": "output.category",
"type": "string",
"value": "={{ $json.output.category }}"
},
{
"id": "d3fdc30b-9322-472c-b0ca-decb9cdd29bb",
"name": "id",
"type": "string",
"value": "={{ $('Get Messages from Outlook').item.json.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "27d99566-af49-42f3-808f-cafe530f6217",
"name": "Update Category",
"type": "n8n-nodes-base.microsoftOutlook",
"position": [
144,
3904
],
"parameters": {
"messageId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"operation": "update",
"updateFields": {
"categories": "={{ [$json.output.category] }}"
}
},
"credentials": {
"microsoftOutlookOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 2
},
{
"id": "f25951d2-935a-4b7b-b00b-53f08a82513a",
"name": "Sticky Note54",
"type": "n8n-nodes-base.stickyNote",
"position": [
-368,
4336
],
"parameters": {
"color": 3,
"width": 288,
"height": 304,
"content": "### 2\ufe0f\u20e3 Set Up OpenAI Connection\n1. Go to [OpenAI Platform](https://platform.openai.com/api-keys) \n2. Navigate to [OpenAI Billing](https://platform.openai.com/settings/organization/billing/overview) \n3. Add funds to your billing account \n4. Copy your API key into the **OpenAI credentials** in n8n "
},
"typeVersion": 1
},
{
"id": "4fb6ac63-881f-4740-8abc-404ac65d093a",
"name": "Sticky Note24",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1008,
4160
],
"parameters": {
"color": 3,
"width": 288,
"height": 336,
"content": "### 2\ufe0f\u20e3 Set Up Outlook Connection\n1. In n8n \u2192 **Credentials \u2192 New \u2192 Microsoft Outlook OAuth2 API** \n2. Log in with your Outlook account & approve access \n3. Attach this credential to the **Search Outlook** node in the workflow \n4. (Optional) Change the `limit` parameter in the node if you want more/less than 5 results "
},
"typeVersion": 1
},
{
"id": "c4449b1f-301c-4a6a-b7d8-56d65f20911c",
"name": "Sticky Note21",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1888,
3792
],
"parameters": {
"width": 400,
"height": 928,
"content": "\n## \u2699\ufe0f Setup Instructions\n\n### 1\ufe0f\u20e3 Set Up Outlook Connection\n1. In n8n \u2192 **Credentials \u2192 New \u2192 Microsoft Outlook OAuth2 API** \n2. Log in with your Outlook account & approve access \n3. Attach this credential to the **Get Messages from Outlook** and **Update Category** nodes in the workflow \n4. (Optional) Adjust the **limit** field in **Get Messages from Outlook** if you want more/less than 5 results \n\n---\n\n### 2\ufe0f\u20e3 Set Up OpenAI Connection\n1. Go to the **[OpenAI Platform](https://platform.openai.com/api-keys)** \n2. Navigate to **[OpenAI Billing](https://platform.openai.com/settings/organization/billing/overview)** \n3. Add funds to your billing account \n4. Copy your API key into the **OpenAI** credentials in n8n and select it on the **OpenAI Chat Model** and **Categorizing Agent** nodes \n\n\n- \ud83d\udce7 **robert@ynteractive.com** \n- \ud83d\udd17 **[Robert Breen](https://www.linkedin.com/in/robert-breen-29429625/)** \n- \ud83c\udf10 **[ynteractive.com](https://ynteractive.com)**\n"
},
"typeVersion": 1
},
{
"id": "1f45d710-c178-48de-baf3-6da87661b64e",
"name": "Sticky Note22",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1456,
3792
],
"parameters": {
"color": 7,
"width": 1936,
"height": 928,
"content": "# \ud83d\udce7 Auto-Categorize Outlook Emails with OpenAI (n8n)\n\nThis workflow fetches recent emails from Outlook and uses OpenAI to assign a category (e.g., **Red**, **Yellow**, **Green**). It then updates each message\u2019s category in Outlook.\n\n"
},
"typeVersion": 1
}
],
"connections": {
"Loop Over Items1": {
"main": [
[
{
"node": "Set Category and ID",
"type": "main",
"index": 0
}
],
[
{
"node": "Categorizing Agent",
"type": "main",
"index": 0
}
]
]
},
"Categorizing Agent": {
"main": [
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Categorizing Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Set Category and ID": {
"main": [
[
{
"node": "Update Category",
"type": "main",
"index": 0
}
]
]
},
"Set Fields from Email": {
"main": [
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Categorizing Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Get Messages from Outlook": {
"main": [
[
{
"node": "Set Fields from Email",
"type": "main",
"index": 0
}
]
]
},
"When clicking \u2018Execute workflow\u2019": {
"main": [
[
{
"node": "Get Messages from Outlook",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
microsoftOutlookOAuth2ApiopenAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow fetches recent emails from Outlook and uses OpenAI to assign a category (e.g., Red, Yellow, Green). It then updates each message’s category in Outlook. In n8n → Credentials → New → Microsoft Outlook OAuth2 API Log in with your Outlook account & approve access…
Source: https://n8n.io/workflows/7796/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Microsoft Outlook AI Email Assistant. Uses manualTrigger, stickyNote, microsoftOutlook, lmChatOpenAi. Event-driven trigger; 28 nodes.
Provide your Office 365 credentials to connect Outlook. Generate an API token and have a board with your contact details. Obtain an API key (or personal access token) and set up a base to store: Conta
Automatically analyze the sentiment of Facebook posts and their audience comments using GPT-4 to identify trends and potential PR risks. 🧠💬 This workflow fetches recent posts via the Facebook Graph AP
This n8n workflow reads emails from your Outlook inbox, drafts AI-powered replies using OpenAI, and routes them through the gotoHuman node for human approval before replying automatically. Reads Outlo
This powerful n8n workflow helps you automatically re-engage cold leads by summarizing their past emails and generating personalized outreach with OpenAI. It pulls in contacts from Google Sheets, fetc