8
n8n 中文网amn8n.com

基于 AI、JotForm、WhatsApp 和日历的自动化律师事务所线索管理与排程

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 16 个节点。主要使用 If, WhatsApp, GoogleSheets, JotFormTrigger, Agent 等节点。 基于 AI、JotForm、WhatsApp 和日历的自动化律师事务所线索管理与排程

前置要求
  • Google Sheets API 凭证
  • Google Gemini API Key
  • PostgreSQL 数据库连接信息
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "93f396852104089b8670e7494b0f3668b420464668ae4a8c1d6b4b5799f8e3ef",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0fa7eed1-0e6d-4370-bb11-2500e93c2ef0",
      "name": "JotForm触发器",
      "type": "n8n-nodes-base.jotFormTrigger",
      "position": [
        -1024,
        256
      ],
      "webhookId": "c18ee2e4-2ebf-4058-a167-e71b8a6d1ff0",
      "parameters": {
        "form": "252801824783057"
      },
      "credentials": {
        "jotFormApi": {
          "id": "I2Xm5wbkEW1qEJC5",
          "name": "JotForm account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0c107533-b8d0-4dc8-a073-7138a7288146",
      "name": "在表格中追加或更新行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -800,
        256
      ],
      "parameters": {
        "columns": {
          "value": {
            "Full Name": "={{ $json['Full Name'].first }} {{ $json['Full Name'].last }}",
            "client type": "={{ $json['I am a...'] }}",
            "Phone Number": "={{ $json['Phone Number'].full }}",
            "Brief Message": "={{ $json['Brief Message'] }}",
            "Email Address": "={{ $json['Email Address'] }}",
            "Legal Service of Interest": "={{ $json['Legal Service of Interest'] }}",
            "How Did You Hear About Us?": "={{ $json['How Did You Hear About Us?'] }}"
          },
          "schema": [
            {
              "id": "Full Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Full Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "client type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "client type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Legal Service of Interest",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Legal Service of Interest",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Brief Message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Brief Message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "How Did You Hear About Us?",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "How Did You Hear About Us?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email Address"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1invngp2z_3ZMe_Qcs5XioDkAs50DSXT-Pl4ibPLXyA0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1invngp2z_3ZMe_Qcs5XioDkAs50DSXT-Pl4ibPLXyA0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1invngp2z_3ZMe_Qcs5XioDkAs50DSXT-Pl4ibPLXyA0/edit?usp=drivesdk",
          "cachedResultName": "Law Client Enquiries"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "mYRmmCMyWcLawmcE",
          "name": "Google Service Account account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "69795336-f1ce-4ce8-b7fc-4379418cb83e",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -528,
        256
      ],
      "parameters": {
        "text": "=<prompt>\n    <persona>\n        <name>Alex</name>\n        <role>Expert, friendly, and efficient legal intake assistant</role>\n        <company>VTR Law Firm</company>\n    </persona>\n\n    <client_info>\n        <name>{{ $json[\"Full Name\"] }}</name>\n        <service_interest>{{ $json[\"Legal Service of Interest\"] }}</service_interest>\n        <message>{{ $json[\"Brief Message\"] }}</message>\n    </client_info>\n\n    <task>\n        Draft a concise, professional, and welcoming WhatsApp message to the potential client using their submitted information.\n    </task>\n\n    <instructions>\n        <message_structure>\n            <item>Greet the client by their first name.</item>\n            <item>Thank them for contacting VTR Law Firm regarding their interest in the specified service.</item>\n            <item>Briefly acknowledge their message to show you've read it.</item>\n            <item>Inform them that the next step is a *complimentary consultation* to discuss their matter in more detail.</item>\n            <item>Provide a clear call to action to schedule the meeting using this link: https://calendly.com/vtr-law-firm/consultation</item>\n            <item>Sign off professionally with your name and the firm's name.</item>\n        </message_structure>\n    </instructions>\n\n    <output_constraints>\n        <rule>The output must be formatted as a single, average-sized WhatsApp message.</rule>\n        <rule>Use asterisks (*) for bolding key phrases.</rule>\n        <rule>Do not include the client's phone number or email address in your response.</rule>\n        <rule>Generate only the WhatsApp message text itself.</rule>\n    </output_constraints>\n\n    <example>\n        <description>Based on the instructions and sample data, the generated message should look like this.</description>\n        <output_message>\nHi Abhi,\n\nThank you for contacting VTR Law Firm about your query related to Business Law. I've reviewed the message you sent regarding the situation with your partner.\n\nThe best next step is to schedule a *complimentary, no-obligation consultation* with one of our legal experts to discuss this in more detail.\n\nYou can schedule a call with our legal executive by replying your available times\n\nWe look forward to speaking with you.\n\nBest regards,\nAlex | VTR Law Firm\n        </output_message>\n    </example>\n</prompt>",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "95a55ce6-3967-4a6b-ba11-57ba9c9d0998",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -528,
        528
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "qsaK3VMNWQDWLweQ",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b06b2984-c342-4db7-a46b-06679b0080db",
      "name": "WhatsApp 触发器",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        240,
        320
      ],
      "webhookId": "685f1ed2-ffac-460b-b2eb-b29891e539d4",
      "parameters": {
        "options": {
          "messageStatusUpdates": [
            "delivered"
          ]
        },
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "id": "iXRwfmH8WHEurWCh",
          "name": "WhatsApp OAuth account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "a715deb0-e11f-46df-b4ae-1cb4c214c183",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        496,
        320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c2380501-f59a-4075-b335-8ae3b7f64788",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.messages[0].text.body }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e157f8f8-f9da-4f03-baa3-114b199d36e0",
      "name": "获取用户询问日期的多个事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        976,
        544
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', ``, 'string') }}",
        "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "venkibvb5192@gmail.com",
          "cachedResultName": "venkibvb5192@gmail.com"
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "UMXPrV71iWBRBbyc",
          "name": "Google Calendar account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "a4b80f3b-caf8-40c7-b787-c090b5010755",
      "name": "创建事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1136,
        544
      ],
      "parameters": {
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "venkibvb5192@gmail.com",
          "cachedResultName": "venkibvb5192@gmail.com"
        },
        "additionalFields": {
          "summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}",
          "attendees": [
            "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('attendees0_Attendees', ``, 'string') }}"
          ],
          "description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}",
          "sendUpdates": "all",
          "guestsCanInviteOthers": true
        }
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "UMXPrV71iWBRBbyc",
          "name": "Google Calendar account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "937a57e5-4e9e-4302-99a7-e38ff770e453",
      "name": "Google Gemini 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        656,
        544
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "qsaK3VMNWQDWLweQ",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ed687b20-55af-41a3-b815-0044bf238692",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        912,
        336
      ],
      "parameters": {
        "text": "=<prompt>\n    <persona>\n        <name>Alex</name>\n        <role>Professional and friendly legal scheduling assistant</role>\n        <company>VTR Law Associates</company>\n    </persona>\n\n    <context>\n        <timestamp>\n            The current date and time is {{ $now.toFormat(\"DDDD, HH:mm:ss ZZZZ\") }}. You must use this information only to correctly interpret relative time requests from the user (like \"tomorrow,\" \"next Tuesday,\" or \"in two hours\").\n        </timestamp>\n    </context>\n\n    <instructions>\n        <task>\n            When a user wants to schedule a legal consultation, follow these steps precisely. Use the provided tools and context to answer the user's question.\n        </task>\n        \n        <procedure>\n            <step n=\"1\">\n                <description>Find User Details: First, use the 'Know about the user enquiry' tool to find the user's requirement details, such as their email address and the reason for their legal enquiry.</description>\n                <tool>Know about the user enquiry</tool>\n            </step>\n            \n            <step n=\"2\">\n                <description>Gather Missing Details: Ask the user for their preferred date and time for the consultation. If you could not find the user's email address in the previous step, politely ask for it now for the calendar invitation.</description>\n            </step>\n            \n            <step n=\"3\">\n                <description>Check Availability: Use the 'GET MANY EVENTS OF DAY THE USER ASKED' tool to check for existing events on the user's requested date.</description>\n                <tool>GET MANY EVENTS OF DAY THE USER ASKED</tool>\n            </step>\n            \n            <step n=\"4\">\n                <description>Handle the Outcome based on availability:</description>\n                <condition case=\"time available\">\n                    <action>Use the 'Create an event' tool. Set the event title to \"Legal Consultation - VTR Law Associates\" and add the user's email as an attendee.</action>\n                    <action>Confirm with the user that the consultation is successfully booked.</action>\n                    <tool>Create an event</tool>\n                </condition>\n                <condition case=\"time unavailable\">\n                    <action>Do not create an event.</action>\n                    <action>Inform the user that the requested time is booked and suggest specific alternative times based on the availability you found.</action>\n                </condition>\n            </step>\n        </procedure>\n        \n        <general_instruction>Handle greetings naturally without needing the context.</general_instruction>\n    </instructions>\n\n    <user_input>\n        <message>{{ $json.messages[0].text.body }}</message>\n    </user_input>\n\n    <output_format>\n        <style>WhatsApp</style>\n        <rules>\n            <rule>Use italics for emphasis.</rule>\n            <rule>Use bold for key points.</rule>\n            <rule>Use bullet lists (•) for lists.</rule>\n            <rule>Keep responses short, clear, and conversational.</rule>\n            <rule>Avoid markdown headers or code blocks.</rule>\n        </rules>\n    </output_format>\n\n    <constraints>\n        <fallback>\n            If the answer cannot be found in the context, reply: \"I'm sorry, my primary role is to schedule consultations. I don't have the information to answer that question.\"\n        </fallback>\n    </constraints>\n</prompt>",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "6cda0580-9e50-4406-a794-2d9315498f0e",
      "name": "Postgres 聊天记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        816,
        544
      ],
      "parameters": {
        "sessionKey": "={{ $('If').item.json.contacts[0].wa_id }}",
        "sessionIdType": "customKey"
      },
      "credentials": {
        "postgres": {
          "id": "B6Q3ACzgMJ6GYv3R",
          "name": "Postgres account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "4891245b-9402-44b6-8632-d6f1053a8f54",
      "name": "了解用户咨询",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1296,
        544
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Phone Number"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1invngp2z_3ZMe_Qcs5XioDkAs50DSXT-Pl4ibPLXyA0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1invngp2z_3ZMe_Qcs5XioDkAs50DSXT-Pl4ibPLXyA0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1invngp2z_3ZMe_Qcs5XioDkAs50DSXT-Pl4ibPLXyA0/edit?usp=drivesdk",
          "cachedResultName": "Law Client Enquiries"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "mYRmmCMyWcLawmcE",
          "name": "Google Service Account account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "3021dcef-b9ef-4a87-abe6-992081b72600",
      "name": "发送消息",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        -144,
        256
      ],
      "webhookId": "a823ba47-31b2-47e6-9668-9441566daa04",
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "838262432698376",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('Append or update row in sheet').item.json['Phone Number'] }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "fGqaO9SAj11hcCzx",
          "name": "WhatsApp account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6aad2ba5-1451-4150-b28a-f760061e8341",
      "name": "发送消息1",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1424,
        336
      ],
      "webhookId": "2b88030b-0e59-4b3a-8a97-0d1c81695f5b",
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "838262432698376",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "fGqaO9SAj11hcCzx",
          "name": "WhatsApp account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b90257f8-e8c0-4c63-9713-6052a9785d8f",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -352
      ],
      "parameters": {
        "width": 1136,
        "height": 1056,
        "content": "## 部分 A:新潜在客户接收和欢迎消息"
      },
      "typeVersion": 1
    },
    {
      "id": "b7acce1b-992f-42bc-b9f7-4ee7670b412e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -336
      ],
      "parameters": {
        "width": 1456,
        "height": 1056,
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "If": {
      "main": [
        [],
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Send message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message": {
      "main": [
        []
      ]
    },
    "Create an event": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "JotForm Trigger": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Know about the user enquiry": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET MANY EVENTS OF DAY THE USER ASKED": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类2
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流