AutomationFlowsWeb Scraping › Headachetracker

Headachetracker

Headachetracker. Uses httpRequest. Webhook trigger; 42 nodes.

Webhook trigger★★★★★ complexity42 nodesHTTP Request
Web Scraping Trigger: Webhook Nodes: 42 Complexity: ★★★★★ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "linebot/headache",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1400,
        4060
      ],
      "id": "1b358cbc-9539-4744-bc0d-55b1f5b6b346",
      "name": "Webhook"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.events[0].type }}",
                    "rightValue": "postback",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "b0083c5d-f530-4533-849f-783924bbd341"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "postback"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "82a1ba46-2be0-4723-91a3-5fe0a2b1b85e",
                    "leftValue": "={{ $json.body.events[0].type }}",
                    "rightValue": "message",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "message"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -800,
        4060
      ],
      "id": "4508b9bf-135c-40ca-a1b6-91eaf59a1979",
      "name": "Switch"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "51a9606b-ae3f-474d-973c-d642536d7ce1",
              "name": "message",
              "value": "{   \"type\": \"template\",\n    \"altText\": \"\u5403\u4e86\u4ec0\u9ebc\u85e5\",\n    \"template\": {\n        \"type\": \"buttons\",\n        \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=general_questions.png&version_id=null\",\n        \"imageAspectRatio\": \"square\",\n        \"imageSize\": \"cover\",\n        \"title\": \"\u5403\u4e86\u4ec0\u9ebc\u85e5\",\n        \"text\": \"\u8acb\u9078\u64c7\u4e00\u7a2e\",\n        \"actions\": [\n            {\n                \"type\": \"postback\",\n                \"label\": \"\u5403\u4e86\u666e\u62ff\u75bc\",\n                \"text\": \"\u5403\u4e86\u666e\u62ff\u75bc\",\n                \"data\": \"drug_type=\u666e\u62ff\u75bc\"\n            },\n            {\n                \"type\": \"postback\",\n                \"label\": \"\u5403\u4e86\u4f0a\u666e\",\n                \"text\": \"\u5403\u4e86\u4f0a\u666e\",\n                \"data\": \"drug_type=\u4f0a\u666e\"\n            },\n            {\n                \"type\": \"postback\",\n                \"label\": \"\u5403\u4e86\u808c\u8089\u9b06\u5f1b\",\n                \"text\": \"\u5403\u4e86\u808c\u8089\u9b06\u5f1b\",\n                \"data\": \"drug_type=\u808c\u8089\u9b06\u5f1b\"\n            },\n            {\n                \"type\": \"postback\",\n                \"label\": \"\u5403\u4e86\u4e2d\u85e5\",\n                \"text\": \"\u5403\u4e86\u4e2d\u85e5\",\n                \"data\": \"drug_type=\u4e2d\u85e5\"\n            }\n        ]\n    }\n}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -380,
        4780
      ],
      "id": "725647be-d37a-4642-860f-31b776d9065f",
      "name": "Set Drug Select"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\":  \"{{ $('Webhook').item.json.body.events[0].replyToken }}\",\n  \"messages\":[{{ $json.message }}\n]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3220,
        4020
      ],
      "id": "ebc33535-b653-46ef-9cb6-de69dfbc3ea5",
      "name": "Response Drug Select",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.events[0].message.text }}",
                    "rightValue": "\u5403\u85e5\u4e86",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "id": "5ee35c6f-84c5-423c-b446-e74bff580492"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u5403\u85e5"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f56d3cde-d045-4911-9bd4-948b3f1a843c",
                    "leftValue": "={{ $json.body.events[0].message.text }}",
                    "rightValue": "=\u982d\u75db\u4e86",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u982d\u75db"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "bd2f8573-6285-49af-9a80-800336668265",
                    "leftValue": "={{ $json.body.events[0].message.text }}",
                    "rightValue": "\u6700\u8fd1\u5403\u85e5",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u6700\u8fd1\u5403\u85e5"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "567a697b-8a03-481a-a95f-e861452a717d",
                    "leftValue": "={{ $json.body.events[0].message.text }}",
                    "rightValue": "\u63a1\u53d6\u884c\u52d5",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u63a1\u53d6\u884c\u52d5"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "7364b61c-c126-4307-926d-8d87d1893d13",
                    "leftValue": "={{ $json.body.events[0].message.text }}",
                    "rightValue": "\u982d\u4e0d\u75db\u4e86",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u982d\u4e0d\u75db\u4e86"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b6b32546-7312-4cd2-bc6e-a99fba0c6fb6",
                    "leftValue": "={{ $json.body.events[0].message.text }}",
                    "rightValue": "\u6700\u8fd1\u982d\u75db",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u6700\u8fd1\u982d\u75db\u6642\u9593"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -960,
        5060
      ],
      "id": "9ec07937-ec72-407a-983b-a2d290436f26",
      "name": "Determine Response Action"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.drug_type }}",
                    "rightValue": "drug",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    },
                    "id": "6b24bb20-5d45-4b84-9c6f-574bdc5f5483"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "response drug number"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c3d29e35-8353-404a-9668-72bcf7c5ea08",
                    "leftValue": "={{ $json.drug_number }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "responses drug datetime"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "98088412-70f4-4e62-8e62-282f6dfae893",
                    "leftValue": "={{ $json.drug_datetime }}",
                    "rightValue": "now",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "medicine now"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "86e614e5-f263-4a40-a330-485a85c8277f",
                    "leftValue": "={{ $json.pain_level }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "write pain level"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "47044a4e-970c-453a-8d07-9b671652194a",
                    "leftValue": "={{ $json.headache_occur }}",
                    "rightValue": "now",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "headache now"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "caf05b0c-9b01-4aed-bfcd-eefba2c2132c",
                    "leftValue": "={{ $json.headache_occur }}",
                    "rightValue": "selecttime",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "headache select time"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "cf06cf4f-66be-45c9-8fcb-be1ba4590a6d",
                    "leftValue": "={{ $json.action_occur }}",
                    "rightValue": "now",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "action occur now"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "d15ce113-b4cb-4c1a-a15d-99d9e502dad0",
                    "leftValue": "={{ $json.action_occur }}",
                    "rightValue": "selecttime",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "action select time"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "1833c35e-dda8-4901-ac5c-6368622db30f",
                    "leftValue": "={{ $json.no_headache_occur }}",
                    "rightValue": "now",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "no headache now"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "9f4235aa-31bf-4562-acc4-49c7d256d426",
                    "leftValue": "={{ $json.no_headache_occur }}",
                    "rightValue": "selecttime",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "no headache select time"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "7aa61cad-5c79-4dae-baf5-4f1d365c091d",
                    "leftValue": "={{ $json.headache_where }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "select headache where again"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "fc7130a9-d548-4b89-9bfe-0378638c040c",
                    "leftValue": "={{ $json.headache_ask }}",
                    "rightValue": "done",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "headache ask done"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "87fee6fa-bdb8-4c63-8836-0155d0e67b67",
                    "leftValue": "={{ $json.drug_datetime }}",
                    "rightValue": "selecttime",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "medicine selecttime"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        780,
        4000
      ],
      "id": "7328ad1d-ee87-4cf6-9ba4-9ad1a7978bf1",
      "name": "Switch1"
    },
    {
      "parameters": {
        "jsCode": "const input = $input.first().json.body.events[0].postback.data;\n\n// Use a single regex to capture key-value pairs for both long (--key=value) and short (-k=value) options\nconst regex = /([a-zA-Z0-9_]+)=([^\\s]*)/gu;\n\nlet matches;\nlet drug_type = null;\nlet drug_type_tmp = null;\nlet drug_number = null;\nlet drug_number_tmp = null;\nlet drug_datetime = null;\nlet pain_level = null;\nlet pain_level_tmp = null;\nlet headache_occur = null;\nlet headache_occur_tmp = null;\nlet action_occur = null;\nlet action = null;\nlet no_headache_occur = null;\nlet headache_where = null;\nlet headache_where_final = null;\nlet headache_ask = null;\n\n// Loop through the matches\nwhile ((matches = regex.exec(input)) !== null) {\n    const key = matches[1] || matches[3]; // Get long option name or short key\n    var value = matches[2] || matches[4]; // Get the associated value\n    value = value?.trimEnd()\n    // Assign to the appropriate variable based on the key\n    if (key === 'drug_type') {\n        drug_type = value;\n    } else if (key === 'drug_number') {\n        drug_number = value;\n    } else if (key === 'drug_datetime') {\n      drug_datetime = value;\n    } else if (key === 'drug_type_tmp') {\n      drug_type_tmp = value\n    } else if (key === 'drug_number_tmp') {\n      drug_number_tmp = value\n    } else if (key === 'pain_level') {\n      pain_level = value\n    } else if (key === 'pain_level_tmp') {\n      pain_level_tmp = value\n    } else if (key === 'headache_occur') {\n      headache_occur = value\n    } else if (key === 'headache_occur_tmp') {\n      headache_occur_tmp = value\n    } else if (key === 'action_occur') {\n      action_occur = value\n    } else if (key === 'action') {\n      action = value\n    } else if (key === 'no_headache_occur') {\n      no_headache_occur = value\n    } else if (key === 'headache_where') {\n      headache_where = value\n    } else if (key === 'headache_where_final') {\n      headache_where_final = value\n    } else if (key === 'headache_ask') {\n      headache_ask = value\n    }\n}\n\n// Return the results\nreturn { drug_datetime, drug_number, drug_type, drug_type_tmp, drug_number_tmp, pain_level, headache_occur, headache_occur_tmp, action_occur, action, no_headache_occur, headache_where, headache_where_final, pain_level_tmp, headache_ask };"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        600,
        4200
      ],
      "id": "b6583dd7-3ad8-45a3-b638-fc7ac2dc57ab",
      "name": "Code"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "51a9606b-ae3f-474d-973c-d642536d7ce1",
              "name": "message",
              "value": "={\n  \"type\": \"template\",\n  \"altText\": \"\u5403\u4e86\u5e7e\u9846\",\n  \"template\": {\n    \"type\": \"buttons\",\n    \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=general_questions.png&version_id=null\",\n    \"imageAspectRatio\": \"square\",\n    \"imageSize\": \"cover\",\n    \"title\": \"\u5403\u4e86\u5e7e\u9846\u85e5\",\n    \"text\": \"\u56db\u5c0f\u6642\u53ea\u80fd\u5403\u4e00\u9846!\",\n    \"actions\": [\n      {\n        \"type\": \"postback\",\n        \"label\": \"1\",\n        \"text\": \"\u5403\u4e861\u9846\",\n        \"data\": \"drug_number=1 drug_type_tmp={{$json.drug_type}}\"\n      },\n      {\n        \"type\": \"postback\",\n        \"label\": \"2\",\n        \"text\": \"\u5403\u4e862\u9846\",\n        \"data\": \"drug_number=2 drug_type_tmp={{$json.drug_type}}\"\n      }\n    ]\n  }\n}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1560,
        3700
      ],
      "id": "85925739-8f2c-48ad-bb02-bcbb173a7f7d",
      "name": "Set Drug Number"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6b262a70-2015-4722-9bcc-131f673f88ec",
              "name": "=message",
              "value": "={\n  \"type\": \"template\",\n  \"altText\": \"\u4ec0\u9ebc\u6642\u5019\u5403\u85e5\u7684?\",\n  \"template\": {\n    \"type\": \"buttons\",\n    \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=general_questions.png&version_id=null\",\n    \"imageAspectRatio\": \"square\",\n    \"title\": \"\u4ec0\u9ebc\u6642\u5019\u5403\u7684\",\n    \"text\": \"\u8981\u8a18\u9304\u5537\",\n    \"actions\": [\n      {\n        \"type\": \"postback\",\n        \"label\": \"\u5c31\u662f\u73fe\u5728\u5403\u4e86\",\n        \"text\": \"\u5c31\u662f\u73fe\u5728\",\n        \"data\": \"drug_datetime=now drug_type_tmp={{$json.drug_type_tmp}} drug_number_tmp={{$json.drug_number}}\"\n      },\n      {\n        \"type\": \"datetimepicker\",\n        \"label\": \"\u8b93\u6211\u9078\u6642\u9593\",\n        \"data\": \"drug_datetime=selecttime drug_type_tmp={{$json.drug_type_tmp}} drug_number_tmp={{$json.drug_number}}\",\n        \"mode\": \"datetime\",\n        \"initial\": \"{{$now.format('yyyy-MM-dd')}}T{{$now.format('HH:mm')}}\",\n        \"max\": \"{{$now.plus(1, 'days').format('yyyy-MM-dd')}}T00:00\",\n        \"min\": \"{{$now.minus(10, 'days').format('yyyy-MM-dd')}}T00:00\"\n      }\n    ]\n  }\n}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        3860
      ],
      "id": "0bb24fbf-4605-485c-9f47-e4cf81f6bfb2",
      "name": "Set Drug DateTime"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "467ec0f2-bcfa-4dc3-9a7d-f5f708bcad18",
              "name": "drug_type",
              "value": "={{ $('Switch1').item.json.drug_type_tmp }}",
              "type": "string"
            },
            {
              "id": "06d005d7-3e7b-412f-9e51-4b90385b5f9e",
              "name": "drug_number",
              "value": "={{ $('Switch1').item.json.drug_number_tmp }}",
              "type": "string"
            },
            {
              "id": "91bb2ed6-949f-4a0a-a0fc-725d208e0d22",
              "name": "drug_datetime",
              "value": "={{ $json.drug_datetime }}",
              "type": "string"
            },
            {
              "id": "d5b2e09e-4ad0-4c74-bbba-703a97b32655",
              "name": "user_id",
              "value": "={{ $('Webhook').first().json.body.events.first().source.userId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        4020
      ],
      "id": "1a6bac9d-7fa1-456c-a085-7f2e352871b1",
      "name": "Set Drug Usage"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\":  \"{{ $('Webhook').item.json.body.events[0].replyToken }}\",\n  \"messages\":[{\n  \"type\": \"text\",\n  \"text\": \"\u982d\u75db\u5feb\u98db\ud83d\ude2d {{ $json.drug_datetime }} \u5403\u4e86 {{ $json.drug_number }} {{ $json.drug_type }}\"\n}\n]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2040,
        4020
      ],
      "id": "f8a56b36-4648-44e1-827b-af9f3c4f992a",
      "name": "Response Success",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\":  \"{{ $('Webhook').first().json.body.events[0].replyToken }}\",\n  \"messages\":[{\n  \"type\": \"text\",\n  \"text\": {{ $json.formattedOutput }}\n}\n]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        5000
      ],
      "id": "b4ae0726-3e3c-47bf-95d8-53d27fa97b7c",
      "name": "Response Success1",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1366a377-4f67-4f9f-9304-89d8859906fb",
              "name": "message",
              "value": "={\n  \"type\": \"flex\",\n  \"altText\": \"\u73fe\u5728\u982d\u6709\u5e7e\u5206\u75db\",\n  \"contents\": {\n      \"type\": \"bubble\",\n      \"hero\": {\n        \"type\": \"image\",\n        \"size\": \"full\",\n        \"aspectRatio\": \"1:1\",\n        \"aspectMode\": \"cover\",\n        \"action\": {\n          \"type\": \"uri\",\n          \"uri\": \"https://line.me/\"\n        },\n        \"url\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=rate.png&version_id=null\"\n      },\n      \"body\": {\n        \"type\": \"box\",\n        \"layout\": \"vertical\",\n        \"spacing\": \"md\",\n        \"contents\": [\n          {\n            \"type\": \"text\",\n            \"text\": \"\u982d\u75db\u5e7e\u5206\",\n            \"weight\": \"bold\",\n            \"size\": \"xl\",\n            \"align\": \"center\"\n          },\n          {\n            \"type\": \"text\",\n            \"text\": \"\u73fe\u5728\u5e7e\u5206\u75db\",\n            \"size\": \"md\",\n            \"color\": \"#aaaaaa\",\n            \"align\": \"center\"\n          }\n        ]\n      },\n      \"footer\": {\n        \"type\": \"box\",\n        \"layout\": \"vertical\",\n        \"spacing\": \"sm\",\n        \"contents\": [\n          {\n            \"type\": \"box\",\n            \"layout\": \"horizontal\",\n            \"spacing\": \"sm\",\n            \"contents\": [\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"label\": \"1\",\n                  \"text\": \"1 \u5206\u75db\",\n                  \"data\": \"pain_level=1 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#91D3FA\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"label\": \"2\",\n                  \"text\": \"2 \u5206\u75db\",\n                  \"data\": \"pain_level=2 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#76C9F9\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"label\": \"3\",\n                  \"text\": \"3 \u5206\u75db\",\n                  \"data\": \"pain_level=3 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#5CBEF7\",\n                \"height\": \"sm\"\n              }\n            ]\n          },\n          {\n            \"type\": \"box\",\n            \"layout\": \"horizontal\",\n            \"spacing\": \"sm\",\n            \"contents\": [\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"4 \u5206\u75db\",\n                  \"label\": \"4\",\n                  \"data\": \"pain_level=4 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#41B3F6\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"5 \u5206\u75db\",\n                  \"label\": \"5\",\n                  \"data\": \"pain_level=5 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#26A9F4\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"6 \u5206\u75db\",\n                  \"label\": \"6\",\n                  \"data\": \"pain_level=6 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#0B9EF3\",\n                \"height\": \"sm\"\n              }\n            ]\n          },\n          {\n            \"type\": \"box\",\n            \"layout\": \"horizontal\",\n            \"spacing\": \"sm\",\n            \"contents\": [\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"7 \u5206\u75db\",\n                  \"label\": \"7\",\n                  \"data\": \"pain_level=7 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#0A83CA\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"8 \u5206\u75db\",\n                  \"label\": \"8\",\n                  \"data\": \"pain_level=8 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#0869A0\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"9 \u5206\u75db\",\n                  \"label\": \"9\",\n                  \"data\": \"pain_level=9 headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#064E76\",\n                \"height\": \"sm\"\n              }\n            ]\n          },\n          {\n            \"type\": \"box\",\n            \"layout\": \"horizontal\",\n            \"spacing\": \"sm\",\n            \"margin\": \"md\",\n            \"contents\": [\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"\u8d85\u7d1a\u7121\u6575\u75db\",\n                  \"label\": \"\u221e\",\n                  \"data\": \"pain_level=infinite headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#FF4500\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"text\": \"\u6551\u6551\u6211...\",\n                  \"label\": \"help\",\n                  \"data\": \"pain_level=help\"\n                },\n                \"style\": \"primary\",\n                \"height\": \"sm\",\n                \"color\": \"#FF4500\"\n              }\n            ]\n          }\n        ]\n      }\n    }\n}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1860,
        4400
      ],
      "id": "9469ebe2-ac66-4886-8711-b997fc96a1b6",
      "name": "Set Ask Headache Level"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2ff0b5c5-cbe4-4411-b947-cb0c743e30ee",
              "name": "pain_level",
              "value": "={{ $json.pain_level }}",
              "type": "string"
            },
            {
              "id": "fb60b723-f225-4590-9bc9-5357c4d39250",
              "name": "headache_occur",
              "value": "={{ $json.headache_occur_tmp }}",
              "type": "string"
            },
            {
              "id": "883b78ac-f64b-4afc-a867-31f79bf9f6cc",
              "name": "existed_headache_where",
              "value": "",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        4180
      ],
      "id": "387f665d-b98d-4ce1-a5b9-08695b14075f",
      "name": "Set Pain Level"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\":  \"{{ $('Webhook').item.json.body.events[0].replyToken }}\",\n  \"messages\":[{\n  \"type\": \"text\",\n  \"text\": \"\u5728 {{ $json.headache_occur }} \u51fa\u73fe\u4e86 {{ $json.pain_level }} \u7d1a\u982d\u75db\"\n}\n]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3140,
        3660
      ],
      "id": "464d7fb1-1af8-417d-b9f9-8135ed1d81c1",
      "name": "Response Success2",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "let data = $input.all();\nlet formattedOutput = \"\";\nfor (let i = 0; i < data.length; i++) {\n  const entry = data[i].json;\n  console.log(entry)\n  formattedOutput += `\u5728 ${entry.drug_datetime} \u5403\u4e86 ${\"\ud83d\udc8a\".repeat(entry.drug_number)} ${entry.drug_type}`;\n  \n  // Add newline if not the last element\n  if (i < data.length - 1) {\n    formattedOutput += '\\n';\n  }\n}\n\nformattedOutput = JSON.stringify(formattedOutput)\nreturn {formattedOutput}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        5000
      ],
      "id": "888f4980-8001-4c7a-8fbc-e153c289779c",
      "name": "Code1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4bd62c6c-fc23-4108-ad16-74c8366cc27b",
              "name": "message",
              "value": "={\n  \"type\": \"template\",\n  \"altText\": \"\u4ec0\u9ebc\u6642\u5019\u982d\u75db\u7684?\",\n  \"template\": {\n    \"type\": \"buttons\",\n    \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=general_questions.png&version_id=null\",\n    \"imageAspectRatio\": \"square\",\n    \"title\": \"\u4ec0\u9ebc\u6642\u5019?\",\n    \"text\": \"\u9078\u64c7\u982d\u75db\u6642\u9593\",\n    \"actions\": [\n      {\n        \"type\": \"postback\",\n        \"label\": \"\u5c31\u662f\u73fe\u5728\uff0c\u75db\u6b7b\",\n        \"text\": \"\u5c31\u662f\u73fe\u5728\",\n        \"data\": \"headache_occur=now\"\n      },\n      {\n        \"type\": \"datetimepicker\",\n        \"label\": \"\u8b93\u6211\u9078\u6642\u9593\",\n        \"data\": \"headache_occur=selecttime\",\n        \"mode\": \"datetime\",\n        \"initial\": \"{{$now.format('yyyy-MM-dd')}}T{{$now.format('HH:mm')}}\",\n        \"max\": \"{{$now.plus(1, 'days').format('yyyy-MM-dd')}}T00:00\",\n        \"min\": \"{{$now.minus(10, 'days').format('yyyy-MM-dd')}}T00:00\"\n      }\n    ]\n  }\n}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -260,
        4920
      ],
      "id": "b0d8ad48-2568-4569-8dc8-9d08bd0ab058",
      "name": "Set Headache When"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e294c37d-c089-43ea-bacd-0e5e4e089bac",
              "name": "headache_occur",
              "value": "={{ $('Webhook').item.json.body.events[0].postback.params.datetime }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        4500
      ],
      "id": "8a4747e1-0bde-4349-b23e-4007c7b26159",
      "name": "Set Select Occur Time"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ceb5e266-ed7d-4da9-84eb-2340ebe85914",
              "name": "headache_occur",
              "value": "={{ $now.format('yyyy-MM-dd') }}T{{ $now.format('HH:mm') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        4340
      ],
      "id": "ab2c595d-8257-474c-9dfc-2a38c10c099d",
      "name": "Set Now Occur Time"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "88ea8471-364f-42c6-a5ad-5241e9cdc82c",
              "name": "message",
              "value": "={\n  \"type\": \"template\",\n  \"altText\": \"\u63a1\u53d6\u4ec0\u9ebc\u884c\u52d5?\",\n  \"template\": {\n    \"type\": \"carousel\",\n    \"imageAspectRatio\": \"square\",\n    \"columns\": [\n      {\n        \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=acupucture.png&version_id=null\",\n        \"title\": \"\u91dd\u7078\",\n        \"text\": \"\u91dd\u7078\u597d\u75e0QQ\",\n        \"actions\": [\n          {\n            \"type\": \"postback\",\n            \"label\": \"\u73fe\u5728\",\n            \"text\": \"\u73fe\u5728\u6b63\u5728\u91dd\u7078QQ\",\n            \"data\": \"action=needle action_occur=now\"\n          },\n          {\n            \"type\": \"datetimepicker\",\n            \"label\": \"\u9078\u64c7\u6642\u9593\",\n            \"data\": \"action=needle action_occur=selecttime\",\n            \"mode\": \"datetime\",\n            \"initial\": \"{{$now.format('yyyy-MM-dd')}}T{{$now.format('HH:mm')}}\",\n            \"max\": \"{{$now.plus(1, 'days').format('yyyy-MM-dd')}}T00:00\",\n            \"min\": \"{{$now.minus(10, 'days').format('yyyy-MM-dd')}}T00:00\"\n          }\n        ]\n      },\n      {\n        \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=hot_shower.png&version_id=null\",\n        \"title\": \"\u6c96\u71b1\u6c34\",\n        \"text\": \"\u6c96\u71b1\u6c34\u597d\u8212\u670d~\",\n        \"actions\": [\n          {\n            \"type\": \"postback\",\n            \"label\": \"\u73fe\u5728\",\n            \"text\": \"\u525b\u6c96\u5b8c\u71b1\u6c34\",\n            \"data\": \"action=shower action_occur=now\"\n          },\n          {\n            \"type\": \"datetimepicker\",\n            \"label\": \"\u9078\u64c7\u6642\u9593\",\n            \"data\": \"action=shower action_occur=selecttime\",\n            \"mode\": \"datetime\",\n            \"initial\": \"{{$now.format('yyyy-MM-dd')}}T{{$now.format('HH:mm')}}\",\n            \"max\": \"{{$now.plus(1, 'days').format('yyyy-MM-dd')}}T00:00\",\n            \"min\": \"{{$now.minus(10, 'days').format('yyyy-MM-dd')}}T00:00\"\n          }\n        ]\n      },\n      {\n        \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=sleep.png&version_id=null\",\n        \"title\": \"\u7761\u89ba\",\n        \"text\": \"Zzzzzzzzz\",\n        \"actions\": [\n          {\n            \"type\": \"postback\",\n            \"label\": \"\u6211\u73fe\u5728\u5c31\u8981\u7761\",\n            \"text\": \"\u5012\u982d\u5c31\u7761\",\n            \"data\": \"action=sleep action_occur=now\"\n          },\n          {\n            \"type\": \"datetimepicker\",\n            \"label\": \"\u9078\u64c7\u6642\u9593\",\n            \"data\": \"action=sleep action_occur=selecttime\",\n            \"mode\": \"datetime\",\n            \"initial\": \"{{$now.format('yyyy-MM-dd')}}T{{$now.format('HH:mm')}}\",\n            \"max\": \"{{$now.plus(1, 'days').format('yyyy-MM-dd')}}T00:00\",\n            \"min\": \"{{$now.minus(10, 'days').format('yyyy-MM-dd')}}T00:00\"\n          }\n        ],\n        \"imageBackgroundColor\": \"#EA8B8B\"\n      },\n      {\n        \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=massage.png&version_id=null\",\n        \"title\": \"\u6309\u6469\u3001\u6309\u7a74\u9053\",\n        \"text\": \"\u6309\u6469...\",\n        \"actions\": [\n          {\n            \"type\": \"postback\",\n            \"label\": \"\u6b63\u5728\u6309\",\n            \"text\": \"\u6b63\u5728\u52aa\u529b\u6309\",\n            \"data\": \"action=massage action_occur=now\"\n          },\n          {\n            \"type\": \"datetimepicker\",\n            \"label\": \"\u9078\u64c7\u6642\u9593\",\n            \"data\": \"action=massage action_occur=selecttime\",\n            \"mode\": \"datetime\",\n            \"initial\": \"{{$now.format('yyyy-MM-dd')}}T{{$now.format('HH:mm')}}\",\n            \"max\": \"{{$now.plus(1, 'days').format('yyyy-MM-dd')}}T00:00\",\n            \"min\": \"{{$now.minus(10, 'days').format('yyyy-MM-dd')}}T00:00\"\n          }\n        ],\n        \"imageBackgroundColor\": \"#EA8B8B\"\n      }\n    ]\n  }\n}\n",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -360,
        5180
      ],
      "id": "fdde5559-9cda-45e4-97c3-1c18eb81b273",
      "name": "Set Action When"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f3356d60-de4d-4d63-b680-18661816e4ec",
              "name": "occur_time",
              "value": "={{ $now.format('yyyy-MM-dd') }}T{{ $now.format('HH:mm') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        4700
      ],
      "id": "ce899024-135c-4e38-bb64-6fb9cfe465b1",
      "name": "Set Action Occur Now"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "21fa4b2e-a105-4f0c-9356-d1427a6af645",
              "name": "action",
              "value": "={{ $('Switch1').item.json.action }}",
              "type": "string"
            },
            {
              "id": "f0b49273-5745-401b-8c0e-6b69e9352c39",
              "name": "occur_time",
              "value": "={{ $json.occur_time }}",
              "type": "string"
            },
            {
              "id": "46d9674c-84b2-497d-872c-302f19ac2beb",
              "name": "user_id",
              "value": "={{ $('Webhook').first().json.body.events.first().source.userId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1980,
        4840
      ],
      "id": "5510e2fa-c9f7-44db-a8df-d62023b330d9",
      "name": "Set Action Insertion Data"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ca3258a0-bb80-42d9-9daa-32c4ba210e41",
              "name": "occur_time",
              "value": "={{ $('Webhook').item.json.body.events[0].postback.params.datetime }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        4920
      ],
      "id": "58108960-8fbe-4c23-88ab-effae9a5c103",
      "name": "Set Action Select Time"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\":  \"{{ $('Webhook').item.json.body.events[0].replyToken }}\",\n  \"messages\":[{\n  \"type\": \"text\",\n  \"text\": \"\u5e0c\u671b\u982d\u75db\u53ef\u4ee5\u8212\u7de9\ud83e\udd7a\"\n}\n]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2380,
        4840
      ],
      "id": "da1d6ae3-a1c2-4a07-960c-70fe80871be7",
      "name": "Response Action",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a3294e08-8654-446d-ba62-1a9d27fcdace",
              "name": "message",
              "value": "={\n    \"type\": \"template\",\n    \"altText\": \"\u4ec0\u9ebc\u6642\u5019\u4e0d\u75db\u7684?\",\n    \"template\": {\n      \"type\": \"buttons\",\n      \"thumbnailImageUrl\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=general_questions.png&version_id=null\",\n      \"imageAspectRatio\": \"square\",\n      \"title\": \"\u4ec0\u9ebc\u6642\u5019\u4e0d\u75db\u4e86?\",\n      \"text\": \"\u606d\u559c\u4f60!\",\n      \"actions\": [\n        {\n          \"type\": \"postback\",\n          \"label\": \"\u73fe\u5728\u4e0d\u75db\u4e86\",\n          \"text\": \"\u73fe\u5728\u4e0d\u75db\u4e86\",\n          \"data\": \"no_headache_occur=now\"\n        },\n        {\n          \"type\": \"datetimepicker\",\n          \"label\": \"\u9078\u64c7\u6642\u9593\",\n          \"data\": \"no_headache_occur=selecttime\",\n          \"mode\": \"datetime\",\n          \"initial\": \"{{$now.format('yyyy-MM-dd')}}T{{$now.format('HH:mm')}}\",\n          \"max\": \"{{$now.plus(1, 'days').format('yyyy-MM-dd')}}T00:00\",\n          \"min\": \"{{$now.minus(10, 'days').format('yyyy-MM-dd')}}T00:00\"\n         }\n      ]\n    }\n  }",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -360,
        5360
      ],
      "id": "45b256bf-8f46-4c10-9b9c-df4328dd31f4",
      "name": "Set No Headache When"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9b5e6717-e940-4739-b294-4b41f35be790",
              "name": "no_headache_time",
              "value": "={{$now.format('yyyy-MM-dd')}}T{{ $now.format('HH:mm') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        5140
      ],
      "id": "38fe54bc-79d1-4706-a5cb-fe3b4c18e8ef",
      "name": "Set No Headache Now"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "887c6e00-e6e0-44a0-92d8-5f293059fd66",
              "name": "headache_occur",
              "value": "={{ $json.no_headache_time }}",
              "type": "string"
            },
            {
              "id": "c1f9b6b1-a41f-4349-ad5f-eed9a0cf2ce6",
              "name": "pain_level",
              "value": "0",
              "type": "string"
            },
            {
              "id": "2c6c5940-b436-474c-bee0-62dfe82eaf42",
              "name": "user_id",
              "value": "={{ $('Webhook').first().json.body.events.first().source.userId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1960,
        5140
      ],
      "id": "3c499629-f2ea-440d-b486-e587673d5853",
      "name": "Set No Headache Insert Data"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"replyToken\":  \"{{ $('Webhook').item.json.body.events[0].replyToken }}\",\n  \"messages\":[{\n  \"type\": \"text\",\n  \"text\": \"\u606d\u559c\u4f60\u5728 {{ $json.headache_occur }} \u982d\u4e0d\u75db\u5566 \ud83d\ude0a\"\n}\n]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2520,
        5140
      ],
      "id": "4cbb96c4-9341-4854-bbea-30391fd7eff8",
      "name": "Response Success3",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9b5e6717-e940-4739-b294-4b41f35be790",
              "name": "no_headache_time",
              "value": "={{ $('Webhook').item.json.body.events[0].postback.params.datetime }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        5400
      ],
      "id": "08fc8974-7435-4bff-9fbe-983a910b8870",
      "name": "Set No Headache Select Time"
    },
    {
      "parameters": {
        "content": "## Set Pain Level\n",
        "height": 180,
        "width": 320,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2520,
        3620
      ],
      "id": "0bf9e043-7942-4334-b16b-dfc38d2b02cd",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d9342c09-16cd-45be-a326-96a0006928a8",
              "name": "message",
              "value": "={\n  \"type\": \"flex\",\n  \"altText\": \"\u54ea\u88e1\u982d\u75db\",\n  \"contents\": {\n      \"type\": \"bubble\",\n      \"hero\": {\n        \"type\": \"image\",\n        \"size\": \"full\",\n        \"aspectRatio\": \"1:1\",\n        \"aspectMode\": \"cover\",\n        \"url\": \"https://storage.morningstella.com/api/v1/buckets/public/objects/download?preview=true&prefix=ache_part.png&version_id=null\",\n        \"action\": {\n          \"type\": \"uri\",\n          \"uri\": \"https://line.me/\"\n        }\n      },\n      \"body\": {\n        \"type\": \"box\",\n        \"layout\": \"vertical\",\n        \"spacing\": \"md\",\n        \"contents\": [\n          {\n            \"type\": \"text\",\n            \"text\": \"\u982d\u75db\u90e8\u4f4d\",\n            \"weight\": \"bold\",\n            \"size\": \"xl\",\n            \"align\": \"center\"\n          },\n          {\n            \"type\": \"text\",\n            \"text\": \"\u8acb\u9078\u64c7\u76ee\u524d\u982d\u75db\u7684\u90e8\u4f4d\",\n            \"size\": \"md\",\n            \"color\": \"#aaaaaa\",\n            \"align\": \"center\"\n          }\n        ]\n      },\n      \"footer\": {\n        \"type\": \"box\",\n        \"layout\": \"vertical\",\n        \"spacing\": \"sm\",\n        \"contents\": [\n          {\n            \"type\": \"box\",\n            \"layout\": \"horizontal\",\n            \"spacing\": \"sm\",\n            \"contents\": [\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"label\": \"\u5de6\u773c\u7aa9\",\n                  \"text\": \"\u5de6\u773c\u7aa9\u75db\",\n                  \"data\": \"headache_where=\u5de6\u773c\u7aa9;{{$json.existed_headache_where}} pain_level_tmp={{$json.pain_level}} headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#5CBEF7\",\n                \"height\": \"sm\"\n              },\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"label\": \"\u53f3\u773c\u7aa9\",\n                  \"text\": \"\u53f3\u773c\u7aa9\u75db\",\n                  \"data\": \"headache_where=\u53f3\u773c\u7aa9;{{$json.existed_headache_where}} pain_level_tmp={{$json.pain_level}} headache_occur_tmp={{$json.headache_occur}}\"\n                },\n                \"style\": \"primary\",\n                \"color\": \"#5CBEF7\",\n                \"height\": \"sm\"\n              }\n            ]\n          },\n          {\n            \"type\": \"box\",\n            \"layout\": \"horizontal\",\n            \"spacing\": \"sm\",\n            \"contents\": [\n              {\n                \"type\": \"button\",\n                \"action\": {\n                  \"type\": \"postback\",\n                  \"label\": \"\u5de6\u908a\u592a\u967d\u7a

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Headachetracker. Uses httpRequest. Webhook trigger; 42 nodes.

Source: https://github.com/MorningStella/HeadacheTracker/blob/21360ad567f6bb469384e18942e87e69f2ea9a37/n8n/workflow.json — original creator credit. Request a take-down →

More Web Scraping workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Web Scraping

This n8n template provides enterprise-level version control for your workflows using GitHub integration. Stop losing hours to broken workflows and manual exports – get proper commit history, visual di

n8n, Execute Workflow Trigger, HTTP Request +1
Web Scraping

This flow creates dummy files for every item added in your *Arrs (Radarr/Sonarr) with the tag .

HTTP Request, Ssh
Web Scraping

This workflow acts as a central API gateway for all technical indicator agents in the Binance Spot Market Quant AI system. It listens for incoming webhook requests and dynamically routes them to the c

HTTP Request
Web Scraping

Sign PDF documents with legally-compliant digital signatures using X.509 certificates. Supports multiple PAdES signature levels (B, T, LT, LTA) with optional visible stamps.

Execute Command, HTTP Request, Read Write File +1
Web Scraping

📡 This workflow serves as the central Alpha Vantage API fetcher for Tesla trading indicators, delivering cleaned 20-point JSON outputs for three timeframes: , , and . It is required by the following a

HTTP Request