diff --git a/20250409/tw_search_do_label.json b/20250409/tw_search_do_label.json new file mode 100644 index 0000000000000000000000000000000000000000..9e014ddb366c5f74e4e29f4af4ebe375a51401c1 --- /dev/null +++ b/20250409/tw_search_do_label.json @@ -0,0 +1,277 @@ +{ + "createdAt": "2025-04-07T09:07:55.439Z", + "updatedAt": "2025-04-09T06:41:33.000Z", + "id": "OkLNJG1HWObUFcS0", + "name": "tw_search_do_label", + "active": true, + "nodes": [ + { + "parameters": { + "operation": "executeQuery", + "query": "CALL do_label_news_source({{ JSON.stringify(JSON.stringify($json.news_id))}},{{ JSON.stringify(JSON.stringify($json.label_data)) }},{{ JSON.stringify(JSON.stringify($json.artificial_label_data)) }});", + "options": {} + }, + "id": "3fd1cd68-88f3-4d6f-91e8-a08b6acf2c10", + "name": "insert_city_news", + "type": "n8n-nodes-base.mySql", + "typeVersion": 2.4, + "position": [ + 740, + 480 + ], + "credentials": { + "mySql": { + "id": "09oRI0DULmEzD9l8", + "name": "SL-DB" + } + } + }, + { + "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('label_data' in item_data){\n content_all['label'] = item_data['label_data'];\n }else if('artificial_label_data' in item_data){\n content_all['artificial_label'] = item_data['artificial_label_data'];\n }\n};\n// console.log(content_all);\ninfo_data_list = JSON.parse($('Webhook').all()[0].json.body.info);\nschedule_id = $('Webhook').all()[0].json.body.schedule_id;\nlabel_data_list = content_all.label;\nartificial_label_data_list = content_all.artificial_label;\nif(artificial_label_data_list.length>0){\n artificial_label_data_list[0]['city_code'] = info_data_list.city_code;\n}\nfunction isEmptyString(value) {\n // 方法1: 直接检查是å¦ä¸ºç©ºå—符串或null\n if (!value || value.trim() == '' || value.trim() == 'null' || value.trim() == 'None') {\n return true;\n }\n return false;\n};\noutput_all = [];\noutput_all_data_temp = {};\noutput_all_data_temp['news_id'] = info_data_list.id;\noutput_all_data_temp['label_data'] = label_data_list;\noutput_all_data_temp['artificial_label_data'] = artificial_label_data_list;\noutput_all.push(output_all_data_temp);\nconsole.log(JSON.stringify(JSON.stringify(info_data_list.id)));\nconsole.log(JSON.stringify(JSON.stringify(label_data_list)));\nconsole.log(JSON.stringify(JSON.stringify(artificial_label_data_list)));\nreturn output_all;" + }, + "id": "6436c8a9-c437-47cf-9788-b0a3cee9a010", + "name": "get_city_news_sql", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 500, + 480 + ] + }, + { + "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 isEmptyString(value) {\n // 方法1: 直接检查是å¦ä¸ºç©ºå—符串或null\n if (!value || value.trim() === '') {\n return true;\n }\n return false;\n};\nfunction isEmpty(value) {\n // 方法1: 直接检查是å¦ä¸ºç©ºå—符串或null\n if (!value) {\n return true;\n }\n return false;\n};\nlabel_data_list = [];\nartificial_label_data_list = [];\nlabel_data_arr = $input.all();\nlabel_result_list = [];\nartificial_label_result_list = [];\nfor(var label_index=0;label_index<label_data_arr.length;label_index++){\n label_data_temp = label_data_arr[label_index];\n workflow_id = label_data_temp.json.data.workflow_id;\n label_data_output_list = label_data_temp.json.data.outputs;\n if(workflow_id == '944449cb-15ad-4648-b3b0-3f103f574e09'){\n if(!isEmpty(label_data_output_list)){\n label_result = label_data_output_list.result;\n for (let i = 0; i < label_result.length; i++) {\n label_result_list.push(label_result[i]);\n }\n }\n }else{\n if(!isEmpty(label_data_output_list)){\n label_result = label_data_output_list.result;\n let label_index_temp = 0;\n for (let i = 0; i < label_result.length&&label_index_temp<1; i++) {\n artificial_label_result_list.push(label_result[i]);\n label_index_temp += 1;\n }\n } \n }\n};\n// console.log(label_result_list);\nfor (let i = 0; i < label_result_list.length; i++) {\n label_code_score = {};\n label_code = label_result_list[i].code;\n // label_score = label_result_list[i].score;\n label_score = \"\";\n if(!isEmptyString(label_code)){\n label_code_score['code'] = label_code;\n label_code_score['score'] = label_score;\n label_data_list.push(label_code_score);\n }\n};\nfor (let i = 0; i < artificial_label_result_list.length; i++) {\n label_code_score = {};\n label_code = artificial_label_result_list[i].code;\n label_name = artificial_label_result_list[i].name;\n // label_score = artificial_label_result_list[i].score;\n label_score = \"\";\n if(!isEmptyString(label_code)){\n label_code_score['code'] = label_code;\n label_code_score['name'] = label_name;\n label_code_score['score'] = label_score;\n artificial_label_data_list.push(label_code_score);\n }\n};\nlabel_data_list_2 = [];\nlabel_data_json = {};\nartificial_label_data_json = {};\nlabel_data_json[\"label_data\"] = label_data_list;\nartificial_label_data_json[\"artificial_label_data\"] = artificial_label_data_list;\n// console.log(label_data_json);\nlabel_data_list_2.push(label_data_json);\nlabel_data_list_2.push(artificial_label_data_json);\nreturn label_data_list_2;" + }, + "id": "7e8a796a-87be-4f77-8229-793308c14cf4", + "name": "get_label_answer", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 240, + 480 + ] + }, + { + "parameters": { + "method": "POST", + "url": "http://172.31.0.160/v1/workflows/run", + "sendHeaders": true, + "specifyHeaders": "json", + "jsonHeaders": "{\n \"Authorization\": \"Bearer app-KNq0O8kENP4ITqSmqHQ0IzAt\",\n \"Content-Type\": \"application/json\"\n}", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"inputs\": {\"msg_info\":\"{{JSON.stringify(JSON.parse($json.body.info).full_text).replaceAll(/\"/g, '\\\\\"')}}\"},\n \"response_mode\": \"blocking\",\n \"user\": \"sl_backend_twitter\"\n}", + "options": {} + }, + "id": "ffc27f68-095e-412e-9262-a5cbca9257a5", + "name": "news_label_dify", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + -480, + 740 + ] + }, + { + "parameters": { + "method": "POST", + "url": "http://172.31.0.160/v1/workflows/run", + "sendHeaders": true, + "specifyHeaders": "json", + "jsonHeaders": "{\n \"Authorization\": \"Bearer app-HCbsiZmUCzP8Vdqb2meKXQSb\",\n \"Content-Type\": \"application/json\"\n}", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={\n \"inputs\": {\"msg_info\":\"{{JSON.stringify(JSON.parse($json.body.info).full_text).replaceAll(/\"/g, '\\\\\"')}}\"},\n \"response_mode\": \"blocking\",\n \"user\": \"sl_backend_twitter\"\n}", + "options": {} + }, + "id": "f9bce107-2aaf-486d-85dd-c99756e07f2c", + "name": "artifi_nature_label_dify", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + -480, + 260 + ] + }, + { + "parameters": {}, + "id": "008410d0-9f2a-4848-b2d3-411b774f4cca", + "name": "merge_label", + "type": "n8n-nodes-base.merge", + "typeVersion": 3, + "position": [ + 0, + 480 + ] + }, + { + "parameters": { + "httpMethod": "POST", + "path": "twitter/search/label", + "authentication": "headerAuth", + "options": { + "allowedOrigins": "*", + "rawBody": false + } + }, + "id": "f11677ff-bb2f-4c0a-b97b-774a0f70121e", + "name": "Webhook", + "type": "n8n-nodes-base.webhook", + "typeVersion": 2, + "position": [ + -940, + 520 + ], + "webhookId": "e495a29c-8f43-4175-bdb8-277e03b60b07", + "credentials": { + "httpHeaderAuth": { + "id": "U87Wvnvu9oQ5Zapo", + "name": "Header Auth account" + } + } + } + ], + "connections": { + "get_city_news_sql": { + "main": [ + [ + { + "node": "insert_city_news", + "type": "main", + "index": 0 + } + ] + ] + }, + "news_label_dify": { + "main": [ + [ + { + "node": "merge_label", + "type": "main", + "index": 1 + } + ] + ] + }, + "artifi_nature_label_dify": { + "main": [ + [ + { + "node": "merge_label", + "type": "main", + "index": 0 + } + ] + ] + }, + "get_label_answer": { + "main": [ + [ + { + "node": "get_city_news_sql", + "type": "main", + "index": 0 + } + ] + ] + }, + "merge_label": { + "main": [ + [ + { + "node": "get_label_answer", + "type": "main", + "index": 0 + } + ] + ] + }, + "Webhook": { + "main": [ + [ + { + "node": "artifi_nature_label_dify", + "type": "main", + "index": 0 + }, + { + "node": "news_label_dify", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "settings": { + "executionOrder": "v1" + }, + "staticData": null, + "meta": { + "templateCredsSetupCompleted": true + }, + "pinData": {}, + "versionId": "e5fc9923-c4dd-4b56-8648-dd07b26e068c", + "triggerCount": 1, + "shared": [ + { + "createdAt": "2025-04-07T09:07:55.459Z", + "updatedAt": "2025-04-07T09:07:55.459Z", + "role": "workflow:owner", + "workflowId": "OkLNJG1HWObUFcS0", + "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