{
  "name": "Consultorio.me Daily Reminders",
  "nodes": [
    {
      "id": "1f6dda04-4b27-4147-8a70-a4ca8981922c",
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 2,
      "position": [
        260,
        280
      ],
      "parameters": {
        "triggerTimes": [
          {
            "hour": 8,
            "minute": 0
          }
        ]
      }
    },
    {
      "id": "d84eb5bf-97fa-4a78-99d8-7827ca0ee13c",
      "name": "Get Token",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        520,
        280
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.consultoriome.com/v1/api/authorization/token",
        "jsonParameters": false,
        "options": {},
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "Basic xxx"
            }
          ]
        }
      }
    },
    {
      "id": "884e55a7-afa3-400e-99c7-b57ae4c43641",
      "name": "Set Date",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        780,
        280
      ],
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "date",
              "value": "={{ (new Date(Date.now() + 24*60*60*1000)).toISOString().slice(0,10) }}"
            }
          ]
        }
      }
    },
    {
      "id": "40583da0-3ebd-4e53-a4a1-992731b1f876",
      "name": "Get Appointments",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1040,
        280
      ],
      "parameters": {
        "method": "GET",
        "url": "={{`https://api.consultoriome.com/v1/api/messenger/appointments/${$node[\"Set Date\"].json[\"date\"]}`}}",
        "jsonParameters": false,
        "options": {},
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "={{`Bearer ${$node[\"Get Token\"].json[\"accessToken\"]}`}}"
            }
          ]
        }
      }
    },
    {
      "id": "7ef1e9bf-db36-4d20-b614-d44ade673236",
      "name": "Prepare Messages",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1300,
        280
      ],
      "parameters": {
        "language": "JavaScript",
        "jsCode": "const result = [];\n\nfor (const item of items) {\n  const a = item.json;\n\n  if (!a.PhoneNumber1 || !a.Message) {\n    continue;\n  }\n\n  result.push({\n    json: {\n      body: a.Message,\n      number: a.PhoneNumber1,\n   },\n  });\n}\n\nreturn result;"
      }
    },
    {
      "id": "f4f703d4-68be-4602-a897-d895abcdb00f",
      "name": "Send to Delivery Service",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1560,
        280
      ],
      "parameters": {
        "method": "POST",
        "url": "https://change_the_address/v1/api/external/change_the_endpoint",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={{$json}}",
        "headerParametersUi": {
          "parameter": [
            {
              "name": "Authorization",
              "value": "Bearer xxxxxxx"
            }
          ]
        }
      }
    }
  ],
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "Get Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Token": {
      "main": [
        [
          {
            "node": "Set Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Date": {
      "main": [
        [
          {
            "node": "Get Appointments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Appointments": {
      "main": [
        [
          {
            "node": "Prepare Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Messages": {
      "main": [
        [
          {
            "node": "Send to Delivery Service",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "versionId": "00000000-0000-0000-0000-000000000000"
}
