Commit e513e6e8 authored by 马超's avatar 马超

Upload New File

parent 3c2afb8d
{
"createdAt": "2025-04-02T09:53:30.470Z",
"updatedAt": "2025-04-07T10:06:47.000Z",
"id": "ZTzHvLotUJai7HJz",
"name": "tw_fy_ch",
"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, '\\\\\"')}}\",\"language\":\"中文\"},\n \"response_mode\": \"blocking\",\n \"user\": \"sl_backend_twitter\"\n}",
"options": {}
},
"id": "37b55ad2-8565-4359-a32e-e9562ffb1311",
"name": "translate_dify",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-280,
420
]
},
{
"parameters": {
"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 if (!str.includes('\"}') || (str.includes('\"}') && !str.endsWith('\"}'))) {\n str = str.replaceAll(\"}\",\"\");\n }\n str = retainSingleOccurrence(str,'}');\n // console.log(str);\n let missing = '';\n if (!str.endsWith('\"}')) {\n if (str.endsWith('\"')) {\n missing += '}'\n }else{\n missing += '\"}'\n }\n }\n str = str+missing;\n // console.log(str);\n return str;\n}\nfunction retainSingleOccurrence(str, subStr) {\n // 检查字符串是否包含子字符串\n if (!str.includes(subStr)) {\n return str;\n }\n // 使用正则表达式删除多余的子字符串\n // 使用全局匹配标志 g 和正则表达式来匹配所有子字符串\n // 注意:这里假设子字符串不会与其他文本重叠\n const regex = new RegExp(`(${subStr})(?=.*${subStr})`, 'g');\n let result = str.replace(regex, '');\n return result;\n}\n// answer =$input.all()[0].json.data.outputs.result.answer;\nanswer =$input.all()[0].json.answer;\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;\nconsole.log(answer_data_json);\nreturn answer_data;"
},
"id": "2d28fe0d-bfbe-4d7c-96a3-b4ea9ba59f05",
"name": "get_transter_answer",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-60,
420
]
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nlet output_info = {};\nlet text_info = {};\ninfo = $('Webhook').item.json.body.info.replace(/https:\\/\\/[^\\s]+/g, '').replaceAll(/[ \\t\\n\\r]+/g, ' ');\n// console.log(info);\noutput_info['text'] = info;\nreturn output_info;"
},
"id": "aab92007-74bf-44a0-a303-ae33f84e9bbf",
"name": "get_info",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-500,
420
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "CALL update_news_source_fy({{JSON.stringify($json.answer.toJsonString())}});",
"options": {}
},
"id": "6ab9f613-438d-4f0d-bcca-a60d40da793a",
"name": "update_news",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
160,
420
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"httpMethod": "POST",
"path": "twitter/search/fy",
"authentication": "headerAuth",
"options": {
"allowedOrigins": "*",
"rawBody": false
}
},
"id": "89e13d80-12a2-4fda-8fc4-66c32cb762a3",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-700,
420
],
"webhookId": "e495a29c-8f43-4175-bdb8-277e03b60b07",
"credentials": {
"httpHeaderAuth": {
"id": "U87Wvnvu9oQ5Zapo",
"name": "Header Auth account"
}
}
}
],
"connections": {
"translate_dify": {
"main": [
[
{
"node": "get_transter_answer",
"type": "main",
"index": 0
}
]
]
},
"get_info": {
"main": [
[
{
"node": "translate_dify",
"type": "main",
"index": 0
}
]
]
},
"get_transter_answer": {
"main": [
[
{
"node": "update_news",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "get_info",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"meta": {
"templateCredsSetupCompleted": true
},
"pinData": {},
"versionId": "09450941-639c-4e37-bb8e-a3d9d1a5cb69",
"triggerCount": 1,
"shared": [
{
"createdAt": "2025-04-02T09:53:30.479Z",
"updatedAt": "2025-04-02T09:53:30.479Z",
"role": "workflow:owner",
"workflowId": "ZTzHvLotUJai7HJz",
"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