{
  "name": "FlowPantry - overdue-invoice-reminders",
  "flow": [
    {
      "id": 1,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {},
      "mapper": {
        "url": "INVOICES_URL",
        "method": "get",
        "headers": [],
        "qs": [],
        "serializeUrl": false,
        "parseResponse": true,
        "shareCookies": false,
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "timeout": ""
      },
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0
        }
      }
    },
    {
      "id": 2,
      "module": "builtin:BasicFeeder",
      "version": 1,
      "parameters": {},
      "mapper": {
        "array": "{{1.data}}"
      },
      "metadata": {
        "designer": {
          "x": 300,
          "y": 0
        }
      }
    },
    {
      "id": 3,
      "module": "builtin:BasicRouter",
      "version": 1,
      "parameters": {},
      "metadata": {
        "designer": {
          "x": 600,
          "y": 0
        }
      },
      "routes": [
        {
          "flow": [
            {
              "id": 4,
              "module": "http:ActionSendData",
              "version": 3,
              "parameters": {},
              "mapper": {
                "url": "https://api.resend.com/emails",
                "method": "post",
                "headers": [
                  {
                    "name": "Authorization",
                    "value": "Bearer YOUR_RESEND_API_KEY"
                  }
                ],
                "qs": [],
                "serializeUrl": false,
                "parseResponse": true,
                "shareCookies": false,
                "rejectUnauthorized": true,
                "followRedirect": true,
                "useQuerystring": false,
                "gzip": true,
                "useMtls": false,
                "timeout": "",
                "bodyType": "raw",
                "contentType": "application/json",
                "inputMethod": "jsonString",
                "data": "{\"from\": \"YOUR_NAME <you@yourdomain.com>\", \"to\": \"{{2.email}}\", \"subject\": \"Friendly reminder: invoice #{{2.id}} from YOUR BUSINESS\", \"text\": \"Hi {{2.customer_name}}, just a friendly reminder that invoice #{{2.id}} for ${{2.amount}} was due on {{2.due_date}}. Pay here: {{2.payment_url}}\\n\\n\\u2014 YOUR BUSINESS\"}"
              },
              "metadata": {
                "designer": {
                  "x": 900,
                  "y": -150
                }
              },
              "filter": {
                "name": "Day 7 overdue, not yet reminded",
                "conditions": [
                  [
                    {
                      "a": "{{2.status}}",
                      "o": "text:notequal",
                      "b": "paid"
                    },
                    {
                      "a": "{{2.reminder_stage}}",
                      "o": "number:less",
                      "b": "7"
                    }
                  ]
                ]
              }
            }
          ]
        },
        {
          "flow": [
            {
              "id": 5,
              "module": "http:ActionSendData",
              "version": 3,
              "parameters": {},
              "mapper": {
                "url": "https://api.resend.com/emails",
                "method": "post",
                "headers": [
                  {
                    "name": "Authorization",
                    "value": "Bearer YOUR_RESEND_API_KEY"
                  }
                ],
                "qs": [],
                "serializeUrl": false,
                "parseResponse": true,
                "shareCookies": false,
                "rejectUnauthorized": true,
                "followRedirect": true,
                "useQuerystring": false,
                "gzip": true,
                "useMtls": false,
                "timeout": "",
                "bodyType": "raw",
                "contentType": "application/json",
                "inputMethod": "jsonString",
                "data": "{\"from\": \"YOUR_NAME <you@yourdomain.com>\", \"to\": \"{{2.email}}\", \"subject\": \"Invoice #{{2.id}} is past due\", \"text\": \"Hi {{2.customer_name}}, invoice #{{2.id}} for ${{2.amount}} is past due. Please pay: {{2.payment_url}}\\n\\n\\u2014 YOUR BUSINESS\"}"
              },
              "metadata": {
                "designer": {
                  "x": 900,
                  "y": 0
                }
              },
              "filter": {
                "name": "Day 14 overdue, stage < 14",
                "conditions": [
                  [
                    {
                      "a": "{{2.status}}",
                      "o": "text:notequal",
                      "b": "paid"
                    },
                    {
                      "a": "{{2.reminder_stage}}",
                      "o": "number:less",
                      "b": "14"
                    }
                  ]
                ]
              }
            }
          ]
        },
        {
          "flow": [
            {
              "id": 6,
              "module": "http:ActionSendData",
              "version": 3,
              "parameters": {},
              "mapper": {
                "url": "https://api.resend.com/emails",
                "method": "post",
                "headers": [
                  {
                    "name": "Authorization",
                    "value": "Bearer YOUR_RESEND_API_KEY"
                  }
                ],
                "qs": [],
                "serializeUrl": false,
                "parseResponse": true,
                "shareCookies": false,
                "rejectUnauthorized": true,
                "followRedirect": true,
                "useQuerystring": false,
                "gzip": true,
                "useMtls": false,
                "timeout": "",
                "bodyType": "raw",
                "contentType": "application/json",
                "inputMethod": "jsonString",
                "data": "{\"from\": \"YOUR_NAME <you@yourdomain.com>\", \"to\": \"{{2.email}}\", \"subject\": \"Final notice: invoice #{{2.id}}\", \"text\": \"Hi {{2.customer_name}}, final notice that invoice #{{2.id}} for ${{2.amount}} is overdue. Pay here: {{2.payment_url}}\\n\\n\\u2014 YOUR BUSINESS\"}"
              },
              "metadata": {
                "designer": {
                  "x": 900,
                  "y": 150
                }
              },
              "filter": {
                "name": "Day 30 overdue, stage < 30",
                "conditions": [
                  [
                    {
                      "a": "{{2.status}}",
                      "o": "text:notequal",
                      "b": "paid"
                    },
                    {
                      "a": "{{2.reminder_stage}}",
                      "o": "number:less",
                      "b": "30"
                    }
                  ]
                ]
              }
            },
            {
              "id": 7,
              "module": "http:ActionSendData",
              "version": 3,
              "parameters": {},
              "mapper": {
                "url": "https://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_SID/Messages.json",
                "method": "post",
                "headers": [],
                "qs": [],
                "serializeUrl": false,
                "parseResponse": true,
                "shareCookies": false,
                "rejectUnauthorized": true,
                "followRedirect": true,
                "useQuerystring": false,
                "gzip": true,
                "useMtls": false,
                "timeout": "",
                "username": "YOUR_TWILIO_SID",
                "password": "YOUR_TWILIO_AUTH_TOKEN",
                "bodyType": "x_www_form_urlencoded",
                "data": "",
                "formFields": [
                  {
                    "key": "To",
                    "value": "OWNER_PHONE"
                  },
                  {
                    "key": "From",
                    "value": "YOUR_TWILIO_NUMBER"
                  },
                  {
                    "key": "Body",
                    "value": "Invoice #{{2.id}} for {{2.customer_name}} ({{2.amount}}) is 30+ days overdue. Call them."
                  }
                ]
              },
              "metadata": {
                "designer": {
                  "x": 1200,
                  "y": 150
                }
              }
            }
          ]
        }
      ]
    }
  ],
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "slots": null,
      "confidential": false,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": {
      "orphans": []
    },
    "zone": "us1.make.com"
  }
}