Skip to content

Instantly share code, notes, and snippets.

@taktamur
Last active January 13, 2024 06:29
Show Gist options
  • Save taktamur/3219c70e1244a2f1935406b2ecccf1ab to your computer and use it in GitHub Desktop.
Save taktamur/3219c70e1244a2f1935406b2ecccf1ab to your computer and use it in GitHub Desktop.
zennのRSSを読み込んで、ChatGPTで要約したものをNotionに保存するn8nワークフロー

n8nのワークフローです。 ZennのRSSフィードを読み取って、ChatGPTで要約して、それをNotionに保存します。 すでに処理したフィードをスキップするため、先にNotionに保存されてる記事を取得してフィルタしています。 n8nはローカルで動かしてます。 image

{
"name": "zennのRSSフィードを要約してNotionに貯める",
"nodes": [
{
"parameters": {},
"id": "2af18bb2-3d04-4f9b-b31d-6ecfd7550830",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-60,
620
]
},
{
"parameters": {
"url": "https://zenn.dev/feed",
"options": {}
},
"id": "e11b719d-9258-4787-8f1c-dfaa7bb7b54e",
"name": "RSS Read",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
320,
900
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "url",
"stringValue": "={{ $json.property_url }}"
}
]
},
"include": "none",
"options": {}
},
"id": "30f6980e-6f67-4d51-ba86-dcc4eb50546b",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
800,
540
]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.url }}",
"operation": "notEqual",
"value2": "={{ null }}"
}
]
}
},
"id": "eb10feff-81b8-4655-845f-4588221bc726",
"name": "Filter",
"type": "n8n-nodes-base.filter",
"typeVersion": 1,
"position": [
1020,
540
]
},
{
"parameters": {},
"id": "1de423bb-48f1-4e32-abe4-9a0274717448",
"name": "Remove Duplicates",
"type": "n8n-nodes-base.removeDuplicates",
"typeVersion": 1,
"position": [
1240,
540
]
},
{
"parameters": {
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "url",
"renameField": true,
"outputFieldName": "postedUrl"
}
]
},
"options": {}
},
"id": "7112b29a-36bc-4f87-a96e-bbb47ca64a26",
"name": "Aggregate",
"type": "n8n-nodes-base.aggregate",
"typeVersion": 1,
"position": [
1460,
540
]
},
{
"parameters": {
"mode": "combine",
"combinationMode": "multiplex",
"options": {}
},
"id": "37dd5f64-9546-4662-bd98-cf4f9ab23aa3",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 2.1,
"position": [
700,
880
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.postedUrl.join() }}",
"operation": "notContains",
"value2": "={{ $json.link }}"
}
]
}
},
"id": "bfc9bf49-bdf0-4349-819e-a45bc1f9df1b",
"name": "Filter1",
"type": "n8n-nodes-base.filter",
"typeVersion": 1,
"position": [
880,
880
]
},
{
"parameters": {
"maxItems": 10
},
"id": "182f9e0c-8868-4cd7-8d1e-9d4537468057",
"name": "Limit",
"type": "n8n-nodes-base.limit",
"typeVersion": 1,
"position": [
1120,
820
]
},
{
"parameters": {
"include": "selected",
"includeFields": "title, link",
"options": {}
},
"id": "46ad9d4c-1699-4c30-9cc3-0f542997a0dc",
"name": "Edit Fields1",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
1340,
880
]
},
{
"parameters": {
"url": "={{ $json.link }}",
"options": {}
},
"id": "4ec884b6-6929-4911-bb55-ae54b65a2426",
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
1600,
1040
]
},
{
"parameters": {
"operation": "extractHtmlContent",
"extractionValues": {
"values": [
{
"key": "content",
"cssSelector": "body"
}
]
},
"options": {}
},
"id": "e23a7326-db33-435d-99b4-52c544b41739",
"name": "HTML",
"type": "n8n-nodes-base.html",
"typeVersion": 1,
"position": [
1760,
1040
]
},
{
"parameters": {
"model": "gpt-3.5-turbo-16k",
"options": {}
},
"id": "59c59260-82da-4567-ac3e-eac7316dc350",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
2240,
1220
],
"credentials": {
"openAiApi": {
"id": "u5LwtvWwuyhxLceo",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"mode": "combine",
"combinationMode": "mergeByPosition",
"options": {}
},
"id": "f3848473-1541-4a36-94dd-e12a05ba4a6c",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 2.1,
"position": [
2680,
900
]
},
{
"parameters": {
"content": "## Notionにためたフィードを取得\n",
"height": 266.5400181902309,
"width": 1200.551275111922
},
"id": "ad74285f-de2c-4865-ae00-df2db1f04663",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
460,
460
]
},
{
"parameters": {
"content": "## RSSフィードで未投稿のものを選ぶ",
"height": 284.86927937521807,
"width": 955.467222366114
},
"id": "8639347e-f2c1-4f41-b17e-3fd7353637c8",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
540,
800
]
},
{
"parameters": {
"content": "## 記事内容を拾ってきて、ChatGPTで要約\n",
"height": 386.11464103080027,
"width": 974.7235372203093
},
"id": "7041ceb5-3536-42da-b157-856ace3293c7",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
1580,
960
]
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "hours"
}
]
}
},
"id": "8da2af8a-b7cd-4d06-8d15-8ca84d0e4f6c",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.1,
"position": [
-40,
820
]
},
{
"parameters": {},
"id": "ee8547b3-7b75-48af-b6b5-4f30ff7d1a71",
"name": "No Operation, do nothing",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
180,
680
]
},
{
"parameters": {
"content": "## Notionに保存",
"height": 298.51576594099606,
"width": 587.0854824728408
},
"id": "1f1e177c-b950-401b-95c2-fc99b94f9e76",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2600,
800
]
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.content = item.json.content.substr(0,15000);\n}\n\nreturn $input.all();"
},
"id": "81615928-337f-473f-b530-3d317dbf8dc5",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1960,
1040
]
},
{
"parameters": {
"resource": "databasePage",
"operation": "getAll",
"databaseId": {
"__rl": true,
"value": "62e5ec7a-bee3-4bf8-8787-ff0080a1a63d",
"mode": "list",
"cachedResultName": "ChatGPTで要約したRSSフィード",
"cachedResultUrl": "https://www.notion.so/62e5ec7abee34bf88787ff0080a1a63d"
},
"limit": 100,
"options": {}
},
"id": "3ef168fb-47af-45e5-a528-0c9b9f5da246",
"name": "Notion",
"type": "n8n-nodes-base.notion",
"typeVersion": 2.1,
"position": [
540,
540
],
"credentials": {
"notionApi": {
"id": "6vBcyrYJGnylGNya",
"name": "Notion account"
}
}
},
{
"parameters": {
"resource": "databasePage",
"databaseId": {
"__rl": true,
"value": "62e5ec7a-bee3-4bf8-8787-ff0080a1a63d",
"mode": "list",
"cachedResultName": "ChatGPTで要約したRSSフィード",
"cachedResultUrl": "https://www.notion.so/62e5ec7abee34bf88787ff0080a1a63d"
},
"propertiesUi": {
"propertyValues": [
{
"key": "summary|rich_text",
"textContent": "={{ $json.text }}"
},
{
"key": "title|title",
"title": "={{ $json.title }}"
},
{
"key": "URL|url",
"urlValue": "={{ $json.link }}"
}
]
},
"options": {}
},
"id": "47635148-cef4-496d-8761-7571ca680ed0",
"name": "Notion1",
"type": "n8n-nodes-base.notion",
"typeVersion": 2.1,
"position": [
2900,
900
],
"credentials": {
"notionApi": {
"id": "6vBcyrYJGnylGNya",
"name": "Notion account"
}
}
},
{
"parameters": {
"prompt": "={{ $json.content }}",
"messages": {
"messageValues": [
{
"message": "この文章を200文字程度に要約してください。"
}
]
}
},
"id": "95c7ec3f-8ed3-438e-ac13-95a098dc8884",
"name": "Basic LLM Chain",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"typeVersion": 1.2,
"position": [
2180,
1040
]
}
],
"pinData": {},
"connections": {
"Edit Fields": {
"main": [
[
{
"node": "Filter",
"type": "main",
"index": 0
}
]
]
},
"Filter": {
"main": [
[
{
"node": "Remove Duplicates",
"type": "main",
"index": 0
}
]
]
},
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicates": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"RSS Read": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Filter1",
"type": "main",
"index": 0
}
]
]
},
"Filter1": {
"main": [
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "HTML",
"type": "main",
"index": 0
}
]
]
},
"HTML": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Basic LLM Chain",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Notion1",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"No Operation, do nothing": {
"main": [
[
{
"node": "RSS Read",
"type": "main",
"index": 0
},
{
"node": "Notion",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Basic LLM Chain",
"type": "main",
"index": 0
}
]
]
},
"Notion": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Basic LLM Chain": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "9a587e1d-76ed-41b5-9c00-bc976e7f20c7",
"id": "ZjCqfMZbx0VgTRY1",
"meta": {
"instanceId": "81881e26d076ee76d90287e5213f613ae8cf6f0d305acb26303262e8d8243289"
},
"tags": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment