{
  "name": "LINE UID",
  "nodes": [
    {
      "parameters": {
        "events": [
          "follow",
          "message"
        ]
      },
      "type": "@aotoki/n8n-nodes-line-messaging.lineMessagingTrigger",
      "typeVersion": 1,
      "position": [
        -48,
        0
      ],
      "id": "31345f0a-a716-438f-a6fd-0521a2bf6795",
      "name": "Line Messaging Trigger",
      "webhookId": "d714f0ba-4c1e-4f7c-b12b-184ee398ebfe",
      "credentials": {
        "lineMessagingApi": {
          "id": "EGmptqRAAZ1AMaLz",
          "name": "Line Messaging account"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://api.line.me/v2/bot/profile/{{ $json.source.userId }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer wIUuCsUa2iEE/dbO/bgE0OIARPJc6lozmoOqMECcM8eguMRfhTcTCLSc6zq+Luks3YGbqdX9iOg+J/8BMoXdkM/QWjN9mdYzDHqTnuQ71HdlpiarxuXmiAlqdhKfvW4XJn12t0WLSW8LU+s7yHbHKAdB04t89/1O/w1cDnyilFU="
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        208,
        0
      ],
      "id": "ad02b91f-d2ce-4f4c-869f-9f28e54cde20",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "content": "當 LINE 的官方帳號\n收到新好友追蹤或新訊息時觸發",
        "height": 80,
        "width": 272
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -96
      ],
      "typeVersion": 1,
      "id": "287708d6-03a2-4242-9dc7-cdacb483ef84",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "使用收到的 UID，\n透過 HTTP Request \n向 LINE 伺服器取得更多資訊",
        "height": 96
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        160
      ],
      "typeVersion": 1,
      "id": "d4eadd35-0541-44d8-b263-25a0d52c4f9e",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "將 LINE 客戶的資訊\n整合到 Ragic 的事件紀錄表",
        "height": 80,
        "width": 224
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -96
      ],
      "typeVersion": 1,
      "id": "d0a774b8-a19c-4c53-bfe2-6acc8e370d63",
      "name": "Sticky Note2",
      "disabled": true
    },
    {
      "parameters": {
        "action": "createNewData",
        "method": "fieldMode",
        "form": "jaykeeRagic/line-n8n-uid/2",
        "entries": {
          "fieldMode_map": [
            {
              "entries_field": "1006809",
              "entries_value": "={{ $('Line Messaging Trigger').item.json.message.type }}"
            },
            {
              "entries_field": "1006810",
              "entries_value": "={{ $json.userId }}"
            },
            {
              "entries_field": "1006811",
              "entries_value": "={{ $json.displayName }}"
            },
            {
              "entries_field": "1006812",
              "entries_value": "={{ $json.pictureUrl }}"
            },
            {
              "entries_field": "1006813",
              "entries_value": "={{ $json.language }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-ragic.ragic",
      "typeVersion": 1,
      "position": [
        432,
        0
      ],
      "id": "5dccd39e-6676-494d-9827-6861a8fc3368",
      "name": "Ragic",
      "credentials": {
        "ragicApi": {
          "id": "kuKk0EVmCHYC54uU",
          "name": "JayKeeRagic"
        }
      }
    },
    {
      "parameters": {
        "content": "將查詢結果拆分，\n交給後續的動作端觸發",
        "height": 80,
        "width": 224
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -96
      ],
      "typeVersion": 1,
      "id": "10cb1bcd-222e-4dc0-b474-63d2d67f3234",
      "name": "Sticky Note5",
      "disabled": true
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\nconst result = [];\n\n// 抓取 Object 中的所有 key (例如 \"1\", \"2\") 並將裡面的內容推入陣列\nfor (const key of Object.keys(data)) {\n  result.push({\n    json: data[key]\n  });\n}\n\nreturn result;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        0
      ],
      "id": "84857ac6-da3a-4cc0-8eb9-cab4bc5a7475",
      "name": "Code in JavaScript",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "content": "如果客戶通訊錄中沒有該 UID，\n從剛建立的事件紀錄表中拋轉",
        "height": 80,
        "width": 256
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        64
      ],
      "typeVersion": 1,
      "id": "5ddc43fb-9658-43fe-bc84-6e3c395b5509",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "檢查客戶通訊錄中\n是否已經有這個 UID 的資料",
        "height": 96,
        "width": 208
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        160
      ],
      "typeVersion": 1,
      "id": "939c303f-40b3-48e5-b2fc-4c8f63b50bc3",
      "name": "Sticky Note3",
      "disabled": true
    },
    {
      "parameters": {
        "form": "jaykeeRagic/line-n8n-uid/3",
        "filters": {
          "filter_map": [
            {
              "filters_field": "1006817",
              "filters_value": "={{ $('Line Messaging Trigger').item.json.source.userId }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-ragic.ragic",
      "typeVersion": 1,
      "position": [
        672,
        0
      ],
      "id": "ddb5db53-ca2d-4267-a414-c85ce22687ff",
      "name": "Ragic1",
      "alwaysOutputData": false,
      "credentials": {
        "ragicApi": {
          "id": "kuKk0EVmCHYC54uU",
          "name": "JayKeeRagic"
        }
      }
    },
    {
      "parameters": {
        "action": "executeActionButton",
        "form": "jaykeeRagic/line-n8n-uid/2",
        "recordIndex": "={{ $('Ragic').item.json.ragicId }}",
        "actionButtonId": "1"
      },
      "type": "n8n-nodes-ragic.ragic",
      "typeVersion": 1,
      "position": [
        1360,
        160
      ],
      "id": "34426b71-4749-40d0-89eb-7d2ac79264e1",
      "name": "Ragic2",
      "credentials": {
        "ragicApi": {
          "id": "kuKk0EVmCHYC54uU",
          "name": "JayKeeRagic"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "4f268c5d-a540-480e-9a5e-5b8c54afbfec",
              "leftValue": "={{ $json._ragicId }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1136,
        0
      ],
      "id": "c28fb90d-4f6c-4c0b-9efa-bf5cbc4ccfe9",
      "name": "If"
    }
  ],
  "pinData": {},
  "connections": {
    "Line Messaging Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Ragic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ragic": {
      "main": [
        [
          {
            "node": "Ragic1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ragic1": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ragic2": {
      "main": [
        []
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [],
        [
          {
            "node": "Ragic2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "4f83d8c7-494a-438b-9e25-357ba85a06ff",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "a53b4727f502e720ea30a373074b0599c2b0492ceebf12c88920178a97d7a187"
  },
  "nodeGroups": [],
  "id": "dY-A6wAiF5_4dYxj2ty8F",
  "tags": []
}