{
  "name": "QuietPass — paid CRM contact checks (OFF)",
  "flow": [
    {
      "id": 1,
      "module": "hubspotcrm:WatchCRMObjects",
      "version": 2,
      "parameters": {
        "__IMTCONN__": null,
        "limit": 10,
        "objectType": "contacts",
        "parseCustomFields": true,
        "outputProperties": [
          "phone",
          "hs_country_region_code",
          "qp_phone_request_id"
        ],
        "watchPattern": "updated",
        "query": "",
        "filter": []
      },
      "mapper": {},
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0,
          "name": "Watch updated contacts"
        }
      }
    },
    {
      "id": 2,
      "module": "app#quietpass-kkwpuh:automationSettings",
      "version": 1,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {},
      "metadata": {
        "designer": {
          "x": 300,
          "y": 0,
          "name": "Get workflow spending limits"
        },
        "expect": [],
        "interface": [
          {
            "name": "available",
            "label": "Automation available",
            "type": "boolean"
          },
          {
            "name": "enabled",
            "label": "New purchases enabled",
            "type": "boolean"
          },
          {
            "name": "revision",
            "label": "Settings revision",
            "type": "uinteger"
          },
          {
            "name": "currency",
            "label": "Workspace currency",
            "type": "text"
          },
          {
            "name": "maxSpend",
            "label": "Maximum per lookup",
            "type": "text"
          },
          {
            "name": "dailyLimit",
            "label": "Maximum per day",
            "type": "text"
          },
          {
            "name": "heldAmount",
            "label": "Amount reserved",
            "type": "text"
          },
          {
            "name": "spentToday",
            "label": "Charged today",
            "type": "text"
          },
          {
            "name": "remainingToday",
            "label": "Available today",
            "type": "text"
          },
          {
            "name": "operations",
            "label": "Recent saved operations",
            "type": "array",
            "spec": [
              {
                "name": "id",
                "label": "Operation ID",
                "type": "text"
              },
              {
                "name": "state",
                "label": "State",
                "type": "text"
              },
              {
                "name": "quoteId",
                "label": "Quote ID",
                "type": "text"
              },
              {
                "name": "maxSpend",
                "label": "Maximum amount",
                "type": "text"
              },
              {
                "name": "chargedAmount",
                "label": "Charged amount",
                "type": "text"
              },
              {
                "name": "updated_at",
                "label": "Updated at (ISO 8601)",
                "type": "text"
              }
            ]
          }
        ]
      }
    },
    {
      "id": 3,
      "module": "hubspotcrm:MakeAPICall",
      "version": 2,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "/crm/v3/objects/contacts/{{1.id}}",
        "method": "GET",
        "qs": [
          {
            "key": "properties",
            "value": "phone,hs_country_region_code,qp_phone_e164,qp_phone_request_id"
          },
          {
            "key": "propertiesWithHistory",
            "value": "phone"
          }
        ]
      },
      "metadata": {
        "designer": {
          "x": 600,
          "y": 0,
          "name": "Read current source phone and its change history"
        }
      },
      "filter": {
        "name": "Customer enabled workflow purchases",
        "conditions": [
          [
            {
              "a": "{{2.available}}",
              "o": "text:equal",
              "b": "true"
            },
            {
              "a": "{{2.enabled}}",
              "o": "text:equal",
              "b": "true"
            }
          ]
        ]
      }
    },
    {
      "id": 4,
      "module": "app#quietpass-kkwpuh:formatPhone",
      "version": 1,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "phone": "{{3.body.properties.phone}}",
        "defaultCountry": "{{3.body.properties.hs_country_region_code}}"
      },
      "metadata": {
        "designer": {
          "x": 900,
          "y": 0,
          "name": "Format a phone number"
        },
        "expect": [
          {
            "name": "phone",
            "type": "text",
            "label": "Phone number",
            "required": true,
            "help": "Map one phone number. Use the country field for local numbers."
          },
          {
            "name": "defaultCountry",
            "type": "text",
            "label": "Default country for local numbers",
            "help": "Two-letter country code, such as GB or US. Leave blank for international input."
          }
        ],
        "interface": [
          {
            "name": "requestId",
            "label": "Request ID",
            "type": "text"
          },
          {
            "name": "mode",
            "label": "Mode",
            "type": "text"
          },
          {
            "name": "simulated",
            "label": "Simulated",
            "type": "boolean"
          },
          {
            "name": "preparedAt",
            "label": "Prepared at",
            "type": "date"
          },
          {
            "name": "number",
            "label": "Phone number",
            "type": "collection",
            "spec": [
              {
                "name": "e164",
                "label": "International number",
                "type": "text"
              },
              {
                "name": "national",
                "label": "National number",
                "type": "text"
              },
              {
                "name": "international",
                "label": "Formatted international number",
                "type": "text"
              },
              {
                "name": "country",
                "label": "Country",
                "type": "text"
              },
              {
                "name": "valid",
                "label": "Numbering plan valid",
                "type": "boolean"
              },
              {
                "name": "validationReason",
                "label": "Validation reason",
                "type": "text"
              },
              {
                "name": "type",
                "label": "Line type",
                "type": "text"
              },
              {
                "name": "typeReason",
                "label": "Line type unavailable reason",
                "type": "text"
              },
              {
                "name": "carrier",
                "label": "Current carrier",
                "type": "text"
              },
              {
                "name": "carrierReason",
                "label": "Carrier unavailable reason",
                "type": "text"
              },
              {
                "name": "ported",
                "label": "Ported",
                "type": "boolean"
              },
              {
                "name": "portedReason",
                "label": "Porting unavailable reason",
                "type": "text"
              }
            ]
          },
          {
            "name": "contact",
            "label": "Contact options",
            "type": "collection",
            "spec": [
              {
                "name": "sms",
                "label": "SMS support",
                "type": "collection",
                "spec": [
                  {
                    "name": "supported",
                    "label": "Supported",
                    "type": "boolean"
                  },
                  {
                    "name": "assumed",
                    "label": "Assumed from line type",
                    "type": "boolean"
                  },
                  {
                    "name": "basis",
                    "label": "Evidence basis",
                    "type": "text"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "whatsapp",
                "label": "WhatsApp registration",
                "type": "collection",
                "spec": [
                  {
                    "name": "registered",
                    "label": "Registered",
                    "type": "boolean"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "telegram",
                "label": "Telegram registration",
                "type": "collection",
                "spec": [
                  {
                    "name": "registered",
                    "label": "Registered",
                    "type": "boolean"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              }
            ]
          },
          {
            "name": "network",
            "label": "Network status",
            "type": "collection",
            "spec": [
              {
                "name": "reachable",
                "label": "Reachable",
                "type": "boolean"
              },
              {
                "name": "reason",
                "label": "Unavailable reason",
                "type": "text"
              }
            ]
          },
          {
            "name": "billing",
            "label": "Charge receipt",
            "type": "collection",
            "spec": [
              {
                "name": "currency",
                "label": "Currency",
                "type": "text"
              },
              {
                "name": "amount",
                "label": "Billed amount",
                "type": "text"
              }
            ]
          }
        ]
      },
      "onerror": [
        {
          "id": 104,
          "module": "builtin:Ignore",
          "version": 1,
          "parameters": {},
          "mapper": {},
          "metadata": {
            "designer": {
              "x": 900,
              "y": 250,
              "name": "Leave failed free formatting for review; never purchase"
            }
          }
        }
      ]
    },
    {
      "id": 5,
      "module": "app#quietpass-kkwpuh:prepareAutomation",
      "version": 1,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "phone": "{{4.number.e164}}",
        "workflowId": "hubspot:REPLACE_HUBSPOT_PORTAL_ID:contacts-v1",
        "recordId": "{{1.id}}",
        "revision": "{{get(first(sort(3.body.propertiesWithHistory.phone; desc; \"timestamp\")); \"timestamp\")}}",
        "checks": [
          "basic_line_type",
          "enhanced_line_type",
          "current_carrier",
          "mnp",
          "live_status",
          "sms",
          "whatsapp",
          "telegram"
        ],
        "currency": "{{2.currency}}",
        "maxSpend": "0.00"
      },
      "metadata": {
        "designer": {
          "x": 1200,
          "y": 0,
          "name": "Prepare a saved phone check"
        },
        "expect": [
          {
            "name": "phone",
            "type": "text",
            "label": "Phone number",
            "required": true,
            "help": "Map one phone number. Use the country field for local numbers."
          },
          {
            "name": "defaultCountry",
            "type": "text",
            "label": "Default country for local numbers",
            "help": "Two-letter country code, such as GB or US. Leave blank for international input."
          },
          {
            "name": "workflowId",
            "type": "text",
            "label": "Workflow ID",
            "required": true,
            "help": "A fixed identifier for this automation. Never use the current execution ID."
          },
          {
            "name": "recordId",
            "type": "text",
            "label": "Immutable source record ID",
            "required": true,
            "help": "A contact ID or a permanent sheet row ID, not its row position."
          },
          {
            "name": "revision",
            "type": "text",
            "label": "Source phone revision",
            "required": true,
            "help": "The source phone-change revision. Preserve it on retries and result writes."
          },
          {
            "name": "checks",
            "type": "select",
            "label": "Checks",
            "required": true,
            "multiple": true,
            "options": [
              {
                "label": "Number details",
                "value": "basic_line_type"
              },
              {
                "label": "Detailed number type",
                "value": "enhanced_line_type"
              },
              {
                "label": "Current network",
                "value": "current_carrier"
              },
              {
                "label": "Number ported",
                "value": "mnp"
              },
              {
                "label": "Live number status",
                "value": "live_status"
              },
              {
                "label": "Landline SMS enablement",
                "value": "sms"
              },
              {
                "label": "WhatsApp",
                "value": "whatsapp"
              },
              {
                "label": "Telegram",
                "value": "telegram"
              }
            ]
          },
          {
            "name": "currency",
            "type": "select",
            "label": "Workspace currency",
            "required": true,
            "options": [
              {
                "label": "GBP",
                "value": "GBP"
              },
              {
                "label": "USD",
                "value": "USD"
              },
              {
                "label": "EUR",
                "value": "EUR"
              }
            ]
          },
          {
            "name": "maxSpend",
            "type": "text",
            "label": "Maximum per lookup",
            "required": true,
            "default": "0.00",
            "help": "Use 0.00 for free Number details, or an amount such as 0.05 for both paid packages. This cannot exceed your Connected tools limit."
          }
        ],
        "interface": [
          {
            "name": "id",
            "label": "Saved operation ID",
            "type": "text"
          },
          {
            "name": "state",
            "label": "Operation state",
            "type": "text"
          },
          {
            "name": "quoteId",
            "label": "Original quote ID",
            "type": "text"
          },
          {
            "name": "maxSpend",
            "label": "Maximum amount",
            "type": "text"
          },
          {
            "name": "heldAmount",
            "label": "Amount reserved",
            "type": "text"
          },
          {
            "name": "chargedAmount",
            "label": "Charged amount",
            "type": "text"
          },
          {
            "name": "resultState",
            "label": "Saved result state",
            "type": "text"
          },
          {
            "name": "result",
            "label": "Phone check result",
            "type": "collection",
            "spec": [
              {
                "name": "requestId",
                "label": "Request ID",
                "type": "text"
              },
              {
                "name": "mode",
                "label": "Mode",
                "type": "text"
              },
              {
                "name": "simulated",
                "label": "Simulated",
                "type": "boolean"
              },
              {
                "name": "preparedAt",
                "label": "Prepared at",
                "type": "date"
              },
              {
                "name": "number",
                "label": "Phone number",
                "type": "collection",
                "spec": [
                  {
                    "name": "e164",
                    "label": "International number",
                    "type": "text"
                  },
                  {
                    "name": "national",
                    "label": "National number",
                    "type": "text"
                  },
                  {
                    "name": "international",
                    "label": "Formatted international number",
                    "type": "text"
                  },
                  {
                    "name": "country",
                    "label": "Country",
                    "type": "text"
                  },
                  {
                    "name": "valid",
                    "label": "Numbering plan valid",
                    "type": "boolean"
                  },
                  {
                    "name": "validationReason",
                    "label": "Validation reason",
                    "type": "text"
                  },
                  {
                    "name": "type",
                    "label": "Line type",
                    "type": "text"
                  },
                  {
                    "name": "typeReason",
                    "label": "Line type unavailable reason",
                    "type": "text"
                  },
                  {
                    "name": "carrier",
                    "label": "Current carrier",
                    "type": "text"
                  },
                  {
                    "name": "carrierReason",
                    "label": "Carrier unavailable reason",
                    "type": "text"
                  },
                  {
                    "name": "ported",
                    "label": "Ported",
                    "type": "boolean"
                  },
                  {
                    "name": "portedReason",
                    "label": "Porting unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "contact",
                "label": "Contact options",
                "type": "collection",
                "spec": [
                  {
                    "name": "sms",
                    "label": "SMS support",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "supported",
                        "label": "Supported",
                        "type": "boolean"
                      },
                      {
                        "name": "assumed",
                        "label": "Assumed from line type",
                        "type": "boolean"
                      },
                      {
                        "name": "basis",
                        "label": "Evidence basis",
                        "type": "text"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  },
                  {
                    "name": "whatsapp",
                    "label": "WhatsApp registration",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "registered",
                        "label": "Registered",
                        "type": "boolean"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  },
                  {
                    "name": "telegram",
                    "label": "Telegram registration",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "registered",
                        "label": "Registered",
                        "type": "boolean"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  }
                ]
              },
              {
                "name": "network",
                "label": "Network status",
                "type": "collection",
                "spec": [
                  {
                    "name": "reachable",
                    "label": "Reachable",
                    "type": "boolean"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "billing",
                "label": "Charge receipt",
                "type": "collection",
                "spec": [
                  {
                    "name": "currency",
                    "label": "Currency",
                    "type": "text"
                  },
                  {
                    "name": "amount",
                    "label": "Billed amount",
                    "type": "text"
                  }
                ]
              }
            ]
          }
        ]
      },
      "filter": {
        "name": "Valid phone with a real phone-change revision",
        "conditions": [
          [
            {
              "a": "{{4.number.valid}}",
              "o": "text:equal",
              "b": "true"
            },
            {
              "a": "{{get(first(sort(3.body.propertiesWithHistory.phone; desc; \"timestamp\")); \"timestamp\")}}",
              "o": "exist"
            }
          ]
        ]
      }
    },
    {
      "id": 6,
      "module": "app#quietpass-kkwpuh:runAutomation",
      "version": 1,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "operationId": "{{5.id}}",
        "allowPaid": false
      },
      "metadata": {
        "designer": {
          "x": 1500,
          "y": 0,
          "name": "Run a saved phone check"
        },
        "expect": [
          {
            "name": "operationId",
            "type": "text",
            "label": "Saved operation ID",
            "required": true
          },
          {
            "name": "allowPaid",
            "type": "boolean",
            "label": "Allow credit use",
            "required": true,
            "default": false
          }
        ],
        "interface": [
          {
            "name": "id",
            "label": "Saved operation ID",
            "type": "text"
          },
          {
            "name": "state",
            "label": "Operation state",
            "type": "text"
          },
          {
            "name": "quoteId",
            "label": "Original quote ID",
            "type": "text"
          },
          {
            "name": "maxSpend",
            "label": "Maximum amount",
            "type": "text"
          },
          {
            "name": "heldAmount",
            "label": "Amount reserved",
            "type": "text"
          },
          {
            "name": "chargedAmount",
            "label": "Charged amount",
            "type": "text"
          },
          {
            "name": "resultState",
            "label": "Saved result state",
            "type": "text"
          },
          {
            "name": "result",
            "label": "Phone check result",
            "type": "collection",
            "spec": [
              {
                "name": "requestId",
                "label": "Request ID",
                "type": "text"
              },
              {
                "name": "mode",
                "label": "Mode",
                "type": "text"
              },
              {
                "name": "simulated",
                "label": "Simulated",
                "type": "boolean"
              },
              {
                "name": "preparedAt",
                "label": "Prepared at",
                "type": "date"
              },
              {
                "name": "number",
                "label": "Phone number",
                "type": "collection",
                "spec": [
                  {
                    "name": "e164",
                    "label": "International number",
                    "type": "text"
                  },
                  {
                    "name": "national",
                    "label": "National number",
                    "type": "text"
                  },
                  {
                    "name": "international",
                    "label": "Formatted international number",
                    "type": "text"
                  },
                  {
                    "name": "country",
                    "label": "Country",
                    "type": "text"
                  },
                  {
                    "name": "valid",
                    "label": "Numbering plan valid",
                    "type": "boolean"
                  },
                  {
                    "name": "validationReason",
                    "label": "Validation reason",
                    "type": "text"
                  },
                  {
                    "name": "type",
                    "label": "Line type",
                    "type": "text"
                  },
                  {
                    "name": "typeReason",
                    "label": "Line type unavailable reason",
                    "type": "text"
                  },
                  {
                    "name": "carrier",
                    "label": "Current carrier",
                    "type": "text"
                  },
                  {
                    "name": "carrierReason",
                    "label": "Carrier unavailable reason",
                    "type": "text"
                  },
                  {
                    "name": "ported",
                    "label": "Ported",
                    "type": "boolean"
                  },
                  {
                    "name": "portedReason",
                    "label": "Porting unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "contact",
                "label": "Contact options",
                "type": "collection",
                "spec": [
                  {
                    "name": "sms",
                    "label": "SMS support",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "supported",
                        "label": "Supported",
                        "type": "boolean"
                      },
                      {
                        "name": "assumed",
                        "label": "Assumed from line type",
                        "type": "boolean"
                      },
                      {
                        "name": "basis",
                        "label": "Evidence basis",
                        "type": "text"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  },
                  {
                    "name": "whatsapp",
                    "label": "WhatsApp registration",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "registered",
                        "label": "Registered",
                        "type": "boolean"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  },
                  {
                    "name": "telegram",
                    "label": "Telegram registration",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "registered",
                        "label": "Registered",
                        "type": "boolean"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  }
                ]
              },
              {
                "name": "network",
                "label": "Network status",
                "type": "collection",
                "spec": [
                  {
                    "name": "reachable",
                    "label": "Reachable",
                    "type": "boolean"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "billing",
                "label": "Charge receipt",
                "type": "collection",
                "spec": [
                  {
                    "name": "currency",
                    "label": "Currency",
                    "type": "text"
                  },
                  {
                    "name": "amount",
                    "label": "Billed amount",
                    "type": "text"
                  }
                ]
              }
            ]
          }
        ]
      }
    },
    {
      "id": 7,
      "module": "app#quietpass-kkwpuh:recoverAutomation",
      "version": 1,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "operationId": "{{5.id}}"
      },
      "metadata": {
        "designer": {
          "x": 1800,
          "y": 0,
          "name": "Get a saved phone check"
        },
        "expect": [
          {
            "name": "operationId",
            "type": "text",
            "label": "Saved operation ID",
            "required": true
          }
        ],
        "interface": [
          {
            "name": "id",
            "label": "Saved operation ID",
            "type": "text"
          },
          {
            "name": "state",
            "label": "Operation state",
            "type": "text"
          },
          {
            "name": "quoteId",
            "label": "Original quote ID",
            "type": "text"
          },
          {
            "name": "maxSpend",
            "label": "Maximum amount",
            "type": "text"
          },
          {
            "name": "heldAmount",
            "label": "Amount reserved",
            "type": "text"
          },
          {
            "name": "chargedAmount",
            "label": "Charged amount",
            "type": "text"
          },
          {
            "name": "resultState",
            "label": "Saved result state",
            "type": "text"
          },
          {
            "name": "result",
            "label": "Phone check result",
            "type": "collection",
            "spec": [
              {
                "name": "requestId",
                "label": "Request ID",
                "type": "text"
              },
              {
                "name": "mode",
                "label": "Mode",
                "type": "text"
              },
              {
                "name": "simulated",
                "label": "Simulated",
                "type": "boolean"
              },
              {
                "name": "preparedAt",
                "label": "Prepared at",
                "type": "date"
              },
              {
                "name": "number",
                "label": "Phone number",
                "type": "collection",
                "spec": [
                  {
                    "name": "e164",
                    "label": "International number",
                    "type": "text"
                  },
                  {
                    "name": "national",
                    "label": "National number",
                    "type": "text"
                  },
                  {
                    "name": "international",
                    "label": "Formatted international number",
                    "type": "text"
                  },
                  {
                    "name": "country",
                    "label": "Country",
                    "type": "text"
                  },
                  {
                    "name": "valid",
                    "label": "Numbering plan valid",
                    "type": "boolean"
                  },
                  {
                    "name": "validationReason",
                    "label": "Validation reason",
                    "type": "text"
                  },
                  {
                    "name": "type",
                    "label": "Line type",
                    "type": "text"
                  },
                  {
                    "name": "typeReason",
                    "label": "Line type unavailable reason",
                    "type": "text"
                  },
                  {
                    "name": "carrier",
                    "label": "Current carrier",
                    "type": "text"
                  },
                  {
                    "name": "carrierReason",
                    "label": "Carrier unavailable reason",
                    "type": "text"
                  },
                  {
                    "name": "ported",
                    "label": "Ported",
                    "type": "boolean"
                  },
                  {
                    "name": "portedReason",
                    "label": "Porting unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "contact",
                "label": "Contact options",
                "type": "collection",
                "spec": [
                  {
                    "name": "sms",
                    "label": "SMS support",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "supported",
                        "label": "Supported",
                        "type": "boolean"
                      },
                      {
                        "name": "assumed",
                        "label": "Assumed from line type",
                        "type": "boolean"
                      },
                      {
                        "name": "basis",
                        "label": "Evidence basis",
                        "type": "text"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  },
                  {
                    "name": "whatsapp",
                    "label": "WhatsApp registration",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "registered",
                        "label": "Registered",
                        "type": "boolean"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  },
                  {
                    "name": "telegram",
                    "label": "Telegram registration",
                    "type": "collection",
                    "spec": [
                      {
                        "name": "registered",
                        "label": "Registered",
                        "type": "boolean"
                      },
                      {
                        "name": "reason",
                        "label": "Unavailable reason",
                        "type": "text"
                      }
                    ]
                  }
                ]
              },
              {
                "name": "network",
                "label": "Network status",
                "type": "collection",
                "spec": [
                  {
                    "name": "reachable",
                    "label": "Reachable",
                    "type": "boolean"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "billing",
                "label": "Charge receipt",
                "type": "collection",
                "spec": [
                  {
                    "name": "currency",
                    "label": "Currency",
                    "type": "text"
                  },
                  {
                    "name": "amount",
                    "label": "Billed amount",
                    "type": "text"
                  }
                ]
              }
            ]
          }
        ]
      }
    },
    {
      "id": 8,
      "module": "hubspotcrm:MakeAPICall",
      "version": 2,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "/crm/v3/objects/contacts/{{1.id}}",
        "method": "GET",
        "qs": [
          {
            "key": "properties",
            "value": "phone,hs_country_region_code,qp_phone_e164,qp_phone_request_id"
          },
          {
            "key": "propertiesWithHistory",
            "value": "phone"
          }
        ]
      },
      "metadata": {
        "designer": {
          "x": 2100,
          "y": 0,
          "name": "Read current source phone and its change history"
        }
      },
      "filter": {
        "name": "Only a settled retained result may be written",
        "conditions": [
          [
            {
              "a": "{{7.state}}",
              "o": "text:equal",
              "b": "settled"
            },
            {
              "a": "{{7.resultState}}",
              "o": "text:equal",
              "b": "settled"
            },
            {
              "a": "{{7.result.requestId}}",
              "o": "exist"
            }
          ]
        ]
      }
    },
    {
      "id": 9,
      "module": "app#quietpass-kkwpuh:formatPhone",
      "version": 1,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "phone": "{{8.body.properties.phone}}",
        "defaultCountry": "{{8.body.properties.hs_country_region_code}}"
      },
      "metadata": {
        "designer": {
          "x": 2400,
          "y": 0,
          "name": "Format a phone number"
        },
        "expect": [
          {
            "name": "phone",
            "type": "text",
            "label": "Phone number",
            "required": true,
            "help": "Map one phone number. Use the country field for local numbers."
          },
          {
            "name": "defaultCountry",
            "type": "text",
            "label": "Default country for local numbers",
            "help": "Two-letter country code, such as GB or US. Leave blank for international input."
          }
        ],
        "interface": [
          {
            "name": "requestId",
            "label": "Request ID",
            "type": "text"
          },
          {
            "name": "mode",
            "label": "Mode",
            "type": "text"
          },
          {
            "name": "simulated",
            "label": "Simulated",
            "type": "boolean"
          },
          {
            "name": "preparedAt",
            "label": "Prepared at",
            "type": "date"
          },
          {
            "name": "number",
            "label": "Phone number",
            "type": "collection",
            "spec": [
              {
                "name": "e164",
                "label": "International number",
                "type": "text"
              },
              {
                "name": "national",
                "label": "National number",
                "type": "text"
              },
              {
                "name": "international",
                "label": "Formatted international number",
                "type": "text"
              },
              {
                "name": "country",
                "label": "Country",
                "type": "text"
              },
              {
                "name": "valid",
                "label": "Numbering plan valid",
                "type": "boolean"
              },
              {
                "name": "validationReason",
                "label": "Validation reason",
                "type": "text"
              },
              {
                "name": "type",
                "label": "Line type",
                "type": "text"
              },
              {
                "name": "typeReason",
                "label": "Line type unavailable reason",
                "type": "text"
              },
              {
                "name": "carrier",
                "label": "Current carrier",
                "type": "text"
              },
              {
                "name": "carrierReason",
                "label": "Carrier unavailable reason",
                "type": "text"
              },
              {
                "name": "ported",
                "label": "Ported",
                "type": "boolean"
              },
              {
                "name": "portedReason",
                "label": "Porting unavailable reason",
                "type": "text"
              }
            ]
          },
          {
            "name": "contact",
            "label": "Contact options",
            "type": "collection",
            "spec": [
              {
                "name": "sms",
                "label": "SMS support",
                "type": "collection",
                "spec": [
                  {
                    "name": "supported",
                    "label": "Supported",
                    "type": "boolean"
                  },
                  {
                    "name": "assumed",
                    "label": "Assumed from line type",
                    "type": "boolean"
                  },
                  {
                    "name": "basis",
                    "label": "Evidence basis",
                    "type": "text"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "whatsapp",
                "label": "WhatsApp registration",
                "type": "collection",
                "spec": [
                  {
                    "name": "registered",
                    "label": "Registered",
                    "type": "boolean"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              },
              {
                "name": "telegram",
                "label": "Telegram registration",
                "type": "collection",
                "spec": [
                  {
                    "name": "registered",
                    "label": "Registered",
                    "type": "boolean"
                  },
                  {
                    "name": "reason",
                    "label": "Unavailable reason",
                    "type": "text"
                  }
                ]
              }
            ]
          },
          {
            "name": "network",
            "label": "Network status",
            "type": "collection",
            "spec": [
              {
                "name": "reachable",
                "label": "Reachable",
                "type": "boolean"
              },
              {
                "name": "reason",
                "label": "Unavailable reason",
                "type": "text"
              }
            ]
          },
          {
            "name": "billing",
            "label": "Charge receipt",
            "type": "collection",
            "spec": [
              {
                "name": "currency",
                "label": "Currency",
                "type": "text"
              },
              {
                "name": "amount",
                "label": "Billed amount",
                "type": "text"
              }
            ]
          }
        ]
      },
      "onerror": [
        {
          "id": 109,
          "module": "builtin:Ignore",
          "version": 1,
          "parameters": {},
          "mapper": {},
          "metadata": {
            "designer": {
              "x": 2400,
              "y": 250,
              "name": "Leave failed free formatting for review; never purchase"
            }
          }
        }
      ]
    },
    {
      "id": 10,
      "module": "hubspotcrm:MakeAPICall",
      "version": 2,
      "parameters": {
        "__IMTCONN__": null
      },
      "mapper": {
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "/crm/v3/objects/contacts/{{1.id}}",
        "method": "PATCH",
        "body": "{\"properties\":{\"qp_phone_e164\":\"{{escapeJSON(if(7.result.number.e164 = null; emptystring; 7.result.number.e164))}}\",\"qp_phone_country\":\"{{escapeJSON(if(7.result.number.country = null; emptystring; 7.result.number.country))}}\",\"qp_phone_valid\":\"{{if(7.result.number.valid = null; emptystring; 7.result.number.valid)}}\",\"qp_phone_type\":\"{{escapeJSON(if(7.result.number.type = null; emptystring; 7.result.number.type))}}\",\"qp_phone_carrier\":\"{{escapeJSON(if(7.result.number.carrier = null; emptystring; 7.result.number.carrier))}}\",\"qp_phone_ported\":\"{{if(7.result.number.ported = null; emptystring; 7.result.number.ported)}}\",\"qp_phone_sms\":\"{{if(7.result.contact.sms.supported = null; emptystring; 7.result.contact.sms.supported)}}\",\"qp_phone_sms_basis\":\"{{escapeJSON(if(7.result.contact.sms.basis = null; emptystring; 7.result.contact.sms.basis))}}\",\"qp_phone_whatsapp\":\"{{if(7.result.contact.whatsapp.registered = null; emptystring; 7.result.contact.whatsapp.registered)}}\",\"qp_phone_telegram\":\"{{if(7.result.contact.telegram.registered = null; emptystring; 7.result.contact.telegram.registered)}}\",\"qp_phone_reachable\":\"{{if(7.result.network.reachable = null; emptystring; 7.result.network.reachable)}}\",\"qp_phone_status\":\"checked\",\"qp_phone_reason\":\"{{escapeJSON(if(ifempty(7.result.number.validationReason; ifempty(7.result.network.reason; emptystring)) = null; emptystring; ifempty(7.result.number.validationReason; ifempty(7.result.network.reason; emptystring))))}}\",\"qp_phone_checked_at\":\"{{escapeJSON(if(7.result.preparedAt = null; emptystring; 7.result.preparedAt))}}\",\"qp_phone_request_id\":\"{{escapeJSON(if(7.result.requestId = null; emptystring; 7.result.requestId))}}\"}}"
      },
      "metadata": {
        "designer": {
          "x": 2700,
          "y": 0,
          "name": "Write only QuietPass fields if the source phone is unchanged"
        }
      },
      "filter": {
        "name": "Same source revision and phone; never overwrite a newer result",
        "conditions": [
          [
            {
              "a": "{{get(first(sort(8.body.propertiesWithHistory.phone; desc; \"timestamp\")); \"timestamp\")}}",
              "o": "text:equal",
              "b": "{{get(first(sort(3.body.propertiesWithHistory.phone; desc; \"timestamp\")); \"timestamp\")}}"
            },
            {
              "a": "{{9.number.e164}}",
              "o": "text:equal",
              "b": "{{7.result.number.e164}}"
            },
            {
              "a": "{{8.body.properties.qp_phone_request_id}}",
              "o": "text:notequal",
              "b": "{{7.result.requestId}}"
            },
            {
              "a": "{{9.number.valid}}",
              "o": "text:equal",
              "b": "true"
            }
          ]
        ]
      }
    }
  ],
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": true,
      "slots": null,
      "confidential": false,
      "dataloss": false,
      "dlq": true,
      "freshVariables": false
    },
    "designer": {
      "orphans": []
    },
    "zone": "eu1.make.com",
    "notes": []
  }
}
