Send Discord message from Webflow form submission
工作流概述
这是一个包含13个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "cGTxHYV93kS71hLL",
"meta": {
"instanceId": "f0243439e79874c29f002782f736673d3388e5328a2ff2db7dd45820643256f5"
},
"name": "Send Discord message from Webflow form submission",
"tags": [
{
"id": "7cKuF8oYmXKMRDsD",
"name": "webflow",
"createdAt": "2024-01-09T02:22:11.773Z",
"updatedAt": "2024-01-09T02:22:11.773Z"
},
{
"id": "3Rn4VbTINmdaOxoY",
"name": "discord",
"createdAt": "2024-01-16T06:00:48.375Z",
"updatedAt": "2024-01-16T06:00:48.375Z"
}
],
"nodes": [
{
"id": "5de5b2ea-5257-4782-8f11-ea9c746083eb",
"name": "Does the channel exist?",
"type": "n8n-nodes-base.if",
"position": [
1420,
360
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b8fa7e94-ea10-40f0-ab0c-795620a5ee60",
"operator": {
"type": "object",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.channel }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "325ac193-b72f-4753-8d74-4e3d5cd5172c",
"name": "Transform data to send message",
"type": "n8n-nodes-base.set",
"position": [
1880,
540
],
"parameters": {
"fields": {
"values": [
{
"name": "formData",
"type": "objectValue",
"objectValue": "={{ $('Filter existing Discord channel').item.json.formData }}"
},
{
"name": "formName",
"stringValue": "={{ $('Filter existing Discord channel').item.json.formName }}"
},
{
"name": "channel",
"type": "objectValue",
"objectValue": "={\"id\":\"{{ $json.id }}\", \"name\": \"{{ $json.name }}\" }"
}
]
},
"include": "none",
"options": {
"dotNotation": true
}
},
"typeVersion": 3.2
},
{
"id": "1f084545-53a6-4460-81bb-d5109cb06db4",
"name": "Webflow Form Submission Trigger",
"type": "n8n-nodes-base.webflowTrigger",
"position": [
780,
360
],
"webhookId": "4f11dae8-d23f-43c7-992b-04460b38f488",
"parameters": {
"site": "60e6f0f07c46af62aa2b1c98"
},
"credentials": {
"webflowApi": {
"id": "Nuq6n7zNYTp6iS2m",
"name": "Webflow Tutum Access"
}
},
"typeVersion": 1
},
{
"id": "a6076ef4-5b8a-45dc-8f44-02ccf9d2ba34",
"name": "Compose Slack message",
"type": "n8n-nodes-base.code",
"position": [
2140,
340
],
"parameters": {
"jsCode": "const webflowFormData = $input.all()[0].json.formData;
const objectToMarkdown = (obj) => {
return Object.entries(obj)
.map(([key, value]) => `**${key}**: ${value}`)
.join('\n');
}
const discordChannelMessage = {
\"content\": `New form submission: \n ${objectToMarkdown(webflowFormData)}`
};
const data = {...$input.all()[0].json, discordChannelMessage: discordChannelMessage};
return data;
"
},
"typeVersion": 2
},
{
"id": "76dd8d4f-5b65-4171-a921-9d32a8e5c893",
"name": "List Discord Channels",
"type": "n8n-nodes-base.discord",
"position": [
1000,
360
],
"parameters": {
"guildId": {
"__rl": true,
"mode": "list",
"value": "987961215550623794",
"cachedResultUrl": "https://discord.com/channels/987961215550623794",
"cachedResultName": "kreonovo"
},
"options": {},
"operation": "getAll"
},
"credentials": {
"discordBotApi": {
"id": "rAP7e9I0RHBsnq7Y",
"name": "Discord Bot KN"
}
},
"typeVersion": 2
},
{
"id": "7551d395-6364-4d28-b778-c2a16b04db96",
"name": "Filter existing Discord channel",
"type": "n8n-nodes-base.code",
"position": [
1200,
360
],
"parameters": {
"jsCode": "
const transformedFormName = (inputString)=> {
// Convert to lowercase
const lowercaseString = inputString.toLowerCase();
// Split by space
const wordsArray = lowercaseString.split(' ');
// Join with hyphens
const resultString = wordsArray.join('-');
return resultString;
}
const currentForm = transformedFormName($('Webflow Form Submission Trigger').all()[0].json[\"name\"]);
const doesChannelExist = (channelName)=> {
return channelName == currentForm
}
let channels = [];
for (const item of $input.all()) {
let channel = {
name: item.json[\"name\"],
id: item.json[\"id\"],
channelExists: doesChannelExist(item.json[\"name\"]),
};
channels.push(channel);
}
let data = [ {
channel: channels.filter((c)=>{return c.channelExists === true})[0],
formName: currentForm,
formData: $('Webflow Form Submission Trigger').all()[0].json[\"data\"]
}
]
return data;"
},
"typeVersion": 2
},
{
"id": "df38e67b-f76d-4b43-8da4-8e39230a5d0a",
"name": "Create Discord channel with form name",
"type": "n8n-nodes-base.discord",
"position": [
1640,
540
],
"parameters": {
"name": "={{ $json.formName }}",
"guildId": {
"__rl": true,
"mode": "list",
"value": "987961215550623794",
"cachedResultUrl": "https://discord.com/channels/987961215550623794",
"cachedResultName": "kreonovo"
},
"options": {}
},
"credentials": {
"discordBotApi": {
"id": "rAP7e9I0RHBsnq7Y",
"name": "Discord Bot KN"
}
},
"typeVersion": 2
},
{
"id": "8a4fb8af-f156-48cf-b6cd-52235ced1de9",
"name": "Notify #general channel of newly created channel1",
"type": "n8n-nodes-base.discord",
"position": [
1880,
780
],
"parameters": {
"content": "=A new channel was created <#{{ $json['id'] }}>",
"guildId": {
"__rl": true,
"mode": "list",
"value": "987961215550623794",
"cachedResultUrl": "https://discord.com/channels/987961215550623794",
"cachedResultName": "kreonovo"
},
"options": {},
"resource": "message",
"channelId": {
"__rl": true,
"mode": "list",
"value": "987961215550623797",
"cachedResultUrl": "https://discord.com/channels/987961215550623794/987961215550623797",
"cachedResultName": "general"
}
},
"credentials": {
"discordBotApi": {
"id": "rAP7e9I0RHBsnq7Y",
"name": "Discord Bot KN"
}
},
"typeVersion": 2
},
{
"id": "1c1a20ee-303e-4015-9465-9674f17fca46",
"name": "Send form submission to Discord channel",
"type": "n8n-nodes-base.discord",
"position": [
2360,
340
],
"parameters": {
"content": "={{ $json.discordChannelMessage.content }}",
"guildId": {
"__rl": true,
"mode": "list",
"value": "987961215550623794",
"cachedResultUrl": "https://discord.com/channels/987961215550623794",
"cachedResultName": "kreonovo"
},
"options": {},
"resource": "message",
"channelId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.channel.id }}"
}
},
"credentials": {
"discordBotApi": {
"id": "rAP7e9I0RHBsnq7Y",
"name": "Discord Bot KN"
}
},
"typeVersion": 2
},
{
"id": "8e7f2f57-b6eb-4b34-84d4-e61f24e0cdf9",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
20,
200
],
"parameters": {
"color": 6,
"width": 624.279069767441,
"height": 535.976744186046,
"content": "# Manage Webflow form submissions in Discord
## Full guide with video
[Full guide with video here](https://blog.kreonovo.co.za/send-webflow-form-submissions-to-discord-server/)
This workflow dynamically creates Discord channels for your Webflow forms then sends form submissions to those channels. The Webflow form name is used to make the channel name.
## Getting started
1. Create Webflow credential using API V1 Token
2. Create Discord credentials using Bot API by making an application [Your applications in Discord](https://discord.com/developers/applications) for a detailed list of scopes for your application please see the video guide above.
3. Connect your credentials to the relevant nodes on the canvas.
4. Activate the workflow and submit a form on your Webflow site
That's it! You do not need to add any custom code to your Webflow forms or site.
The name of your forms in the form settings section of the Designer in Webflow will be used to create the Discord channels. This workflow will automatically do this for you.
"
},
"typeVersion": 1
},
{
"id": "fc1ce7a7-ae13-447c-9c60-c8b082fb2b70",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
2080,
242.97574123989227
],
"parameters": {
"width": 224.58139534883728,
"height": 296.44286341127054,
"content": "### Format the message
Discord accepts Markdown"
},
"typeVersion": 1
},
{
"id": "154a43e0-6967-4307-b9d2-c30be6dae84a",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1320,
740
],
"parameters": {
"width": 323.0232558139535,
"height": 304.69767441860455,
"content": "### False branch
We create a new Discord channel using the form name in Webflow. Channel names must be converted to lowercase and words separated with dash.
When the new channel is created we send a message in the #general channel with a direct link to the new channel.
Finally we send the Webflow form submission as a message in the new channel."
},
"typeVersion": 1
},
{
"id": "f668884a-b6fe-4abd-bf6f-dd45986235bf",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1160,
160
],
"parameters": {
"width": 224.58139534883728,
"height": 393.9954240581709,
"content": "### Combining data to move forward
This code will check if a channel with the form name exists in Discord.
We also create an object to pass forward to the next node."
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "677986e6-bdc4-4e4d-92ee-568385174325",
"connections": {
"Compose Slack message": {
"main": [
[
{
"node": "Send form submission to Discord channel",
"type": "main",
"index": 0
}
]
]
},
"List Discord Channels": {
"main": [
[
{
"node": "Filter existing Discord channel",
"type": "main",
"index": 0
}
]
]
},
"Does the channel exist?": {
"main": [
[
{
"node": "Compose Slack message",
"type": "main",
"index": 0
}
],
[
{
"node": "Create Discord channel with form name",
"type": "main",
"index": 0
}
]
]
},
"Transform data to send message": {
"main": [
[
{
"node": "Compose Slack message",
"type": "main",
"index": 0
}
]
]
},
"Filter existing Discord channel": {
"main": [
[
{
"node": "Does the channel exist?",
"type": "main",
"index": 0
}
]
]
},
"Webflow Form Submission Trigger": {
"main": [
[
{
"node": "List Discord Channels",
"type": "main",
"index": 0
}
]
]
},
"Create Discord channel with form name": {
"main": [
[
{
"node": "Transform data to send message",
"type": "main",
"index": 0
},
{
"node": "Notify #general channel of newly created channel1",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- If
- Set
- Webflowtrigger
- Code
- Discord
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作