This workflow follows the Agent → Ollama 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 →
{
"name": "IDS AI - Chat with PDF Support",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "ids-ai-chat",
"responseMode": "responseNode",
"options": {
"allowedOrigins": "*"
}
},
"id": "webhook-trigger",
"name": "Webhook Trigger",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
220,
300
]
},
{
"parameters": {
"jsCode": "// Extract data from request\nconst body = $input.first().json.body || $input.first().json;\nconst message = body.message || '';\nconst context = body.context || '';\nconst conversationId = body.conversationId || 'default';\n\n// Check for exercise patterns in message\nconst exercisePatterns = [\n /solve\\s+this/i, /answer\\s+these/i, /complete\\s+the/i,\n /\\d+\\s*points?/i, /\\d+\\s*marks?/i,\n /exercise\\s*\\d/i, /problem\\s*\\d/i, /question\\s*\\d/i,\n /homework/i, /assignment/i, /quiz/i, /exam/i\n];\n\nlet isExercise = false;\nfor (const pattern of exercisePatterns) {\n if (pattern.test(message) || pattern.test(context)) {\n isExercise = true;\n break;\n }\n}\n\n// Prepare the prompt for AI\nlet fullPrompt = message;\nif (context && context.trim().length > 0) {\n fullPrompt = `DOCUMENT CONTENT:\\n${context.substring(0, 15000)}\\n\\n---\\n\\nUSER QUESTION: ${message}`;\n}\n\nreturn [{\n json: {\n message,\n context,\n fullPrompt,\n conversationId,\n isExercise\n }\n}];"
},
"id": "exercise-filter",
"name": "Process Message",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
440,
300
]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.isExercise }}",
"value2": true
}
]
}
},
"id": "if-exercise",
"name": "Is Exercise?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
660,
300
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ JSON.stringify({ response: \"I'm sorry, but I cannot help with exercises, homework, quizzes, or exams. I'm here to help you understand concepts and learn. Would you like me to explain any concepts instead?\", conversationId: $json.conversationId, isBlocked: true }) }}",
"options": {
"responseHeaders": {
"entries": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
}
},
"id": "reject-exercise",
"name": "Reject Exercise",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
880,
180
]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.fullPrompt }}",
"options": {
"systemMessage": "You are IDS AI, an intelligent educational assistant. Help students understand concepts, summarize documents, and explain academic topics. NEVER help with exercises, homework, quizzes, or exams - politely decline those requests."
}
},
"id": "ai-agent",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.6,
"position": [
880,
420
]
},
{
"parameters": {
"model": "llama3.2:latest",
"options": {}
},
"id": "ollama-chat",
"name": "Ollama Chat",
"type": "@n8n/n8n-nodes-langchain.lmChatOllama",
"typeVersion": 1,
"position": [
780,
620
]
},
{
"parameters": {
"respondWith": "allIncomingItems",
"options": {
"responseHeaders": {
"entries": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
}
},
"id": "send-response",
"name": "Send Response",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1100,
420
]
}
],
"connections": {
"Webhook Trigger": {
"main": [
[
{
"node": "Process Message",
"type": "main",
"index": 0
}
]
]
},
"Process Message": {
"main": [
[
{
"node": "Is Exercise?",
"type": "main",
"index": 0
}
]
]
},
"Is Exercise?": {
"main": [
[
{
"node": "Reject Exercise",
"type": "main",
"index": 0
}
],
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Send Response",
"type": "main",
"index": 0
}
]
]
},
"Ollama Chat": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
IDS AI - Chat with PDF Support. Uses agent, lmChatOllama. Webhook trigger; 7 nodes.
Source: https://github.com/yasxai/aimazigh-ai/blob/3665e9f4a45a7441eb5b3d903deece3b1c87026c/n8n-workflows/chat-workflow-v2.json — 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.
This workflow is designed for organizations or services managing appointments, such as interview scheduling, class enrollments, or client meetings. It’s ideal for users who want to automate appointmen
This workflow implements a privacy-preserving AI document processing pipeline that detects, masks, and securely manages Personally Identifiable Information (PII) before any AI processing occurs.
This automated n8n workflow enables an AI-powered movie recommendation system on WhatsApp. Users send messages like "I want to watch a horror movie" or "Where can I watch the Jumanji movie?" The workf
This n8n workflow enables an AI-powered symptom checker where users input symptoms via a form or chat, analyzes them using an AI model, matches possible conditions, and suggests relevant doctors with
W_ADMIN_AGENT - Autonomous AI Admin Assistant. Uses httpRequest, agent, lmChatOllama, memoryBufferWindow. Webhook trigger; 11 nodes.