WhatsApp上的AI电影推荐器
这是一个Support Chatbot, Multimodal AI领域的自动化工作流,包含 20 个节点。主要使用 If, Set, Code, Webhook, HttpRequest 等节点。 WhatsApp上的AI电影推荐器
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
{
"id": "VtM8HCd8u8XVdY76",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281"
},
"name": "WhatsApp 上的 AI 电影推荐器",
"tags": [],
"nodes": [
{
"id": "7b3c972a-bed3-45d3-bd94-1fd6d4f2f0c2",
"name": "Ollama 模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOllama",
"position": [
100,
1220
],
"parameters": {
"model": "llama3.2-16000:latest",
"options": {}
},
"credentials": {
"ollamaApi": {
"id": "7td3WzXCW2wNhraP",
"name": "Ollama - test"
}
},
"typeVersion": 1
},
{
"id": "01b7e2c5-b991-4092-8391-53647b710ada",
"name": "分析 WhatsApp 消息",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
20,
1000
],
"parameters": {
"text": "={{ $json.body.message }}",
"options": {
"systemMessage": "You are a movie assistant that analyzes WhatsApp messages for movie requests.\n\nAnalyze the message and determine:\n1. If it's asking for a specific movie (return: \"specific:MovieName\")\n2. If it's asking for genre recommendations (return: \"genre:GenreName\")\n3. If it's asking where to watch something (return: \"where:MovieName\")\n\nExamples:\n- \"I want to watch horror movies\" → \"genre:horror\"\n- \"Where can I watch Jumanji?\" → \"where:Jumanji\"\n- \"Recommend me action films\" → \"genre:action\"\n- \"What's available on Netflix?\" → \"genre:popular\"\n\nReply with only the format above, nothing else.\n\nInput: {{ $json.body.message }}"
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "e6af8044-a298-4020-8e66-1fcd798a2934",
"name": "检查请求类型",
"type": "n8n-nodes-base.if",
"position": [
400,
1000
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.output }}",
"value2": "specific:",
"operation": "contains"
}
]
}
},
"typeVersion": 1
},
{
"id": "46191d6d-568a-463d-9cab-dbc4907ffcde",
"name": "检查请求来源",
"type": "n8n-nodes-base.if",
"position": [
620,
1080
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.output }}",
"value2": "where:",
"operation": "contains"
}
]
}
},
"typeVersion": 1
},
{
"id": "578c6858-2b24-45a4-9f7b-3dd4999a5548",
"name": "提取电影标题",
"type": "n8n-nodes-base.set",
"position": [
840,
900
],
"parameters": {
"values": {
"string": [
{
"name": "movie_title",
"value": "={{ $json.output.split(':')[1] }}"
},
{
"name": "phone_number",
"value": "={{ $node[\"WhatsApp Webhook Trigger\"].json.body.from }}"
}
]
},
"options": {},
"keepOnlySet": true
},
"typeVersion": 1
},
{
"id": "0283347d-f2dd-4695-b536-9ba16c997bfb",
"name": "提取类型",
"type": "n8n-nodes-base.set",
"position": [
840,
1120
],
"parameters": {
"values": {
"string": [
{
"name": "genre",
"value": "={{ $json.output.split(':')[1] }}"
},
{
"name": "phone_number",
"value": "={{ $node[\"WhatsApp Webhook Trigger\"].json.body.from }}"
}
]
},
"options": {},
"keepOnlySet": true
},
"typeVersion": 1
},
{
"id": "e5831fc6-0b89-4944-83d6-c7bf5dfabd9f",
"name": "搜索特定电影",
"type": "n8n-nodes-base.httpRequest",
"position": [
1060,
900
],
"parameters": {
"url": "https://api.themoviedb.org/3/search/movie",
"options": {},
"authentication": "predefinedCredentialType",
"queryParametersUi": {
"parameter": [
{
"name": "api_key",
"value": "YOUR_TMDB_API_KEY"
},
{
"name": "query",
"value": "={{ $json.movie_title }}"
}
]
}
},
"typeVersion": 1
},
{
"id": "1b6d90a5-16dc-4826-88e5-05ee09b0d152",
"name": "按类型搜索电影",
"type": "n8n-nodes-base.httpRequest",
"position": [
1060,
1120
],
"parameters": {
"url": "https://api.themoviedb.org/3/discover/movie",
"options": {},
"authentication": "predefinedCredentialType",
"queryParametersUi": {
"parameter": [
{
"name": "api_key",
"value": "YOUR_TMDB_API_KEY"
},
{
"name": "with_genres",
"value": "={{ $json.genre === 'horror' ? '27' : $json.genre === 'action' ? '28' : $json.genre === 'comedy' ? '35' : $json.genre === 'drama' ? '18' : $json.genre === 'romance' ? '10749' : $json.genre === 'thriller' ? '53' : $json.genre === 'sci-fi' || $json.genre === 'science fiction' ? '878' : '28' }}"
},
{
"name": "sort_by",
"value": "popularity.desc"
},
{
"name": "page",
"value": "1"
}
]
}
},
"typeVersion": 1
},
{
"id": "6142cc81-1377-4282-99eb-03d472dd2d5a",
"name": "获取流媒体可用性",
"type": "n8n-nodes-base.httpRequest",
"position": [
1280,
900
],
"parameters": {
"url": "https://api.watchmode.com/v1/title/{{ $json.results[0].id }}/details/",
"options": {},
"queryParametersUi": {
"parameter": [
{
"name": "apiKey",
"value": "YOUR_WATCHMODE_API_KEY"
},
{
"name": "append_to_response",
"value": "sources"
}
]
}
},
"typeVersion": 1
},
{
"id": "444665c4-e78c-4601-9802-75de6260d6d9",
"name": "格式化类型推荐",
"type": "n8n-nodes-base.code",
"position": [
1280,
1120
],
"parameters": {
"jsCode": "// Format movie recommendations from genre search\nconst movies = items[0].json.results.slice(0, 5); // Top 5 movies\nconst genre = $node[\"Extract Genre\"].json.genre;\nconst phoneNumber = items[0].json.phone_number;\n\nlet message = `🎬 *${genre.toUpperCase()} Movie Recommendations:*\\n\\n`;\n\nmovies.forEach((movie, index) => {\n const rating = movie.vote_average ? `⭐ ${movie.vote_average}/10` : 'No rating';\n const year = movie.release_date ? `(${movie.release_date.split('-')[0]})` : '';\n \n message += `${index + 1}. *${movie.title}* ${year}\\n`;\n message += `${rating}\\n`;\n if (movie.overview && movie.overview.length > 100) {\n message += `${movie.overview.substring(0, 100)}...\\n\\n`;\n } else if (movie.overview) {\n message += `${movie.overview}\\n\\n`;\n } else {\n message += 'No description available\\n\\n';\n }\n});\n\nmessage += `💡 *Want streaming info for any movie? Just ask \"Where can I watch [Movie Name]?\"*`;\n\nreturn [{\n json: {\n phone_number: phoneNumber,\n message: message,\n type: 'genre_recommendations'\n }\n}];"
},
"typeVersion": 2
},
{
"id": "34e44718-176b-4809-94e0-9d554c5c9df0",
"name": "格式化流媒体响应",
"type": "n8n-nodes-base.code",
"position": [
1500,
900
],
"parameters": {
"jsCode": "// Format streaming availability response\nconst movie = $node[\"Search Specific Movie\"].json.results[0];\nconst streamingData = items[0].json;\nconst phoneNumber = $node[\"Extract Movie Title\"].json.phone_number;\n\nif (!movie) {\n return [{\n json: {\n phone_number: phoneNumber,\n message: \"❌ Sorry, I couldn't find that movie. Please check the spelling and try again.\",\n type: 'error'\n }\n }];\n}\n\nlet message = `🎬 *${movie.title}*`;\nif (movie.release_date) {\n message += ` (${movie.release_date.split('-')[0]})`;\n}\nmessage += `\\n⭐ ${movie.vote_average}/10\\n\\n`;\n\nif (movie.overview) {\n message += `📖 *Plot:*\\n${movie.overview}\\n\\n`;\n}\n\n// Check if streaming data is available\nif (streamingData.sources && streamingData.sources.length > 0) {\n message += `📺 *Available on:*\\n`;\n streamingData.sources.slice(0, 8).forEach(source => {\n const platform = source.name || source.source_name || 'Unknown Platform';\n const type = source.type === 'sub' ? '(Subscription)' : \n source.type === 'rent' ? '(Rent)' : \n source.type === 'buy' ? '(Buy)' : '';\n message += `• ${platform} ${type}\\n`;\n });\n} else {\n message += `📺 *Streaming Info:*\\n• Check Netflix, Prime Video, Disney+, or other platforms\\n• May be available for rent/purchase on digital platforms`;\n}\n\nreturn [{\n json: {\n phone_number: phoneNumber,\n message: message,\n type: 'streaming_info'\n }\n}];"
},
"typeVersion": 2
},
{
"id": "ce66592d-4f92-48c0-8d27-0ae1fc170a46",
"name": "准备 WhatsApp 消息",
"type": "n8n-nodes-base.code",
"position": [
1500,
1120
],
"parameters": {
"jsCode": "// Prepare WhatsApp message payload\nconst phoneNumber = items[0].json.phone_number;\nconst message = items[0].json.message;\n\nreturn [{\n json: {\n messaging_product: \"whatsapp\",\n to: phoneNumber,\n type: \"text\",\n text: {\n body: message\n }\n }\n}];"
},
"typeVersion": 2
},
{
"id": "d9973ca2-3b10-4fae-b083-3d2b52dc52a9",
"name": "概览",
"type": "n8n-nodes-base.stickyNote",
"position": [
-100,
0
],
"parameters": {
"color": 5,
"width": 600,
"height": 360,
"content": "## 电影推荐 WhatsApp 机器人"
},
"typeVersion": 1
},
{
"id": "cc2a939c-d5e9-480d-b41d-a07d2046232a",
"name": "设置指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
0
],
"parameters": {
"color": 7,
"width": 660,
"height": 360,
"content": "## 设置说明:"
},
"typeVersion": 1
},
{
"id": "10e4252a-09a1-4b5d-9177-d7763bf5e472",
"name": "消息处理",
"type": "n8n-nodes-base.stickyNote",
"position": [
-260,
760
],
"parameters": {
"color": 4,
"width": 500,
"height": 600,
"content": "## 消息处理流程"
},
"typeVersion": 1
},
{
"id": "6517c012-f59d-4c14-bd51-1d0261490ef3",
"name": "请求路由",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
640
],
"parameters": {
"color": 3,
"width": 480,
"height": 600,
"content": "## 请求路由"
},
"typeVersion": 1
},
{
"id": "c2b73395-abae-4d42-9eeb-8a4946f8997d",
"name": "API 集成",
"type": "n8n-nodes-base.stickyNote",
"position": [
820,
620
],
"parameters": {
"color": 6,
"width": 560,
"height": 600,
"content": "## API 集成"
},
"typeVersion": 1
},
{
"id": "6e53dc12-4048-4cca-a8e1-1ec76e557ebc",
"name": "响应格式化",
"type": "n8n-nodes-base.stickyNote",
"position": [
1480,
700
],
"parameters": {
"color": 2,
"width": 560,
"height": 600,
"content": "## 响应格式化"
},
"typeVersion": 1
},
{
"id": "faec17ce-cb22-448c-81bd-b310487529ec",
"name": "发送 WhatsApp 响应",
"type": "n8n-nodes-base.httpRequest",
"position": [
1720,
1000
],
"parameters": {
"url": "https://graph.facebook.com/v17.0/YOUR_PHONE_NUMBER_ID/messages",
"options": {},
"authentication": "predefinedCredentialType"
},
"typeVersion": 1
},
{
"id": "e8ff4c7a-9ec1-47c8-897b-dbd5045e15a1",
"name": "WhatsApp Webhook 触发器",
"type": "n8n-nodes-base.webhook",
"position": [
-200,
1000
],
"webhookId": "daa6c91b-b1f7-430d-8ff1-c6afc19cdd40",
"parameters": {
"path": "daa6c91b-b1f7-430d-8ff1-c6afc19cdd40",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "2715ef60-87da-45ad-a9dd-46adb914aaa7",
"connections": {
"Ollama Model": {
"ai_languageModel": [
[
{
"node": "Analyze WhatsApp Message",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Extract Genre": {
"main": [
[
{
"node": "Search Movies by Genre",
"type": "main",
"index": 0
}
]
]
},
"Check Request Type": {
"main": [
[
{
"node": "Extract Movie Title",
"type": "main",
"index": 0
}
],
[
{
"node": "Check Where Request",
"type": "main",
"index": 0
}
]
]
},
"Check Where Request": {
"main": [
[
{
"node": "Extract Movie Title",
"type": "main",
"index": 0
}
],
[
{
"node": "Extract Genre",
"type": "main",
"index": 0
}
]
]
},
"Extract Movie Title": {
"main": [
[
{
"node": "Search Specific Movie",
"type": "main",
"index": 0
}
]
]
},
"Search Specific Movie": {
"main": [
[
{
"node": "Get Streaming Availability",
"type": "main",
"index": 0
}
]
]
},
"Search Movies by Genre": {
"main": [
[
{
"node": "Format Genre Recommendations",
"type": "main",
"index": 0
}
]
]
},
"Analyze WhatsApp Message": {
"main": [
[
{
"node": "Check Request Type",
"type": "main",
"index": 0
}
]
]
},
"Prepare WhatsApp Message": {
"main": [
[
{
"node": "Send WhatsApp Response",
"type": "main",
"index": 0
}
]
]
},
"WhatsApp Webhook Trigger": {
"main": [
[
{
"node": "Analyze WhatsApp Message",
"type": "main",
"index": 0
}
]
]
},
"Format Streaming Response": {
"main": [
[
{
"node": "Send WhatsApp Response",
"type": "main",
"index": 0
}
]
]
},
"Get Streaming Availability": {
"main": [
[
{
"node": "Format Streaming Response",
"type": "main",
"index": 0
}
]
]
},
"Format Genre Recommendations": {
"main": [
[
{
"node": "Prepare WhatsApp Message",
"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.
分享此工作流