Commit 43757f29 authored by 马超's avatar 马超

Upload New File

parent ec0820fc
{
"createdAt": "2025-02-13T05:26:27.831Z",
"updatedAt": "2025-04-07T11:29:34.000Z",
"id": "XOxxbzAyvGssVTZV",
"name": "webhook-theguardian",
"active": true,
"nodes": [
{
"parameters": {
"method": "POST",
"url": "http://172.31.0.160/v1/completion-messages",
"sendHeaders": true,
"specifyHeaders": "json",
"jsonHeaders": "{\n \"Authorization\": \"Bearer app-fxQiMsg03GrJCtwNfLRtnD4R\",\n \"Content-Type\": \"application/json\"\n}",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"inputs\": {\"record_json\":\"{{$json.text.replaceAll(/\"/g, '\\\\\"').replaceAll(/\\\\n/g, '')}}\",\"language\":\"中文\"},\n \"response_mode\": \"blocking\",\n \"user\": \"sl_backend_theguardian\"\n}",
"options": {}
},
"id": "2423e7cc-07ea-44a8-9c7f-482313383562",
"name": "dify",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
400,
280
]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nlet output_info = {};\nlet text_info = {};\ntitle = JSON.parse($input.item.json.body.info).title;\ncontent = JSON.parse($input.item.json.body.info).content;\ntext_info['title'] = title;\n//text_info['content'] = content;\noutput_info['text'] = JSON.stringify(text_info);\nreturn output_info;"
},
"id": "9584a3ec-017f-4f42-adb5-ecdfaa9cead6",
"name": "get_info",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
140,
280
]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\n//answer = \"```json{\\\"test1\\\":\\\"test\\\"}```\";\nfunction findAllIndexes(str, charToFind) {\n const regex = new RegExp(charToFind, 'g');\n let indexes = [];\n let result;\n while ((result = regex.exec(str)) !== null) {\n indexes.push(result.index);\n }\n return indexes;\n}\nfunction isValidJSON(str) {\n try {\n JSON.parse(str);\n return true;\n } catch (e) {\n return false;\n }\n}\nfunction autoCompleteJSON(str) {\n if (isValidJSON(str)) {\n return str;\n }\n let missing = '';\n if (!str.endsWith('\"}')) {\n missing += '\"}'\n }\n str = str+missing;\n return str;\n}\n// answer = $input.item.json.data.outputs.result.answer;\n// answer = $input.item.json.data.answer;\nanswer = $input.item.json.answer;\nanswer = answer.replaceAll(/\\n/g, '').replaceAll(/%s| /g, '');\nindexes = findAllIndexes(answer,\"```\");\nanswer_str = '';\nif(indexes.length>0){\n answer_str = answer.slice(indexes[0]+7, indexes[1]);\n}else{\n answer_str = answer;\n}\nanswer_str = answer_str.replace(/\\s+/g, '');\nanswer_data_json = JSON.parse(autoCompleteJSON(answer_str));\nanswer_data = {};\nanswer_data[\"answer\"] = answer_data_json;\nreturn answer_data;"
},
"id": "2d1dc138-7daf-4ed5-8d42-d5cd9ca46c1e",
"name": "get_answer",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
680,
280
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "START TRANSACTION;\n\nINSERT INTO news_source (topic,content,source_url,news_uid,status,language,snapshot,news_web,news_type) VALUES {{ $json.news_data }};\n\nSET @last_insert_id = LAST_INSERT_ID();\n\nINSERT INTO news_url (url, type,news_id)\nVALUES {{ $json.urls_data }};\n\nCOMMIT;",
"options": {}
},
"id": "6507e1ec-dd11-48d2-94f6-0dc4a2d57cd5",
"name": "insert_city_news",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
1200,
280
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nresult_data = $input.all();\ncontent_all = {};\nfor(let item_index =0; item_index < result_data.length;item_index++){\n item_data = result_data[item_index].json;\n if('answer' in item_data){\n content_all['answer'] = item_data['answer'];\n }\n}\n//console.log(content_all);\ninfo_data_list = JSON.parse($('Webhook').item.json.body.info);\nanswer_data = content_all.answer;\ninfo_data_list['title'] = answer_data.title;\n//info_data_list['content'] = answer_data.content;\noutput_all = [];\noutput_all_data = {};\noutput_news_data_str = \"\";\noutput_news_url_data_str = \"\";\nnews_item_data = \"\";\nnews_item_data = news_item_data+\"(\";\nnews_item_data += '\"'+info_data_list.title+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.content+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.url+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.id+'\"';\nnews_item_data += ',';\nnews_item_data += '\"4\"';\nnews_item_data += ',';\nnews_item_data += '\"zh_cn\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.html_url+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.news_web+'\"';\nnews_item_data += ',';\nnews_item_data += '\"'+info_data_list.type+'\"';\nnews_item_data += ')';\nimages_url = info_data_list.images_url;\nfor (let i = 0; i < images_url.length; i++) {\n image_url = images_url[i];\n image_item_data = \"(\";\n image_item_data += '\"'+image_url+'\"';\n image_item_data += ',';\n image_item_data += '0';\n image_item_data += ',';\n image_item_data += '@last_insert_id';\n image_item_data += '),';\n output_news_url_data_str += image_item_data;\n}\nif(output_news_url_data_str.length == 0){\n output_news_url_data_str = \"('','',''),\"\n}\noutput_all_data['urls_data'] = output_news_url_data_str.slice(0,output_news_url_data_str.length-1);\noutput_all_data['news_data'] = news_item_data;\noutput_all.push(output_all_data);\nreturn output_all;"
},
"id": "95f88b0d-d2bf-4c31-80cb-de4ccdf54cef",
"name": "get_city_news_sql",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
940,
280
]
},
{
"parameters": {
"httpMethod": "POST",
"path": "theguardian/translate/ch",
"authentication": "headerAuth",
"options": {
"allowedOrigins": "*",
"rawBody": false
}
},
"id": "e343ac73-8e4a-4d93-a4f1-4d5561e85d75",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-120,
280
],
"webhookId": "e495a29c-8f43-4175-bdb8-277e03b60b07",
"credentials": {
"httpHeaderAuth": {
"id": "U87Wvnvu9oQ5Zapo",
"name": "Header Auth account"
}
}
}
],
"connections": {
"dify": {
"main": [
[
{
"node": "get_answer",
"type": "main",
"index": 0
}
]
]
},
"get_info": {
"main": [
[
{
"node": "dify",
"type": "main",
"index": 0
}
]
]
},
"get_answer": {
"main": [
[
{
"node": "get_city_news_sql",
"type": "main",
"index": 0
}
]
]
},
"get_city_news_sql": {
"main": [
[
{
"node": "insert_city_news",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "get_info",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"meta": {
"templateCredsSetupCompleted": true
},
"pinData": {},
"versionId": "ecc05f57-c667-4542-8d91-4916590bc7ef",
"triggerCount": 1,
"shared": [
{
"createdAt": "2025-02-13T05:26:27.839Z",
"updatedAt": "2025-02-13T05:26:27.839Z",
"role": "workflow:owner",
"workflowId": "XOxxbzAyvGssVTZV",
"projectId": "C7zKoCDdmGgzUqSW",
"project": {
"createdAt": "2024-08-23T06:31:21.275Z",
"updatedAt": "2024-08-23T06:41:43.608Z",
"id": "C7zKoCDdmGgzUqSW",
"name": "周 卫 <zhouwei@ssish.com>",
"type": "personal",
"projectRelations": [
{
"createdAt": "2024-08-23T06:31:21.275Z",
"updatedAt": "2024-08-23T06:31:21.275Z",
"role": "project:personalOwner",
"userId": "3f0021b4-d0a7-4db6-af21-5ef829c47882",
"projectId": "C7zKoCDdmGgzUqSW",
"user": {
"createdAt": "2024-08-23T06:31:16.119Z",
"updatedAt": "2025-03-19T06:19:26.514Z",
"id": "3f0021b4-d0a7-4db6-af21-5ef829c47882",
"email": "zhouwei@ssish.com",
"firstName": "周",
"lastName": "卫",
"personalizationAnswers": {
"companyType": "education",
"role": "business-owner",
"automationBeneficiary": "my-team",
"companySize": "20-99",
"reportedSource": "friend",
"version": "v4",
"personalization_survey_submitted_at": "2024-08-23T06:57:52.856Z",
"personalization_survey_n8n_version": "1.55.3"
},
"settings": {
"userActivated": true,
"firstSuccessfulWorkflowId": "s6zsznwVs6N4L2Hx",
"userActivatedAt": 1725957335278,
"npsSurvey": {
"responded": true,
"lastShownAt": 1742365155724
},
"isOnboarded": true
},
"role": "global:owner",
"disabled": false,
"mfaEnabled": false,
"isPending": false,
"isOwner": true
}
}
]
}
}
],
"tags": []
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment