Workflow: Telegramtrigger Workflow
Integrations: executionData, googleSheets, httpRequest, if, noOp, redis, set, stickyNote, switch, telegram, telegramTrigger

{"meta": {"instanceId": "workflow-7e24124e", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:56.360093", "updatedAt": "2025-09-29T07:07:56.360110", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production"}, "nodes": [{"id": "c537229c-ffdf-4a4b-8cdd-1d88621e58a0", "name": "Telegram Trigger", "type": "n8n-nodes-base.telegramTrigger", "position": [-1060, 2060], "webhookId": "1b9f2217-7c53-4440-b62b-aafcf1e1d45d", "parameters": {"updates": ["message"], "additionalFields": {}}, "credentials": {"telegramApi": {"id": "wJqs1eMdbjilZH1W", "name": "jimleuk_ai_survey_demo_bot"}}, "typeVersion": 1.1, "notes": "This telegramTrigger node performs automated tasks as part of the workflow."}, {"id": "90426896-35d8-4449-8607-70e8485441ed", "name": "Send Next Question", "type": "n8n-nodes-base.telegram", "position": [2560, 1900], "webhookId": "4306c719-0b05-4986-8ea8-8bcda06e0ad1", "parameters": {"text": "={{ $('Get Survey State1').first().json.next_question_idx }}. {{ Object.values($('Get Columns1').first().json)[$('Get Survey State1').first().json.next_question_idx+1] }}", "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}", "additionalFields": {"appendAttribution": false}}, "credentials": {"telegramApi": {"id": "wJqs1eMdbjilZH1W", "name": "jimleuk_ai_survey_demo_bot"}}, "typeVersion": 1.2, "notes": "This telegram node performs automated tasks as part of the workflow."}, {"id": "614b6d06-7bca-4710-aebf-3a2a685ace09", "name": "Send Response", "type": "n8n-nodes-base.telegram", "position": [1540, 2540], "webhookId": "dd1c616f-891c-48d4-8828-e612b13bca63", "parameters": {"text": "={{ $('Interview Agent1').first().json.output }}", "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}", "additionalFields": {"appendAttribution": false}}, "credentials": {"telegramApi": {"id": "wJqs1eMdbjilZH1W", "name": "jimleuk_ai_survey_demo_bot"}}, "typeVersion": 1.2, "notes": "This telegram node performs automated tasks as part of the workflow."}, {"id": "c7f7acc4-c3f7-4fae-98dd-25dca9caae8b", "name": "Has No Record?", "type": "n8n-nodes-base.if", "position": [60, 2260], "parameters": {"options": {}, "conditions": {"options": {"version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict"}, "combinator": "and", "conditions": [{"id": "a9f08592-d870-44a4-a7f9-d70193cf721b", "operator": {"type": "object", "operation": "empty", "singleValue": true}, "leftValue": "={{ $json }}", "rightValue": ""}]}}, "typeVersion": 2.2, "notes": "This if node performs automated tasks as part of the workflow."}, {"id": "207a2647-56eb-419a-8269-9a32edabe43a", "name": "Is Survey Continue?", "type": "n8n-nodes-base.if", "position": [1980, 2060], "parameters": {"options": {}, "conditions": {"options": {"version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict"}, "combinator": "and", "conditions": [{"id": "5685829b-a2b2-42c8-b6bc-22eaa03db1d2", "operator": {"type": "boolean", "operation": "false", "singleValue": true}, "leftValue": "={{ $('Increment Index1').item.json.is_survey_complete }}", "rightValue": ""}]}}, "typeVersion": 2.2, "notes": "This if node performs automated tasks as part of the workflow."}, {"id": "a8e98579-6afa-4d7d-859d-9e635a0a1b0c", "name": "Get State2", "type": "n8n-nodes-base.redis", "position": [-520, 2060], "parameters": {"key": "YOUR_CREDENTIAL_HERE", "options": {}, "operation": "get", "propertyName": "data"}, "credentials": {"redis": {"id": "zU4DA70qSDrZM1El", "name": "Redis account (localhost)"}}, "typeVersion": 1, "notes": "This redis node performs automated tasks as part of the workflow."}, {"id": "8074143c-eab7-4146-937c-16c44ef40333", "name": "Get Columns1", "type": "n8n-nodes-base.googleSheets", "position": [1440, 2060], "parameters": {"options": {"dataLocationOnSheet": {"values": {"firstDataRow": 1, "rangeDefinition": "specifyRange"}}}, "sheetName": {"__rl": true, "mode": "list", "value": "gid=0", "cachedResultUrl": "{{ $env.WEBHOOK_URL }}", "cachedResultName": "Sheet1"}, "documentId": {"__rl": true, "mode": "id", "value": "={{ $('Set Variables1').first().json.gsheetId }}"}}, "credentials": {"googleSheetsOAuth2Api": {"id": "XHvC7jIRR8A2TlUl", "name": "Google Sheets account"}}, "typeVersion": 4.5, "notes": "This googleSheets node performs automated tasks as part of the workflow."}, {"id": "1f75f3fc-7893-444d-8a1e-59ec3d42ea1d", "name": "Set Variables1", "type": "n8n-nodes-base.set", "position": [-880, 2060], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "2140b769-2e90-4828-8022-1b0a9baf6e44", "name": "title", "type": "string", "value": "Product Satisfaction Survey: DJI Mini 2"}, {"id": "fb7110cb-82d3-4c95-81ba-ac97a26fe05e", "name": "gsheetId", "type": "string", "value": "1KMNqWWO36osZx7jF-i1UL53z2GZnCn9fiBjtlGpvWB4"}, {"id": "6d9c4b02-8326-49f4-ac22-24bdec7fdd67", "name": "cacheKey", "type": "string", "value": "=survey_user_{{ $json.sessionId }}"}]}}, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "a0c06eb9-46d6-4888-85b0-e9a31a31337b", "name": "Message Type1", "type": "n8n-nodes-base.switch", "position": [-320, 2060], "parameters": {"rules": {"values": [{"outputKey": "YOUR_CREDENTIAL_HERE", "conditions": {"options": {"version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict"}, "combinator": "and", "conditions": [{"id": "f5fa8b7c-fdda-4c6d-b610-e243d6299598", "operator": {"type": "boolean", "operation": "true", "singleValue": true}, "leftValue": "={{ ['/start','/next', '/reset'].includes($('Telegram Trigger').first().json.message.text) }}", "rightValue": "="}]}, "renameOutput": true}]}, "options": {"fallbackOutput": "extra", "renameFallbackOutput": "is_normal_message"}}, "typeVersion": 3.2, "notes": "This switch node performs automated tasks as part of the workflow."}, {"id": "315585fe-d2e4-4cb1-9d0e-a3e8bc053da3", "name": "Get Command1", "type": "n8n-nodes-base.set", "position": [-120, 1760], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "73335bd3-ce50-46c5-8bcf-f7b8cd992208", "name": "command", "type": "string", "value": "={{ $('Telegram Trigger').first().json.message.text.slice($('Telegram Trigger').first().json.message.entities[0].offset, $('Telegram Trigger').first().json.message.entities[0].length ) }}"}]}}, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "7036d250-0271-4c93-9f60-01b9ccaf8be3", "name": "Bot Actions1", "type": "n8n-nodes-base.switch", "position": [60, 1760], "parameters": {"rules": {"values": [{"outputKey": "YOUR_CREDENTIAL_HERE", "conditions": {"options": {"version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict"}, "combinator": "and", "conditions": [{"id": "6f427c86-090d-429a-bc99-d2dd7753c153", "operator": {"type": "boolean", "operation": "true", "singleValue": true}, "leftValue": "={{ $('Get Command1').first().json.command === '/start' }}", "rightValue": "/start"}]}, "renameOutput": true}, {"outputKey": "YOUR_CREDENTIAL_HERE", "conditions": {"options": {"version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict"}, "combinator": "and", "conditions": [{"id": "bca60df4-278d-4598-afc9-6e8ee61b7ac5", "operator": {"type": "boolean", "operation": "true", "singleValue": true}, "leftValue": "={{ $('Get Command1').first().json.command === '/next' }}", "rightValue": ""}]}, "renameOutput": true}]}, "options": {"fallbackOutput": "extra"}}, "typeVersion": 3.2, "notes": "This switch node performs automated tasks as part of the workflow."}, {"id": "fa755815-29c2-419e-8e36-51102ee88681", "name": "Memory3", "type": "n8n-nodes-base.noOp", "position": [2220, 2060], "parameters": {"sessionKey": "YOUR_CREDENTIAL_HERE", "sessionIdType": "customKey", "contextWindowLength": 10}, "credentials": {"redis": {"id": "zU4DA70qSDrZM1El", "name": "Redis account (localhost)"}}, "typeVersion": 1.4, "notes": "This memoryRedisChat node performs automated tasks as part of the workflow."}, {"id": "a231e026-e5bf-4864-a57b-29d01e32e1a8", "name": "Get Survey State1", "type": "n8n-nodes-base.set", "position": [1620, 2060], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "6836a5aa-2b51-48cc-8d8f-d64a85d8a52f", "name": "title", "type": "string", "value": "={{ Object.values($json)[1] }}"}, {"id": "7b2fdf1b-4f55-4b55-be54-a7b97dd094cb", "name": "num_questions", "type": "number", "value": "={{ Object.keys($json).length - 2 }}"}, {"id": "dc6d5c41-0f35-49c9-b9c9-b6b4f2ceb66c", "name": "next_question_idx", "type": "number", "value": "={{ (Number($('Get State3').first().json.data?.current_question_idx) || 0) + 1 }}"}, {"id": "8b17703f-fbff-40d2-a7bb-d450f2edfea3", "name": "is_survey_complete", "type": "boolean", "value": "={{ ((Number($('Get State3').first().json.data?.current_question_idx) || 0) + 1) >= (Object.keys($json).length - 1) }}"}]}}, "executeOnce": true, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "a3bb744d-c59f-45a9-8b9d-3c291fa8d860", "name": "Reset Agent Memory1", "type": "n8n-nodes-base.noOp", "position": [2240, 1900], "parameters": {"mode": "insert", "messages": {"messageValues": [{"message": "=You are a curious and inquisitive researcher conducting a survey with a user.\n* In this conversation, you are only interested in one of the questions from the survey which you will ask.\n* When asking an open-ended question, converse with the user to dig deeper into their answer and reveal insights into the user's experience. Do not ask other questions which do not try to expand the user's answer to the initial question.\n* If this is closed-ended question, it is okay to receive a static response and move on to the next question.\n* Only the initial question is numbered, following questions or messages should not be numbered or bulletpointed.\n* If the user goes off-topic, doesn't want to answer the question or wants to do something else which is not related to the survey, then ignore what they say/ask and politely repeat the question."}, {"type": "ai", "message": "={{ $('Get Survey State1').first().json.next_question_idx }}. {{ Object.values($('Get Columns1').first().json)[$('Get Survey State1').first().json.next_question_idx+1] }}"}]}, "insertMode": "override"}, "typeVersion": 1.1, "notes": "This memoryManager node performs automated tasks as part of the workflow."}, {"id": "b9d693b7-c139-45d8-b0d8-fd8134c7ba84", "name": "Memory4", "type": "n8n-nodes-base.noOp", "position": [1120, 2700], "parameters": {"sessionKey": "YOUR_CREDENTIAL_HERE", "sessionIdType": "customKey", "contextWindowLength": 100}, "credentials": {"redis": {"id": "zU4DA70qSDrZM1El", "name": "Redis account (localhost)"}}, "typeVersion": 1.4, "notes": "This memoryRedisChat node performs automated tasks as part of the workflow."}, {"id": "c8fd56f5-c4c0-40cb-b727-07a94b633657", "name": "Start Session1", "type": "n8n-nodes-base.redis", "position": [440, 1620], "parameters": {"key": "YOUR_CREDENTIAL_HERE", "value": "={{\n{\n  \"has_session\": true,\n  \"session_createdAt\": $now,\n  \"current_question_idx\": 0\n}\n}}", "keyType": "YOUR_CREDENTIAL_HERE", "operation": "set"}, "credentials": {"redis": {"id": "zU4DA70qSDrZM1El", "name": "Redis account (localhost)"}}, "typeVersion": 1, "notes": "This redis node performs automated tasks as part of the workflow."}, {"id": "02eaa2cf-512c-4526-948e-b68989b3a8f4", "name": "Get State3", "type": "n8n-nodes-base.redis", "position": [1260, 2060], "parameters": {"key": "YOUR_CREDENTIAL_HERE", "options": {}, "operation": "get", "propertyName": "data"}, "credentials": {"redis": {"id": "zU4DA70qSDrZM1El", "name": "Redis account (localhost)"}}, "typeVersion": 1, "notes": "This redis node performs automated tasks as part of the workflow."}, {"id": "85631c2a-9317-4b14-92d1-895ac022eb70", "name": "Increment Index1", "type": "n8n-nodes-base.redis", "position": [1800, 2060], "parameters": {"key": "YOUR_CREDENTIAL_HERE", "value": "={{\n{\n  \"current_question_idx\": $json.next_question_idx < $json.num_questions\n    ? $json.next_question_idx\n    : $json.num_questions,\n  \"session_updated\": $now,\n}\n}}", "keyType": "YOUR_CREDENTIAL_HERE", "operation": "set"}, "credentials": {"redis": {"id": "zU4DA70qSDrZM1El", "name": "Redis account (localhost)"}}, "typeVersion": 1, "notes": "This redis node performs automated tasks as part of the workflow."}, {"id": "4464f6fe-d579-4e03-a8ca-918515d38b30", "name": "Interview Agent1", "type": "n8n-nodes-base.noOp", "position": [1040, 2540], "parameters": {"text": "={{ $('Telegram Trigger').first().json.message.text }}", "options": {}, "promptType": "define"}, "typeVersion": 1.7, "notes": "This agent node performs automated tasks as part of the workflow."}, {"id": "11ec3d5a-5f89-4a84-96ef-291526ae7365", "name": "Get Record1", "type": "n8n-nodes-base.googleSheets", "position": [-120, 2260], "parameters": {"options": {"returnFirstMatch": true}, "filtersUI": {"values": [{"lookupValue": "={{ $('Telegram Trigger').first().json.message.from.id }}", "lookupColumn": "ID"}]}, "sheetName": {"__rl": true, "mode": "list", "value": "gid=0", "cachedResultUrl": "{{ $env.WEBHOOK_URL }}", "cachedResultName": "Sheet1"}, "documentId": {"__rl": true, "mode": "id", "value": "={{ $('Set Variables1').first().json.gsheetId }}"}}, "credentials": {"googleSheetsOAuth2Api": {"id": "XHvC7jIRR8A2TlUl", "name": "Google Sheets account"}}, "typeVersion": 4.5, "alwaysOutputData": true, "notes": "This googleSheets node performs automated tasks as part of the workflow."}, {"id": "665d58f8-ba2f-4d87-ae56-260333c5ecdf", "name": "Append Responses1", "type": "n8n-nodes-base.set", "position": [440, 2440], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "8069d106-0918-4bc3-9f49-789322129136", "name": "payload", "type": "string", "value": "={{\n[\n  Object.values($('Get Record1').first().json)[Number($('Get State2').first().json.data.current_question_idx || 0) + 1],\n  'User: ' + $('Telegram Trigger').first().json.message.text,\n].join('\\n\\n').trim()\n}}"}, {"id": "d25c278c-d3a9-4a5a-9f49-01ee3ca8285a", "name": "cell", "type": "string", "value": "={{\n'abcdefghijklmnopqrstuvxyz'.toUpperCase().split('')[$('Message Type1').first().json.data.current_question_idx]\n}}{{ $('Get Record1').first().json.row_number }}"}]}}, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "4771e9e4-8b79-4530-8c4a-6e7ab0623d98", "name": "Update Answer2", "type": "n8n-nodes-base.httpRequest", "position": [1360, 2540], "parameters": {"url": "{{ $env.BASE_URL }}", "method": "PUT", "options": {}, "jsonBody": "={{\n{\n  \"range\": `Sheet1!${$('Append Responses1').first().json.cell}`,\n  \"majorDimension\": \"ROWS\",\n  \"values\": [[\n    $('Append Responses1').first().json.payload + '\\n\\nAgent: ' + $('Interview Agent1').first().json.output]]\n}\n}}", "sendBody": true, "sendQuery": true, "specifyBody": "json", "authentication": "{{ $credentials.predefinedCredentialType }}", "queryParameters": {"parameters": [{"name": "valueInputOption", "value": "RAW"}]}, "nodeCredentialType": "YOUR_CREDENTIAL_HERE"}, "credentials": {"googleSheetsOAuth2Api": {"id": "XHvC7jIRR8A2TlUl", "name": "Google Sheets account"}}, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow."}, {"id": "b7094d87-97ce-4f1a-8d30-4d6d57d24477", "name": "Get Last Bot Message1", "type": "n8n-nodes-base.redis", "position": [260, 2440], "parameters": {"key": "YOUR_CREDENTIAL_HERE", "options": {}, "operation": "get", "propertyName": "data"}, "credentials": {"redis": {"id": "zU4DA70qSDrZM1El", "name": "Redis account (localhost)"}}, "typeVersion": 1, "notes": "This redis node performs automated tasks as part of the workflow."}, {"id": "6dc77f41-6c3b-4358-82bc-2ea299ef69b2", "name": "Update Answer3", "type": "n8n-nodes-base.httpRequest", "position": [1020, 2180], "parameters": {"url": "{{ $env.BASE_URL }}", "method": "PUT", "options": {}, "jsonBody": "={{\n{\n  \"range\": `Sheet1!${$('Append Responses1').first().json.cell}`,\n  \"majorDimension\": \"ROWS\",\n  \"values\": [[$('Append Responses1').first().json.payload]]\n}\n}}", "sendBody": true, "sendQuery": true, "specifyBody": "json", "authentication": "{{ $credentials.predefinedCredentialType }}", "queryParameters": {"parameters": [{"name": "valueInputOption", "value": "RAW"}]}, "nodeCredentialType": "YOUR_CREDENTIAL_HERE"}, "credentials": {"googleSheetsOAuth2Api": {"id": "XHvC7jIRR8A2TlUl", "name": "Google Sheets account"}}, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow."}, {"id": "dd67ca61-b36c-4f9f-84fe-0b25d411e459", "name": "Model2", "type": "n8n-nodes-base.noOp", "position": [1000, 2700], "parameters": {"model": {"__rl": true, "mode": "list", "value": "gpt-4o-mini"}, "options": {}}, "credentials": {"openAiApi": {"id": "8gccIjcuf3gvaoEr", "name": "OpenAi account"}}, "typeVersion": 1.2, "notes": "This lmChatOpenAi node performs automated tasks as part of the workflow."}, {"id": "57698127-eea0-434e-af3a-4d49db4a7f15", "name": "Model3", "type": "n8n-nodes-base.noOp", "position": [600, 2600], "parameters": {"model": {"__rl": true, "mode": "list", "value": "gpt-4o-mini"}, "options": {}}, "credentials": {"openAiApi": {"id": "8gccIjcuf3gvaoEr", "name": "OpenAi account"}}, "typeVersion": 1.2, "notes": "This lmChatOpenAi node performs automated tasks as part of the workflow."}, {"id": "bad16467-bb3c-4d50-9dd8-014bac25fd61", "name": "Should Follow Up?1", "type": "n8n-nodes-base.noOp", "position": [620, 2440], "parameters": {"options": {}, "inputText": "=AI: {{ $('Get Last Bot Message1').item.json.data?.first().parseJson().data.content ?? ''}}\nUSER: {{ $('Telegram Trigger').first().json.message.text }}", "categories": {"categories": [{"category": "should_not_ask_followup_questions", "description": "=Either\n* The user was asked a close-ended question and gave an adequate static response\n* There are no further insights to be learned from the user's answer"}, {"category": "should_ask_followup_questions", "description": "=Either one of\n* There are possibly more insights to be learned from the user's answer if we enquire. hint: did the user explaied or justified their answer?\n* The user didn't answer the question"}]}}, "typeVersion": 1, "notes": "This textClassifier node performs automated tasks as part of the workflow."}, {"id": "86545380-9ff1-4815-bfaf-c4137fa00fda", "name": "Execution Data2", "type": "n8n-nodes-base.executionData", "position": [-700, 2060], "parameters": {"dataToSave": {"values": [{"key": "YOUR_CREDENTIAL_HERE", "value": "=state_message"}, {"key": "YOUR_CREDENTIAL_HERE", "value": "={{ $json.gsheetId }}"}, {"key": "YOUR_CREDENTIAL_HERE", "value": "={{ $json.title }}"}, {"key": "YOUR_CREDENTIAL_HERE", "value": "={{ $('Telegram Trigger').item.json.message.from.id }}"}]}}, "typeVersion": 1, "notes": "This executionData node performs automated tasks as part of the workflow."}, {"id": "ed16f03b-621e-4766-b8fd-f1f662b2dd0b", "name": "Create Record2", "type": "n8n-nodes-base.googleSheets", "position": [260, 2060], "parameters": {"columns": {"value": {"ID": "={{ $('Telegram Trigger').first().json.message.from.id }}"}, "schema": [{"id": "ID", "type": "string", "display": true, "removed": false, "required": false, "displayName": "ID", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What's your name?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What's your name?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What were the main factors that influenced your decision to purchase the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What were the main factors that influenced your decision to purchase the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What ultimately convinced you to choose the DJI Mini 2 over other options?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What ultimately convinced you to choose the DJI Mini 2 over other options?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How satisfied are you with the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How satisfied are you with the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What features do you like most about the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What features do you like most about the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Are there any features you feel are missing or could be improved?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Are there any features you feel are missing or could be improved?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Have you experienced any technical issues with the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Have you experienced any technical issues with the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How likely are you to recommend the DJI Mini 2 to others?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How likely are you to recommend the DJI Mini 2 to others?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Where did you purchase your DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Where did you purchase your DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How was your overall purchase experience?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How was your overall purchase experience?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Did you find all the information you needed before purchasing?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Did you find all the information you needed before purchasing?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "If you interacted with DJI customer support, how would you rate the experience?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "If you interacted with DJI customer support, how would you rate the experience?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How can DJI improve the Mini 2 or future drone models?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How can DJI improve the Mini 2 or future drone models?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How can DJI improve the overall shopping and customer service experience?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How can DJI improve the overall shopping and customer service experience?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Any additional comments or feedback?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Any additional comments or feedback?", "defaultMatch": false, "canBeUsedToMatch": true}], "mappingMode": "defineBelow", "matchingColumns": ["ID"], "attemptToConvertTypes": false, "convertFieldsToString": false}, "options": {}, "operation": "appendOrUpdate", "sheetName": {"__rl": true, "mode": "list", "value": "gid=0", "cachedResultUrl": "{{ $env.WEBHOOK_URL }}", "cachedResultName": "Sheet1"}, "documentId": {"__rl": true, "mode": "id", "value": "={{ $('Set Variables1').first().json.gsheetId }}"}}, "credentials": {"googleSheetsOAuth2Api": {"id": "XHvC7jIRR8A2TlUl", "name": "Google Sheets account"}}, "typeVersion": 4.5, "alwaysOutputData": true, "notes": "This googleSheets node performs automated tasks as part of the workflow."}, {"id": "f2119ef5-aef3-4b0f-80f5-1715a4afe3e0", "name": "Sticky Note8", "type": "n8n-nodes-base.stickyNote", "position": [-1120, 1820], "parameters": {"color": 7, "width": 760, "height": 500, "content": "## 1. Initiate Survey by Inviting User to Chat\n[Learn more about the chat trigger]({{ $env.WEBHOOK_URL }}\n\nTo present the survey to the user, we'll use n8n's builtin hosted chat. Survey questions are predefined and pulled from Google Sheet. Finally, for state and session management such as tracking which question we're asking, we'll use Redis as it's a fast write and ready database suitable for our chat."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "9e7ca15c-0e31-4d78-b8af-31fd6260cd61", "name": "Send Start", "type": "n8n-nodes-base.telegram", "position": [600, 1620], "webhookId": "c5d13268-df58-450b-84c4-a61cd2e027ed", "parameters": {"text": "={{ $('Set Variables1').first().json.title }}.\nWelcome! Thank you for taking the time to participate in our survey.\n\nYou'll be asked a couple of pre-defined questions. For each question, we may ask follow-up questions to better understand your situation. If you want to skip to the next question at any time, simply reply with the \"/next\". Your responses will be recorded.\n\nTo start the survey, simply reply with \"/next\".", "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}", "additionalFields": {"appendAttribution": false}}, "credentials": {"telegramApi": {"id": "wJqs1eMdbjilZH1W", "name": "jimleuk_ai_survey_demo_bot"}}, "typeVersion": 1.2, "notes": "This telegram node performs automated tasks as part of the workflow."}, {"id": "e8be2d00-39c8-4dd1-a597-813fc4bffe10", "name": "Send Start1", "type": "n8n-nodes-base.telegram", "position": [260, 1900], "webhookId": "c5d13268-df58-450b-84c4-a61cd2e027ed", "parameters": {"text": "=Sorry, that command is unrecognised. The available options are /start or /next.", "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}", "additionalFields": {"appendAttribution": false}}, "credentials": {"telegramApi": {"id": "wJqs1eMdbjilZH1W", "name": "jimleuk_ai_survey_demo_bot"}}, "typeVersion": 1.2, "notes": "This telegram node performs automated tasks as part of the workflow."}, {"id": "153bbe8b-52bc-403c-ae5f-346060a5aac3", "name": "Completed Survey", "type": "n8n-nodes-base.telegram", "position": [2220, 2280], "webhookId": "409dbc48-4916-415b-8c1b-caf3b359e1e4", "parameters": {"text": "=Done! Thank you for completing our survey.\nTo start the survey again, use \"/start\".", "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}", "additionalFields": {"appendAttribution": false}}, "credentials": {"telegramApi": {"id": "wJqs1eMdbjilZH1W", "name": "jimleuk_ai_survey_demo_bot"}}, "typeVersion": 1.2, "notes": "This telegram node performs automated tasks as part of the workflow."}, {"id": "c2e39206-f586-4c90-aeb0-d6a141e81d1d", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [-180, 1540], "parameters": {"color": 7, "width": 420, "height": 380, "content": "## 2. Handle Bot Commands\n[Learn more about the switch node]({{ $env.WEBHOOK_URL }}\n\nOur chatbot can be a mix of traditional chat mechanics and AI agent. Using bot commands, gives the user some control over the flow of the conversation such as skipping to the next question or starting over the survey."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "6b6241ae-17b7-4f0f-9c00-f5de4d62f692", "name": "Create Record1", "type": "n8n-nodes-base.googleSheets", "position": [280, 1620], "parameters": {"columns": {"value": {"ID": "={{ $('Telegram Trigger').first().json.message.from.id }}"}, "schema": [{"id": "ID", "type": "string", "display": true, "removed": false, "required": false, "displayName": "ID", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What's your name?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What's your name?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What were the main factors that influenced your decision to purchase the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What were the main factors that influenced your decision to purchase the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Did you compare the DJI Mini 2 with other drone models before purchasing? If yes, which other drone models were you considering? ", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What ultimately convinced you to choose the DJI Mini 2 over other options?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What ultimately convinced you to choose the DJI Mini 2 over other options?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How satisfied are you with the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How satisfied are you with the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "What features do you like most about the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "What features do you like most about the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Are there any features you feel are missing or could be improved?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Are there any features you feel are missing or could be improved?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Have you experienced any technical issues with the DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Have you experienced any technical issues with the DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How likely are you to recommend the DJI Mini 2 to others?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How likely are you to recommend the DJI Mini 2 to others?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Where did you purchase your DJI Mini 2?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Where did you purchase your DJI Mini 2?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How was your overall purchase experience?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How was your overall purchase experience?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Did you find all the information you needed before purchasing?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Did you find all the information you needed before purchasing?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "If you interacted with DJI customer support, how would you rate the experience?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "If you interacted with DJI customer support, how would you rate the experience?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How can DJI improve the Mini 2 or future drone models?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How can DJI improve the Mini 2 or future drone models?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "How can DJI improve the overall shopping and customer service experience?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "How can DJI improve the overall shopping and customer service experience?", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Any additional comments or feedback?", "type": "string", "display": true, "removed": true, "required": false, "displayName": "Any additional comments or feedback?", "defaultMatch": false, "canBeUsedToMatch": true}], "mappingMode": "defineBelow", "matchingColumns": ["ID"], "attemptToConvertTypes": false, "convertFieldsToString": false}, "options": {}, "operation": "appendOrUpdate", "sheetName": {"__rl": true, "mode": "list", "value": "gid=0", "cachedResultUrl": "{{ $env.WEBHOOK_URL }}", "cachedResultName": "Sheet1"}, "documentId": {"__rl": true, "mode": "id", "value": "={{ $('Set Variables1').first().json.gsheetId }}"}}, "credentials": {"googleSheetsOAuth2Api": {"id": "XHvC7jIRR8A2TlUl", "name": "Google Sheets account"}}, "typeVersion": 4.5, "alwaysOutputData": true, "notes": "This googleSheets node performs automated tasks as part of the workflow."}, {"id": "f8f6b582-75d7-40a1-95a5-c1b80fa41c64", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "position": [520, 2180], "parameters": {"color": 7, "width": 440, "height": 420, "content": "## 3. Support to Follow-Up Questions\n[Learn more about the Text Classifier node]({{ $env.WEBHOOK_URL }}\n\nDepending on whether the current question is open-ended or closed-ended, we may not require the Agent to spend too much time on the answer. Here we're using the text classifier node to make that judgement call - when closed-ended, we can skip to the next question and when open-ended, we can attempt to dig deeper into the answer."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "5aa8956b-787d-4b4a-b4dc-a2415434a331", "name": "Sticky Note4", "type": "n8n-nodes-base.stickyNote", "position": [980, 2340], "parameters": {"color": 7, "width": 700, "height": 500, "content": "## 4. Deeper Insights with a Conversational AI Agent\n[Learn more about the AI Agent]({{ $env.WEBHOOK_URL }}\n\nThe way we utilise the AI in this workflow is by allowing the agent to converse back-and-forth with the user on any given question of the survey. This means answers can be more than just single sentence and can expand to minute-long conversations, producting much deeper insights for the survey."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "aa304745-6d30-4fdb-8279-eb505ee06a61", "name": "Sticky Note5", "type": "n8n-nodes-base.stickyNote", "position": [1200, 1820], "parameters": {"color": 7, "width": 740, "height": 380, "content": "## 5. Managing Conversational Flow with External State\n[Learn more about the Redis node]({{ $env.WEBHOOK_URL }}\n\nWe use Redis as a quick and easy way to store and track the question index (or \"state\") as the user progresses through the survey. To calculate which question should be next or if the survey is complete, we query the spreadsheet row for the user's session and calculate our next state from there. "}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "4ce7ce73-d771-4794-b1fb-87c15ccdbdaf", "name": "Sticky Note6", "type": "n8n-nodes-base.stickyNote", "position": [2160, 1680], "parameters": {"color": 7, "width": 620, "height": 520, "content": "## 6. Resetting Chat Memory for Every Question\n[Learn more about the Chat Memory Manager]({{ $env.WEBHOOK_URL }}\n\nI discovered that to ensure my agent focused on a specific question when interacting with the user, I needed to clear all previous message context to prevent it from using past references. This is a really unconventional approach to controlling Agent behaviour but from my observation, greatly reduces hallucinations during the conversation."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "2b26317c-6ba6-4ff0-92a6-525cce9e725d", "name": "Sticky Note7", "type": "n8n-nodes-base.stickyNote", "position": [-1740, 1300], "parameters": {"width": 580, "height": 1020, "content": "## Try It Out\n### This n8n template demonstrates how you can build a structured chat journey augmented with AI for your business.\n\nIn this scenario, a chatbot conducts a product satisfaction survey with a user using a predefined set of questions. For each question, the agent can dive deeper into the user's answers by asking follow-up questions.\n\nThis chatbot template isn't fully \"agentic\" which makes it a bit more complicated and scripted but ensures a more deterministic user journey; suitable when you need more guide-rails on the experience.\n\nSee example survey here: {{ $env.WEBHOOK_URL }}\n\n### How it works\n* A chat session is started with the user who needs to enter the bot command \"/next\" to start the survey.\n* Once started, the template pulls in questions from a google sheet to ask the user. Questions are asked in sequence from left to right.\n* When the user answers the question, a text classifier node is used to determine \nif a follow-up question could be asked.\n* If not, the survey proceeds to the next question. Otherwise, an AI Agent will generate a follow-up question based on the user's response.\n* All answers and AI conversations are recorded in the Google Sheet.\n* When all questions are answered, the template will stop the survey and give the user a chance to restart.\n\n### How to use\n* You'll need to setup a Telegram bot ([see docs]({{ $env.WEBHOOK_URL }}\n* Create a google sheet with an ID column. Populate the rest of the columns with your survey questions ([see sample]({{ $env.WEBHOOK_URL }}\n* Ensure you have a Redis instance to capture state. Either self-host or sign-up to [Upstash]({{ $env.WEBHOOK_URL }} for a free account.\n* Update the \"Set Variable\" node with your google sheet ID and survey title.\n* Share the bot with users to allow others to participate in your survey.\n\n### Can I use this for WhatsApp?\nYes you can! Swapping out all telegram nodes for WhatsApp nodes should produce the same result.\n\n\n### Need Help?\nJoin the [Discord]({{ $env.WEBHOOK_URL }} or ask in the [Forum]({{ $env.WEBHOOK_URL }}"}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}], "pinData": {}, "connections": {"4771e9e4-8b79-4530-8c4a-6e7ab0623d98": {"main": [[{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-3a292d8b", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-1c7cb288", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-65406eaa", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-cd54692a", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-a1a214bb", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-b6838e4c", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-19614ebb", "type": "main", "index": 0}], [{"node": "error-handler-4771e9e4-8b79-4530-8c4a-6e7ab0623d98-426d4fd6", "type": "main", "index": 0}]]}, "6dc77f41-6c3b-4358-82bc-2ea299ef69b2": {"main": [[{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-7cce876e", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-e77b8440", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-aaa503d3", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-c09e0de0", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-e41c403f", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-037952be", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-bba8b244", "type": "main", "index": 0}], [{"node": "error-handler-6dc77f41-6c3b-4358-82bc-2ea299ef69b2-2daeeca3", "type": "main", "index": 0}]]}, "c537229c-ffdf-4a4b-8cdd-1d88621e58a0": {"main": [[{"node": "error-handler-c537229c-ffdf-4a4b-8cdd-1d88621e58a0-a889e381", "type": "main", "index": 0}]]}, "90426896-35d8-4449-8607-70e8485441ed": {"main": [[{"node": "error-handler-90426896-35d8-4449-8607-70e8485441ed-4b08cc25", "type": "main", "index": 0}]]}, "614b6d06-7bca-4710-aebf-3a2a685ace09": {"main": [[{"node": "error-handler-614b6d06-7bca-4710-aebf-3a2a685ace09-be152fc5", "type": "main", "index": 0}]]}, "8074143c-eab7-4146-937c-16c44ef40333": {"main": [[{"node": "error-handler-8074143c-eab7-4146-937c-16c44ef40333-c87d98b4", "type": "main", "index": 0}]]}, "11ec3d5a-5f89-4a84-96ef-291526ae7365": {"main": [[{"node": "error-handler-11ec3d5a-5f89-4a84-96ef-291526ae7365-3a556156", "type": "main", "index": 0}]]}, "dd67ca61-b36c-4f9f-84fe-0b25d411e459": {"main": [[{"node": "error-handler-dd67ca61-b36c-4f9f-84fe-0b25d411e459-e908d1ba", "type": "main", "index": 0}]]}, "57698127-eea0-434e-af3a-4d49db4a7f15": {"main": [[{"node": "error-handler-57698127-eea0-434e-af3a-4d49db4a7f15-e249de1f", "type": "main", "index": 0}]]}, "ed16f03b-621e-4766-b8fd-f1f662b2dd0b": {"main": [[{"node": "error-handler-ed16f03b-621e-4766-b8fd-f1f662b2dd0b-460d8296", "type": "main", "index": 0}]]}, "9e7ca15c-0e31-4d78-b8af-31fd6260cd61": {"main": [[{"node": "error-handler-9e7ca15c-0e31-4d78-b8af-31fd6260cd61-e9ed442f", "type": "main", "index": 0}]]}, "e8be2d00-39c8-4dd1-a597-813fc4bffe10": {"main": [[{"node": "error-handler-e8be2d00-39c8-4dd1-a597-813fc4bffe10-391f9df0", "type": "main", "index": 0}]]}, "153bbe8b-52bc-403c-ae5f-346060a5aac3": {"main": [[{"node": "error-handler-153bbe8b-52bc-403c-ae5f-346060a5aac3-540dc0eb", "type": "main", "index": 0}]]}, "6b6241ae-17b7-4f0f-9c00-f5de4d62f692": {"main": [[{"node": "error-handler-6b6241ae-17b7-4f0f-9c00-f5de4d62f692-8a8aee43", "type": "main", "index": 0}]]}}, "name": "Telegramtrigger Workflow", "settings": {"executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": null, "timezone": "UTC", "executionTimeout": 3600, "maxExecutions": 1000, "retryOnFail": true, "retryCount": 3, "retryDelay": 1000}, "description": "Automated workflow: Telegramtrigger Workflow. This workflow integrates 16 different services: textClassifier, telegramTrigger, httpRequest, stickyNote, telegram. It contains 56 nodes and follows best practices for error handling and security.", "tags": ["automation", "n8n", "production-ready", "excellent", "optimized"], "notes": "Excellent quality workflow: Telegramtrigger Workflow. This workflow has been optimized for production use with comprehensive error handling, security, and documentation."}