航空公司常见问题解答机器人
这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 27 个节点。主要使用 If, Code, Merge, Webhook, HttpRequest 等节点。 使用GPT-4和问题分类自动化航空公司客户支持
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
{
"id": "cxCJTsyZ4OX5OxaM",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281"
},
"name": "航空公司常见问题解答机器人",
"tags": [],
"nodes": [
{
"id": "d1db4f7a-cbb3-4ae1-a476-184c12f3b84c",
"name": "Webhook - 用户问题",
"type": "n8n-nodes-base.webhook",
"notes": "Receives user questions from chat interface (web, mobile, messaging apps)",
"position": [
-2240,
-48
],
"webhookId": "airlines-faq-bot",
"parameters": {
"path": "airlines-faq",
"options": {},
"httpMethod": "POST",
"responseMode": "responseNode"
},
"typeVersion": 1.1
},
{
"id": "0bef0713-edcc-471a-99b5-461a74ddb142",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2302,
-204
],
"parameters": {
"color": 4,
"width": 220,
"height": 316,
"content": "## 📥 入口点"
},
"typeVersion": 1
},
{
"id": "315fc368-5276-43ea-a448-9fa6196ad139",
"name": "提取和清理问题",
"type": "n8n-nodes-base.code",
"notes": "Parses webhook payload and extracts user question with metadata",
"position": [
-2016,
-48
],
"parameters": {
"jsCode": "// Extract and clean user input\nconst userQuestion = $input.item.json.body.question || $input.item.json.body.message || $input.item.json.body.text;\nconst userId = $input.item.json.body.user_id || $input.item.json.body.userId || 'anonymous';\nconst sessionId = $input.item.json.body.session_id || $input.item.json.body.sessionId || `session_${Date.now()}`;\nconst userName = $input.item.json.body.user_name || $input.item.json.body.userName || 'Traveler';\n\n// Clean the question\nconst cleanedQuestion = userQuestion.trim();\n\nreturn {\n json: {\n userQuestion: cleanedQuestion,\n userId: userId,\n sessionId: sessionId,\n userName: userName,\n timestamp: new Date().toISOString(),\n questionLength: cleanedQuestion.length\n }\n};"
},
"typeVersion": 2
},
{
"id": "1ba95fc8-ec26-4777-9862-f935b9eb1689",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2078,
-204
],
"parameters": {
"color": 5,
"width": 220,
"height": 316,
"content": "## 🔍 数据提取"
},
"typeVersion": 1
},
{
"id": "8497922b-c25a-499c-9011-30658f50f7fb",
"name": "分类问题类别",
"type": "n8n-nodes-base.httpRequest",
"notes": "Uses AI to categorize the question type for better response handling",
"position": [
-1792,
-48
],
"parameters": {
"url": "https://api.openai.com/v1/chat/completions",
"options": {},
"sendBody": true,
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{
"name": "model",
"value": "gpt-3.5-turbo"
},
{
"name": "messages",
"value": "=[{\"role\": \"system\", \"content\": \"You are a travel question classifier. Classify the following travel question into ONE of these categories: DESTINATIONS, PACKAGES, VISA, TRANSPORT, HOTELS, ACTIVITIES, BOOKING, CANCELLATION, BAGGAGE, GENERAL. Respond with only the category name in uppercase.\"}, {\"role\": \"user\", \"content\": \"{{ $json.userQuestion }}\"}]"
},
{
"name": "temperature",
"value": "0.2"
},
{
"name": "max_tokens",
"value": "20"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "769f6bfc-2285-48b4-9e66-39df46c26e08",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1854,
-252
],
"parameters": {
"color": 6,
"width": 220,
"height": 364,
"content": "## 🏷️ 分类"
},
"typeVersion": 1
},
{
"id": "3cfb9603-87c8-400e-8759-16e48edc9b3a",
"name": "解析类别结果",
"type": "n8n-nodes-base.code",
"notes": "Extracts and stores the detected question category",
"position": [
-1568,
-48
],
"parameters": {
"jsCode": "// Extract category from AI response\nconst category = $input.item.json.choices[0].message.content.trim().toUpperCase();\nconst previousData = $('Extract & Clean Question').item.json;\n\nreturn {\n json: {\n ...previousData,\n category: category,\n categoryDetected: true\n }\n};"
},
"typeVersion": 2
},
{
"id": "095d8f5c-5ade-410f-8520-f6425cc1dfc2",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1630,
-204
],
"parameters": {
"color": 5,
"width": 220,
"height": 316,
"content": "## 📋 类别解析"
},
"typeVersion": 1
},
{
"id": "bb2ef1fa-d174-4bc7-9701-2198294717ea",
"name": "获取知识库上下文",
"type": "n8n-nodes-base.code",
"notes": "Retrieves relevant information from knowledge base based on category",
"position": [
-1344,
-48
],
"parameters": {
"jsCode": "// Retrieve relevant knowledge base content based on category\nconst category = $input.item.json.category;\n\n// Knowledge base for different categories\nconst knowledgeBase = {\n DESTINATIONS: `Popular destinations include: Paris (France) - Eiffel Tower, museums; Tokyo (Japan) - temples, technology; New York (USA) - landmarks, culture; Dubai (UAE) - luxury, architecture; Bali (Indonesia) - beaches, temples; London (UK) - history, culture; Rome (Italy) - ancient sites; Barcelona (Spain) - architecture, beaches; Sydney (Australia) - Opera House, beaches; Singapore - modern city, gardens. Best times to visit vary by destination. Europe: April-October. Asia: November-March. Americas: Year-round with seasonal variations.`,\n \n PACKAGES: `Travel packages available: Honeymoon packages (7-14 days) with romantic destinations; Family packages with kid-friendly activities; Adventure packages including trekking, diving, skiing; Beach resort packages with all-inclusive options; Cultural tour packages with guided experiences; Business travel packages with flexible bookings; Group tour packages with fixed itineraries; Custom packages tailored to preferences. Packages include flights, hotels, transfers, and selected activities. Early bird discounts up to 20% available.`,\n \n VISA: `Visa requirements vary by destination and passport: EU citizens can travel visa-free within Schengen area; US/UK/Canada citizens have visa-free access to 150+ countries; Tourist visas typically valid 30-90 days; Business visas require company invitation letter; E-visas available for many countries (Turkey, India, Australia, etc.); Visa-on-arrival available in Thailand, Indonesia, Maldives; Processing time: 3-15 business days; Required documents: valid passport (6 months validity), photos, travel itinerary, proof of accommodation, bank statements.`,\n \n TRANSPORT: `Transportation options: International flights with major airlines (economy, business, first class); Domestic flights for inter-city travel; Airport transfers (private car, shuttle, taxi, metro); Train services (high-speed, regional); Car rentals with international/local companies; Private chauffeurs available; Bike rentals in tourist cities; Ferry services for island destinations; Metro/subway in major cities; Rideshare services (Uber, Lyft) available in most cities. Pre-booking recommended for better rates.`,\n \n HOTELS: `Accommodation options: 5-star luxury hotels with premium amenities; 4-star business hotels with conference facilities; 3-star tourist hotels for budget travelers; Boutique hotels with unique experiences; Beach resorts with all-inclusive packages; Airport hotels for layovers; Hostels for backpackers; Vacation rentals (Airbnb, apartments); Bed & breakfasts; Eco-lodges and sustainable accommodations. Amenities include: WiFi, breakfast, pool, gym, spa, concierge, room service. Free cancellation available on selected bookings.`,\n \n ACTIVITIES: `Popular activities: City tours (walking, bus, bike); Museum and gallery visits; Adventure sports (diving, skiing, paragliding); Cultural experiences (cooking classes, traditional shows); Beach activities (snorkeling, surfing, sailing); Wildlife safaris and nature tours; Food and wine tours; Shopping tours in local markets; Spa and wellness experiences; Night entertainment and cruises; Photography tours; Theme parks and attractions. Activities can be pre-booked or arranged on arrival.`,\n \n BOOKING: `Booking process: Search flights/hotels on website or app; Select dates, passengers, preferences; Compare prices and options; Add extras (meals, baggage, insurance); Enter passenger details; Choose payment method (card, PayPal, installments); Receive instant confirmation email; E-tickets sent to email/app; Check-in online 24-48 hours before departure; Modify booking through manage booking section. Customer support available 24/7. Book in advance for better prices (2-3 months recommended).`,\n \n CANCELLATION: `Cancellation policy: Free cancellation up to 24 hours for most bookings; Refundable tickets allow cancellation with fees; Non-refundable tickets have restrictions; Cancellation fees: 0-100% depending on timing; Hotels: usually free cancellation 1-3 days before check-in; Packages: cancellation fees apply per component; Medical emergencies considered for exceptions; Travel insurance covers cancellations; Refund processing: 7-14 business days; Online cancellation available through manage booking. Contact support for assistance.`,\n \n BAGGAGE: `Baggage allowance: Economy class - 1 cabin bag (7-10kg) + 1 checked bag (20-23kg); Business class - 2 cabin bags + 2 checked bags (32kg each); Cabin baggage dimensions: 55x40x20cm; Excess baggage charged per kg; Liquid restrictions: max 100ml containers in clear bag; Sports equipment charged separately; Musical instruments as cabin baggage (subject to size); Prohibited items: weapons, explosives, flammables; Fragile items declaration recommended; Lost baggage claim at airport desk; Delayed baggage compensation available.`,\n \n GENERAL: `General travel information: Customer service available 24/7 via phone, email, chat; Mobile app for iOS and Android; Loyalty program with points and rewards; Travel insurance recommended for all bookings; Payment options: credit/debit cards, PayPal, installments; Multi-currency support; Newsletter for deals and offers; Best price guarantee; Flexible booking options; Group booking discounts; Corporate travel solutions; Travel advisories and safety tips; Passport and document checklist; Health and vaccination requirements; Currency exchange information.`\n};\n\nconst relevantContext = knowledgeBase[category] || knowledgeBase['GENERAL'];\n\nreturn {\n json: {\n ...$input.item.json,\n knowledgeContext: relevantContext,\n contextLength: relevantContext.length\n }\n};"
},
"typeVersion": 2
},
{
"id": "08a39ce0-ceeb-42b7-8834-7ab611c4ca0f",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1416,
-188
],
"parameters": {
"color": 4,
"height": 300,
"content": "## 📚 知识库"
},
"typeVersion": 1
},
{
"id": "41dd1bb9-921f-4260-aa46-0af5ac648a4b",
"name": "生成 AI 答案",
"type": "n8n-nodes-base.httpRequest",
"notes": "Uses GPT-4 to generate accurate, contextual answer to user's question",
"position": [
-1120,
-48
],
"parameters": {
"url": "https://api.openai.com/v1/chat/completions",
"options": {},
"sendBody": true,
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{
"name": "model",
"value": "gpt-4"
},
{
"name": "messages",
"value": "=[{\"role\": \"system\", \"content\": \"You are a helpful and friendly airlines travel assistant. Answer travel questions accurately based on the provided context. Be concise but informative. Use a warm, professional tone. If you don't have specific information, provide general guidance and suggest contacting customer support for details. Always prioritize customer satisfaction and safety.\\n\\nContext Information:\\n{{ $json.knowledgeContext }}\"}, {\"role\": \"user\", \"content\": \"{{ $json.userQuestion }}\"}]"
},
{
"name": "temperature",
"value": "0.7"
},
{
"name": "max_tokens",
"value": "500"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "cfdcbd1d-75ae-43c8-85da-32f8f6f68191",
"name": "便签 5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1192,
-172
],
"parameters": {
"color": 6,
"height": 284,
"content": "## 🤖 AI 响应"
},
"typeVersion": 1
},
{
"id": "e153881f-8b15-4138-9b2b-40aca2b9da64",
"name": "格式化最终响应",
"type": "n8n-nodes-base.code",
"notes": "Formats AI answer with quick links and related resources",
"position": [
-896,
-48
],
"parameters": {
"jsCode": "// Extract AI answer and add helpful resources\nconst aiAnswer = $input.item.json.choices[0].message.content.trim();\nconst previousData = $('Fetch Knowledge Base Context').item.json;\nconst category = previousData.category;\n\n// Add relevant quick links based on category\nconst quickLinks = {\n DESTINATIONS: ['View All Destinations', 'Travel Guides', 'Best Time to Visit'],\n PACKAGES: ['Browse Packages', 'Custom Package Builder', 'Special Offers'],\n VISA: ['Visa Requirements Checker', 'Document Checklist', 'Visa Application'],\n TRANSPORT: ['Book Flights', 'Airport Transfers', 'Car Rentals'],\n HOTELS: ['Search Hotels', 'Hotel Deals', 'Partner Properties'],\n ACTIVITIES: ['Popular Activities', 'Book Tours', 'Local Experiences'],\n BOOKING: ['New Booking', 'Manage Booking', 'Check-in Online'],\n CANCELLATION: ['Cancel Booking', 'Refund Status', 'Change Booking'],\n BAGGAGE: ['Baggage Policy', 'Add Extra Baggage', 'Track Baggage'],\n GENERAL: ['Contact Support', 'FAQs', 'Travel Tips']\n};\n\nconst relatedLinks = quickLinks[category] || quickLinks['GENERAL'];\n\nreturn {\n json: {\n answer: aiAnswer,\n category: category,\n relatedLinks: relatedLinks,\n userQuestion: previousData.userQuestion,\n userName: previousData.userName,\n userId: previousData.userId,\n sessionId: previousData.sessionId,\n timestamp: previousData.timestamp,\n answerLength: aiAnswer.length,\n tokensUsed: $input.item.json.usage?.total_tokens || 0\n }\n};"
},
"typeVersion": 2
},
{
"id": "33add07e-b654-40f6-b949-306c54fff462",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-958,
-204
],
"parameters": {
"color": 5,
"width": 220,
"height": 316,
"content": "## 📝 响应格式化"
},
"typeVersion": 1
},
{
"id": "8ca97e45-3377-43ec-986c-60437382fc97",
"name": "检查用户满意度",
"type": "n8n-nodes-base.if",
"notes": "Detects positive feedback or satisfaction indicators in user response",
"position": [
-672,
-48
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false
},
"combinator": "and",
"conditions": [
{
"id": "satisfaction-check",
"operator": {
"type": "string",
"operation": "regex"
},
"leftValue": "={{ $json.userQuestion.toLowerCase() }}",
"rightValue": "thank|thanks|helpful|great|perfect|excellent|satisfied"
}
]
}
},
"typeVersion": 2
},
{
"id": "df25cb34-8bfc-49dc-84e2-fb49e4eaa574",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-734,
-316
],
"parameters": {
"color": 4,
"width": 220,
"height": 428,
"content": "## ✅ 满意度检查"
},
"typeVersion": 1
},
{
"id": "02415ea9-30f3-4e6a-9417-cbddb271385c",
"name": "记录满意用户",
"type": "n8n-nodes-base.code",
"notes": "Records satisfied user interaction for analytics",
"position": [
-448,
-144
],
"parameters": {
"jsCode": "// Log satisfied interaction\nconst logData = $input.item.json;\n\nreturn {\n json: {\n ...logData,\n satisfactionStatus: 'satisfied',\n followUpOffered: false,\n needsHumanSupport: false\n }\n};"
},
"typeVersion": 2
},
{
"id": "bdc67353-8ec2-4cc0-8b52-9b3d47b8dfc9",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
-400
],
"parameters": {
"color": 6,
"width": 200,
"height": 280,
"content": "## 😊 满意路径"
},
"typeVersion": 1
},
{
"id": "cd966262-02d7-4a2a-8c4d-d4817274cbf6",
"name": "提供人工支持",
"type": "n8n-nodes-base.code",
"notes": "Offers human agent support if user seems unsatisfied or needs more help",
"position": [
-448,
48
],
"parameters": {
"jsCode": "// Add follow-up offer for unsure users\nconst logData = $input.item.json;\n\nreturn {\n json: {\n ...logData,\n satisfactionStatus: 'needs_followup',\n followUpOffered: true,\n followUpMessage: 'Would you like to speak with a travel specialist for more personalized assistance? Or do you have any other questions?',\n supportOptions: ['Chat with Agent', 'Schedule Call', 'Send Email', 'Continue with Bot']\n }\n};"
},
"typeVersion": 2
},
{
"id": "d7e44de7-358f-49b8-b33d-4a07a9119405",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
208
],
"parameters": {
"color": 5,
"width": 200,
"height": 328,
"content": "## 🤝 跟进路径"
},
"typeVersion": 1
},
{
"id": "d109c4a2-0fbf-4d2d-b83a-6a564dc0debf",
"name": "合并满意度路径",
"type": "n8n-nodes-base.merge",
"notes": "Combines both satisfaction paths into single output stream",
"position": [
-224,
-48
],
"parameters": {
"mode": "combine",
"options": {}
},
"typeVersion": 3
},
{
"id": "93a86c68-f530-42e1-bdb8-fc96d2a8ff0f",
"name": "便签 10",
"type": "n8n-nodes-base.stickyNote",
"position": [
-276,
-220
],
"parameters": {
"color": 4,
"width": 200,
"height": 332,
"content": "## 🔀 路径合并"
},
"typeVersion": 1
},
{
"id": "74c7c9f0-6980-49c3-ad70-83a1302b30f8",
"name": "记录交互到数据库",
"type": "n8n-nodes-base.httpRequest",
"notes": "Saves complete interaction data to database for analytics and training",
"position": [
0,
-48
],
"parameters": {
"url": "https://your-database-api.com/logs/interactions",
"options": {},
"sendBody": true,
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{
"name": "userId",
"value": "={{ $json.userId }}"
},
{
"name": "sessionId",
"value": "={{ $json.sessionId }}"
},
{
"name": "question",
"value": "={{ $json.userQuestion }}"
},
{
"name": "category",
"value": "={{ $json.category }}"
},
{
"name": "answer",
"value": "={{ $json.answer }}"
},
{
"name": "satisfaction",
"value": "={{ $json.satisfactionStatus }}"
},
{
"name": "timestamp",
"value": "={{ $json.timestamp }}"
},
{
"name": "tokensUsed",
"value": "={{ $json.tokensUsed }}"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "fd0b4322-d55f-4fe4-b012-95449f15f1a6",
"name": "便签11",
"type": "n8n-nodes-base.stickyNote",
"position": [
-62,
-316
],
"parameters": {
"color": 6,
"width": 220,
"height": 428,
"content": "## 💾 数据库记录"
},
"typeVersion": 1
},
{
"id": "74fac8eb-c4d9-4c90-bb9b-b8a833e2285b",
"name": "发送响应给用户",
"type": "n8n-nodes-base.respondToWebhook",
"notes": "Sends formatted answer back to user via webhook response",
"position": [
224,
-48
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": "={{ {\n \"status\": \"success\",\n \"answer\": $json.answer,\n \"category\": $json.category,\n \"relatedLinks\": $json.relatedLinks,\n \"followUpMessage\": $json.followUpMessage || null,\n \"supportOptions\": $json.supportOptions || null,\n \"sessionId\": $json.sessionId,\n \"timestamp\": $json.timestamp\n} }}"
},
"typeVersion": 1.1
},
{
"id": "fe10f085-1e51-4fdf-9c12-d673e1549176",
"name": "便签 12",
"type": "n8n-nodes-base.stickyNote",
"position": [
162,
-252
],
"parameters": {
"color": 5,
"width": 220,
"height": 364,
"content": "## 📤 响应传递"
},
"typeVersion": 1
},
{
"id": "76739678-85b5-4e62-a537-ad651b769001",
"name": "便签 13",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1616,
-1024
],
"parameters": {
"color": 3,
"width": 380,
"height": 664,
"content": "## ✈️ 航空公司常见问题解答机器人"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "255b9151-2d16-4a97-8929-7c4fe0306493",
"connections": {
"Generate AI Answer": {
"main": [
[
{
"node": "Format Final Response",
"type": "main",
"index": 0
}
]
]
},
"Log Satisfied User": {
"main": [
[
{
"node": "Merge Satisfaction Paths",
"type": "main",
"index": 0
}
]
]
},
"Offer Human Support": {
"main": [
[
{
"node": "Merge Satisfaction Paths",
"type": "main",
"index": 1
}
]
]
},
"Format Final Response": {
"main": [
[
{
"node": "Check User Satisfaction",
"type": "main",
"index": 0
}
]
]
},
"Parse Category Result": {
"main": [
[
{
"node": "Fetch Knowledge Base Context",
"type": "main",
"index": 0
}
]
]
},
"Check User Satisfaction": {
"main": [
[
{
"node": "Log Satisfied User",
"type": "main",
"index": 0
}
],
[
{
"node": "Offer Human Support",
"type": "main",
"index": 0
}
]
]
},
"Webhook - User Question": {
"main": [
[
{
"node": "Extract & Clean Question",
"type": "main",
"index": 0
}
]
]
},
"Extract & Clean Question": {
"main": [
[
{
"node": "Classify Question Category",
"type": "main",
"index": 0
}
]
]
},
"Merge Satisfaction Paths": {
"main": [
[
{
"node": "Log Interaction to Database",
"type": "main",
"index": 0
}
]
]
},
"Classify Question Category": {
"main": [
[
{
"node": "Parse Category Result",
"type": "main",
"index": 0
}
]
]
},
"Log Interaction to Database": {
"main": [
[
{
"node": "Send Response to User",
"type": "main",
"index": 0
}
]
]
},
"Fetch Knowledge Base Context": {
"main": [
[
{
"node": "Generate AI Answer",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 客服机器人, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
分享此工作流