Skip to content

Instantly share code, notes, and snippets.

@gongzili456
Last active January 31, 2023 09:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gongzili456/5c934c988c3c8ba09706b8a7329b637c to your computer and use it in GitHub Desktop.
Save gongzili456/5c934c988c3c8ba09706b8a7329b637c to your computer and use it in GitHub Desktop.
Watch CMB back billings to import MoneyWiz
{
"name": "招商银行储蓄卡动账",
"nodes": [
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"filters": {
"sender": "95555@message.cmbchina.com"
}
},
"id": "666368f4-23da-450e-b2bd-282af1f8bcdc",
"name": "当有动账邮件时",
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1,
"position": [940, 580],
"credentials": {
"gmailOAuth2": {
"id": "1",
"name": "Gmail account"
}
}
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "{{ Your google sheet id}}",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "0",
"mode": "id"
},
"dataMode": "autoMapInputData",
"options": {
"cellFormat": "USER_ENTERED",
"handlingExtraData": "insertInNewColumn"
}
},
"id": "cb7a7d79-f267-44d8-857a-f29f7f58d708",
"name": "Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 3,
"position": [2460, 820],
"credentials": {
"googleSheetsOAuth2Api": {
"id": "4",
"name": "Google Sheets account"
}
}
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const regex = /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})在【(.*)-(.*)】发生快捷支付扣款,人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*)/\n\nconst matched = $json.snippet.match(regex)\n$json.matched = matched\n\n$json.transaction = \"Expense\"\n\nreturn $input.item;"
},
"id": "7c07f604-631e-470f-b006-c57562116dc9",
"name": "消费",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1800, 560]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const snippet = $input.item.json.snippet\n\nconst ts = parseInt($json.internalDate)\nconst t = new Date(new Date(ts).toLocaleString(\"en-US\", {timeZone: \"Asia/Shanghai\"}))\n\nconst year = t.getFullYear()\nconst hour = t.getHours()\nconst minute = t.getMinutes()\nconst second = t.getSeconds()\n\nreturn {json: { snippet, year: year, hour: hour, minute: minute, second: second }}\n"
},
"id": "9b2921dd-b8a0-4443-9e26-07817e306ace",
"name": "提取正文",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1120, 580]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})在【(.*)-(.*)】发生快捷支付退款,人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*)/.test($json[\"snippet\"]) }}",
"value2": true
}
]
}
},
"id": "bb88189d-2779-4375-a4ab-043a42686bf4",
"name": "IF 退款",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [1400, 740]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})在【(.*)-(.*)】发生快捷支付扣款,人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*)/.test($json[\"snippet\"]) }}",
"value2": true
}
]
}
},
"id": "de251ee7-1c31-4612-b363-7287d257eeea",
"name": "IF 扣款",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [1400, 580]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const regex = /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})在【(.*)-(.*)】发生快捷支付退款,人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*)/\n\nconst matched = $json.snippet.match(regex)\n$json.matched = matched\n\n$json.transaction = \"Income\"\n\nreturn $input.item;"
},
"id": "5d6b11ef-0db2-408a-b704-dbcc00f6d405",
"name": "退款",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1800, 720]
},
{
"parameters": {},
"id": "7b8fb2c9-a68e-4059-b05b-f25588f85507",
"name": "结束",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [1800, 400]
},
{
"parameters": {
"channel": "moneywiz",
"jsonParameters": true,
"otherOptions": {},
"attachments": [],
"attachmentsJson": "=[\n {\n \"title\": \"招商银行动账通知({{ $json[\"Transaction\"] == \"Income\" ? \"收入\" : \"支出\" }})\",\n \"text\": \"{{ $json[\"Memo\"] }}\"\n },\n {\n \"fallback\": \"是否将动账导入到 MoneyWiz 中?\",\n \"title\": \"是否将动账导入到 MoneyWiz 中?\",\n \"callback_id\": \"import_to_moneywiz_cb\",\n \"color\": \"{{ $json[\"Transaction\"] == \"Income\" ? \"#3AA3E3\" : \"#F55050\" }}\",\n \"attachment_type\": \"default\",\n \"actions\": [\n {\n \"name\": \"yes\",\n \"text\": \"Import to MoneyWiz\",\n \"type\": \"button\",\n \"value\": \"yes\",\n \"style\": \"primary\",\n \"url\": \"{{ $json[\"url\"] }}\"\n }\n ]\n }\n ]",
"blocksJson": "="
},
"id": "48e06a3f-d477-4362-994d-c97e8682f4df",
"name": "Import URL Message",
"type": "n8n-nodes-base.slack",
"typeVersion": 1,
"position": [2460, 640],
"credentials": {
"slackApi": {
"id": "2",
"name": "Slack account"
}
}
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日他行实时转入人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*),付方(\\W+)/.test($json[\"snippet\"]) }}",
"value2": true
}
]
}
},
"id": "e0d5a8dd-c261-4221-b6cb-220bf0969c2e",
"name": "IF 转账(转入)",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [1400, 940]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})实时转至他行人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*),收款人(\\W+)/.test($json[\"snippet\"]) }}",
"value2": true
}
]
}
},
"id": "e284e782-de26-4d61-8fa8-3071a6474b55",
"name": "IF 转账(转出)",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [1400, 1100]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const regex = /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日他行实时转入人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*),付方(\\W+)/\n\nconst matched = $json.snippet.match(regex)\n$json.matched = matched\n\nreturn $input.item;"
},
"id": "a79ff81c-44e2-4c43-8682-2d8dedbeb3fd",
"name": "转入",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1800, 920]
},
{
"parameters": {
"channel": "moneywiz",
"jsonParameters": true,
"otherOptions": {},
"attachments": [],
"attachmentsJson": "=[\n {\n \"title\": \"招商银行动账通知(转账)\",\n \"text\": \"{{ $json[\"Memo\"] }}\"\n },\n {\n \"fallback\": \"是否将动账导入到 MoneyWiz 中?\",\n \"title\": \"是否将动账导入到 MoneyWiz 中?\",\n \"callback_id\": \"import_to_moneywiz_cb\",\n \"color\": \"{{ $json[\"Description\"] == \"转账(入)\" ? \"#3AA3E3\" : \"#F55050\" }}\",\n \"attachment_type\": \"default\",\n \"actions\": [\n {\n \"name\": \"yes\",\n \"text\": \"Import to MoneyWiz\",\n \"type\": \"button\",\n \"value\": \"yes\",\n \"style\": \"primary\",\n \"url\": \"{{ $json[\"url\"] }}\"\n }\n ]\n }\n ]",
"blocksJson": "="
},
"id": "17282f1d-75fa-47b0-99f7-d0b32e384cfc",
"name": "Import URL Message1",
"type": "n8n-nodes-base.slack",
"typeVersion": 1,
"position": [2460, 1000],
"credentials": {
"slackApi": {
"id": "2",
"name": "Slack account"
}
}
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const regex = /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})实时转至他行人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*),收款人(\\W+)/\n\nconst matched = $json.snippet.match(regex)\n$json.matched = matched\n\nreturn $input.item;"
},
"id": "456a6586-6257-4854-8fdf-f87d4e998af6",
"name": "转出",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1800, 1080]
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"string": [
{
"name": "Amount",
"value": "={{ $json[\"matched\"][7] }}"
},
{
"name": "Account",
"value": "招商银行"
},
{
"name": "Description",
"value": "={{ $json[\"matched\"][5] }}-{{ $json[\"matched\"][6] }}"
},
{
"name": "Payee",
"value": "={{ $json[\"matched\"][6] }}"
},
{
"name": "Date",
"value": "={{ $json[\"matched\"][3] }}-{{ $json[\"matched\"][2] }}-{{ $now.year }}"
},
{
"name": "Time",
"value": "={{ $json[\"matched\"][4] }}:00"
},
{
"name": "Memo",
"value": "={{ $json[\"matched\"][0] }}"
},
{
"name": "Currency",
"value": "CNY"
},
{
"name": "Check #"
},
{
"name": "Tags",
"value": "={{ $json[\"matched\"][5] }}"
},
{
"name": "Balance",
"value": "={{ $json[\"matched\"][8] }}"
},
{
"name": "Transaction",
"value": "={{ $json[\"transaction\"] }}"
},
{
"name": "Transfers"
},
{
"name": "DateTime",
"value": "={{ $json[\"year\"] }}-{{ $json[\"matched\"][2] }}-{{ $json[\"matched\"][3] }} {{ $json[\"matched\"][4] }}:00"
}
]
},
"options": {}
},
"id": "35ec60c0-d30b-48bd-9411-dda5d9a852b9",
"name": "MoneyWiz 数据(消费)",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [2020, 640]
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"string": [
{
"name": "Amount",
"value": "={{ $json[\"matched\"][4] }}"
},
{
"name": "Account",
"value": "招商银行"
},
{
"name": "Description",
"value": "=转账(入)"
},
{
"name": "Date",
"value": "={{ $json[\"matched\"][3] }}-{{ $json[\"matched\"][2] }}-{{ $json[\"year\"] }}"
},
{
"name": "Memo",
"value": "={{ $json[\"matched\"][0] }}"
},
{
"name": "Currency",
"value": "CNY"
},
{
"name": "Check #"
},
{
"name": "Balance",
"value": "={{ $json[\"matched\"][5] }}"
},
{
"name": "Transfers",
"value": "={{ $json[\"matched\"][6] }}"
},
{
"name": "DateTime",
"value": "={{ $json[\"year\"] }}-{{ $json[\"matched\"][2] }}-{{ $json[\"matched\"][3] }} {{ $json[\"hour\"] }}:{{ $json[\"minute\"] }}:{{ $json[\"second\"] }}"
}
]
},
"options": {}
},
"id": "583a1288-0665-4ba3-be6f-adedb51dd847",
"name": "MoneyWiz 数据(转账)",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [2020, 1000]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const j = $input.item.json\n\nconst schema = {\n amount: j.Amount,\n toAccount: j.Account,\n account: j.Transfers,\n currency: j.Currency,\n description: j.Description,\n memo: j.Memo,\n date: j.DateTime,\n save: false,\n}\n\nconst params = Object.keys(schema).map(function(k) {\n return k + \"=\" + encodeURIComponent(schema[k])\n})\n\n$input.item.json.url = \"moneywiz://transfer\" + \"?\" + params.join(\"&\");\n\nreturn $input.item;"
},
"id": "cb05afb8-ed03-4951-9e74-645f544542d1",
"name": "MoneyWiz Import URL Schema(转账)",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [2240, 1000]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const j = $input.item.json\n\nconst schema = {\n amount: j.Amount,\n account: j.Account,\n currency: j.Currency,\n payee: j.Payee,\n description: j.Description,\n memo: j.Memo,\n tags: j.Tags,\n date: j.DateTime,\n save: false,\n}\n\nconst params = Object.keys(schema).map(function(k) {\n return k + \"=\" + encodeURIComponent(schema[k])\n})\n\n$input.item.json.url = \"moneywiz://\" + j.Transaction.toLowerCase() + \"?\" + params.join(\"&\");\n\nreturn $input.item;"
},
"id": "6aab0e17-9e61-42c9-a3ab-b7d4688370a3",
"name": "MoneyWiz Import URL Schema(消费)",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [2240, 640]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})信用卡还款交易人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*)/.test($json[\"snippet\"]) }}",
"value2": true
}
]
}
},
"id": "fc5db529-40b4-4f1d-b9df-acc669d3e20e",
"name": "IF 信用卡还款",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [1400, 1280]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const regex = /您账户([0-9]{4})于([0-9]{2})月([0-9]{2})日([0-9]{2}:[0-9]{2})信用卡还款交易人民币([-+]?[0-9]*\\.?[0-9]*),余额([-+]?[0-9]*\\.?[0-9]*)/\n\nconst matched = $json.snippet.match(regex)\n$json.matched = matched\n\nreturn $input.item;"
},
"id": "68348e1c-8ff2-477f-bb37-0ad356e9599f",
"name": "信用卡还款",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1800, 1260]
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"string": [
{
"name": "Amount",
"value": "={{ $json[\"matched\"][5] }}"
},
{
"name": "Account",
"value": "招商银行"
},
{
"name": "Description",
"value": "=转账(入)"
},
{
"name": "Date",
"value": "={{ $json[\"matched\"][3] }}-{{ $json[\"matched\"][2] }}-{{ $json[\"year\"] }}"
},
{
"name": "Memo",
"value": "={{ $json[\"matched\"][0] }}"
},
{
"name": "Currency",
"value": "CNY"
},
{
"name": "Check #"
},
{
"name": "Balance",
"value": "={{ $json[\"matched\"][6] }}"
},
{
"name": "Transfers",
"value": "招商银行(信用卡)"
},
{
"name": "DateTime",
"value": "={{ $json[\"year\"] }}-{{ $json[\"matched\"][2] }}-{{ $json[\"matched\"][3] }} {{ $json[\"hour\"] }}:{{ $json[\"minute\"] }}:{{ $json[\"second\"] }}"
}
]
},
"options": {}
},
"id": "b8e87710-7e3c-4ca3-acc5-4e41722937dc",
"name": "MoneyWiz 数据(信用卡还款)",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [2020, 1260]
}
],
"pinData": {},
"connections": {
"当有动账邮件时": {
"main": [
[
{
"node": "提取正文",
"type": "main",
"index": 0
}
]
]
},
"提取正文": {
"main": [
[
{
"node": "IF 退款",
"type": "main",
"index": 0
},
{
"node": "IF 扣款",
"type": "main",
"index": 0
},
{
"node": "IF 转账(转入)",
"type": "main",
"index": 0
},
{
"node": "IF 转账(转出)",
"type": "main",
"index": 0
},
{
"node": "IF 信用卡还款",
"type": "main",
"index": 0
}
]
]
},
"IF 退款": {
"main": [
[
{
"node": "退款",
"type": "main",
"index": 0
}
],
[
{
"node": "结束",
"type": "main",
"index": 0
}
]
]
},
"IF 扣款": {
"main": [
[
{
"node": "消费",
"type": "main",
"index": 0
}
],
[
{
"node": "结束",
"type": "main",
"index": 0
}
]
]
},
"消费": {
"main": [
[
{
"node": "MoneyWiz 数据(消费)",
"type": "main",
"index": 0
}
]
]
},
"退款": {
"main": [
[
{
"node": "MoneyWiz 数据(消费)",
"type": "main",
"index": 0
}
]
]
},
"IF 转账(转入)": {
"main": [
[
{
"node": "转入",
"type": "main",
"index": 0
}
],
[
{
"node": "结束",
"type": "main",
"index": 0
}
]
]
},
"IF 转账(转出)": {
"main": [
[
{
"node": "转出",
"type": "main",
"index": 0
}
],
[
{
"node": "结束",
"type": "main",
"index": 0
}
]
]
},
"转入": {
"main": [
[
{
"node": "MoneyWiz 数据(转账)",
"type": "main",
"index": 0
}
]
]
},
"转出": {
"main": [
[
{
"node": "MoneyWiz 数据(转账)",
"type": "main",
"index": 0
}
]
]
},
"MoneyWiz 数据(消费)": {
"main": [
[
{
"node": "MoneyWiz Import URL Schema(消费)",
"type": "main",
"index": 0
}
]
]
},
"MoneyWiz 数据(转账)": {
"main": [
[
{
"node": "MoneyWiz Import URL Schema(转账)",
"type": "main",
"index": 0
}
]
]
},
"MoneyWiz Import URL Schema(转账)": {
"main": [
[
{
"node": "Google Sheets",
"type": "main",
"index": 0
},
{
"node": "Import URL Message1",
"type": "main",
"index": 0
}
]
]
},
"MoneyWiz Import URL Schema(消费)": {
"main": [
[
{
"node": "Import URL Message",
"type": "main",
"index": 0
},
{
"node": "Google Sheets",
"type": "main",
"index": 0
}
]
]
},
"IF 信用卡还款": {
"main": [
[
{
"node": "信用卡还款",
"type": "main",
"index": 0
}
],
[
{
"node": "结束",
"type": "main",
"index": 0
}
]
]
},
"信用卡还款": {
"main": [
[
{
"node": "MoneyWiz 数据(信用卡还款)",
"type": "main",
"index": 0
}
]
]
},
"MoneyWiz 数据(信用卡还款)": {
"main": [
[
{
"node": "MoneyWiz Import URL Schema(转账)",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {},
"versionId": "477c303d-0e8e-4987-bfb9-ff40033a089a",
"id": "1",
"meta": {
"instanceId": "23b02a64715a2620abc56479282532d1f8058cbe462c04dc6efaf99758c97161"
},
"tags": [
{
"createdAt": "2023-01-28T12:25:55.374Z",
"updatedAt": "2023-01-28T12:25:55.374Z",
"id": "1",
"name": "招商银行"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment