Publish Image Post to Bluesky
工作流概述
这是一个包含15个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "XGFs5jZNCeURd4OT",
"meta": {
"instanceId": "c5e9c1178f3b42f080c51c81bcfa62e1fbd48abf38103a7a4cd8e15abc64df08",
"templateCredsSetupCompleted": true
},
"name": "Publish Image Post to Bluesky",
"tags": [],
"nodes": [
{
"id": "afd666fc-8f79-488d-a295-4bfdd6883924",
"name": "When clicking ‘Test workflow’",
"type": "n8n-nodes-base.manualTrigger",
"position": [
35,
260
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d31bfe18-5acc-4f72-80d0-d85111dd62cc",
"name": "Create Bluesky Session",
"type": "n8n-nodes-base.httpRequest",
"position": [
435,
260
],
"parameters": {
"url": "https://bsky.social/xrpc/com.atproto.server.createSession",
"method": "POST",
"options": {},
"jsonBody": "={{ $('Define Credentials').item.json.credentials }}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "514ac077-3c96-41f0-b178-afefe2f9faae",
"name": "Download Images",
"type": "n8n-nodes-base.httpRequest",
"position": [
1260,
260
],
"parameters": {
"url": "={{ $json.url }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "67e77e91-3a53-44c3-a474-2cd3b4977cf2",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
1580,
260
],
"parameters": {
"jsCode": "return $input.all().map( item => ({
alt: \"-\",
image: {
...item.json.blob
}
}));"
},
"typeVersion": 2
},
{
"id": "b8540b04-afe8-4455-8fec-fcab5ffff1ae",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
102.39520958083813
],
"parameters": {
"color": 4,
"width": 391.0892880786254,
"height": 335.5179928232044,
"content": "## Define Your Post Caption Here
You can set
* the text caption of your post (max 300 characters)
* image URLs (max of 4 images at 1MB each)"
},
"typeVersion": 1
},
{
"id": "2a6e60ef-4042-4648-85bb-143d226aa736",
"name": "Split Out",
"type": "n8n-nodes-base.splitOut",
"position": [
1100,
260
],
"parameters": {
"options": {},
"fieldToSplitOut": "photos"
},
"typeVersion": 1
},
{
"id": "5c3a6c2f-7b60-4448-9d85-4174e9f5f770",
"name": "Post to Bluesky",
"type": "n8n-nodes-base.httpRequest",
"position": [
1940,
260
],
"parameters": {
"url": "https://bsky.social/xrpc/com.atproto.repo.createRecord",
"method": "POST",
"options": {},
"jsonBody": "={
\"repo\": \"{{ $('Create Bluesky Session').item.json.did }}\",
\"collection\": \"app.bsky.feed.post\",
\"record\": {
\"$type\": \"app.bsky.feed.post\",
\"text\": \"{{ $('Set Caption').item.json['Post Text'].trim()}}\",
\"createdAt\": \"{{ $now }}\",
\"embed\": {
\"$type\": \"app.bsky.embed.images\",
\"images\":{{ $('Aggregate').item.json.data.toJsonString() }}
}
}
}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "=Bearer {{ $('Create Bluesky Session').item.json.accessJwt }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "266ef5cb-18df-45b0-b5c4-59782e571d40",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
180,
-2.994011976047659
],
"parameters": {
"color": 3,
"width": 418.7983637184758,
"height": 440.36620487216396,
"content": "## Set Bluesky Credentials
You'll need to set 2 values...
1. _Identifier_
This is your Bluesky username, e.g. \"username.bsky.social\"
2. _App Password_
This is _not_ your sign-in password, but something created in [your Bluesky account](https://bsky.app/settings/app-passwords)
A Bluesky session is then opened for image uploading and posting."
},
"typeVersion": 1
},
{
"id": "3a7fc037-02f6-4091-bcdc-5b22d43269ef",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1063.9520958083824,
160
],
"parameters": {
"color": 7,
"width": 814.7806424732389,
"height": 269.1258097879526,
"content": "### Handling image attachments
Bluesky doesn't attach images directly to the post, they're first individually uploaded [then embedded in the post](https://docs.bsky.app/docs/tutorials/creating-a-post#images-embeds)."
},
"typeVersion": 1
},
{
"id": "aa7796b3-9cc7-4219-85af-a9ae3613f891",
"name": "Define Credentials",
"type": "n8n-nodes-base.set",
"position": [
235,
260
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "{\"credentials\":
{
\"identifier\": \"username.bsky.social\",
\"password\": \"XXXX-YYYY-ZZZZ-XXXX\"
}
}"
},
"typeVersion": 3.4
},
{
"id": "4bcf77ef-b40e-485e-b444-659f77cf9d69",
"name": "Aggregate",
"type": "n8n-nodes-base.aggregate",
"position": [
1740,
260
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "eb2730e5-cad7-47f0-96d2-f2ae1dee6dd5",
"name": "Set Images",
"type": "n8n-nodes-base.set",
"position": [
880,
260
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "{ \"photos\":[
{
\"url\":\"https://picsum.photos/800/600?random=234234\"
},
{
\"url\":\"https://picsum.photos/800/600?random=676855\"
},
{
\"url\":\"https://picsum.photos/800/600?random=4564\"
},
{
\"url\":\"https://picsum.photos/800/600?random=12124\"
}
]}"
},
"typeVersion": 3.4
},
{
"id": "0d3a030e-1ac6-420d-a850-d267928f4072",
"name": "Post Image to Bluesky",
"type": "n8n-nodes-base.httpRequest",
"position": [
1420,
260
],
"parameters": {
"url": "https://bsky.social/xrpc/com.atproto.repo.uploadBlob",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "binaryData",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "=Bearer {{ $('Create Bluesky Session').item.json.accessJwt }}"
}
]
},
"inputDataFieldName": "data"
},
"typeVersion": 4.2
},
{
"id": "31124777-ee35-4ceb-b0e7-75f7cef4b481",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
-260
],
"parameters": {
"width": 880.0000000000002,
"height": 207.9041916167665,
"content": "# Create a new post with images on Bluesky
This workflow will
1. retrieve images from URLs you specify
2. upload them 1 by 1 as blobs to BlueSky
3. let you specify the basic text of a post
3. use your Bluesky credentials to post to your feed"
},
"typeVersion": 1
},
{
"id": "f8e54515-c9ec-474d-aa2b-fe357cbd4775",
"name": "Set Caption",
"type": "n8n-nodes-base.set",
"position": [
688,
260
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "6135981d-82d9-47bb-9eb5-ce9a4220f108",
"name": "Caption Text",
"type": "string",
"value": "Here is the amazing content of my post, max of 300 characters!"
}
]
}
},
"typeVersion": 3.4
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "86d8df08-3f73-40a5-9c5b-d2ebda3f3b13",
"connections": {
"Code": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Post to Bluesky",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Download Images",
"type": "main",
"index": 0
}
]
]
},
"Set Images": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Set Caption": {
"main": [
[
{
"node": "Set Images",
"type": "main",
"index": 0
}
]
]
},
"Download Images": {
"main": [
[
{
"node": "Post Image to Bluesky",
"type": "main",
"index": 0
}
]
]
},
"Define Credentials": {
"main": [
[
{
"node": "Create Bluesky Session",
"type": "main",
"index": 0
}
]
]
},
"Post Image to Bluesky": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Create Bluesky Session": {
"main": [
[
{
"node": "Set Caption",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Test workflow’": {
"main": [
[
{
"node": "Define Credentials",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Manualtrigger
- Httprequest
- Code
- Stickynote
- Splitout
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的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错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作