{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "C5A5DB8D-0C9F-4156-B6DA-5E2ED6280D2D",
    "name": "Front: quick pay and remit-to requests to AP"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -70,
        "y": 0,
        "zoom": 1
      },
      "autoSave": false,
      "descriptions": {
        "flow": "Reads each new email in the AP inbox in Front, picks out quick pay requests, remit-to changes and notices of assignment, checks the load and its POD in McLeod, assigns the conversation to AP and posts what to check as a comment.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Reads each new email in the AP inbox in Front, picks out quick pay requests, remit-to changes and notices of assignment, checks the load and its POD in McLeod, assigns the conversation to AP and posts what to check as a comment.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 800,
            "y": 49
          }
        },
        "flowElementId": "3E2B3D3C-6392-4560-995E-4E4FA09D978A",
        "groupId": null,
        "id": "9797469B-38D5-4661-AC74-DC5C76CD256D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "ac7be0da-12d5-4b80-b536-4c2ccdfe865f",
                "nestedOperation": null,
                "operation": "notEqual",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Request",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "kind",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "B9400825-06BF-4533-8B12-682AFBC941C2"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "other"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "ac7be0da-12d5-4b80-b536-4c2ccdfe865f"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Quick pay or remit-to",
          "storeResult": false,
          "thenComponent": {
            "componentId": "952B558B-7B6A-4DFC-BFB9-AB0922FEB7B3",
            "componentType": "ELEMENT"
          }
        },
        "name": "Quick pay or remit-to?",
        "nextElementIds": [
          "952B558B-7B6A-4DFC-BFB9-AB0922FEB7B3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Updates a conversation's status, assignee, inbox, or tags. Only the fields you provide are changed; leave others empty to keep them unchanged.",
          "elementId": "EXTENSION:::SHARED:::default:::front-service:::updateConversation",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tag and assign to AP Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::front-service:::updateConversation",
          "legacyElementId": "JS###v1###FrontService###updateConversation",
          "methodName": "updateConversation",
          "position": {
            "x": 490,
            "y": 380
          }
        },
        "flowElementId": "79D721BF-D8DD-453D-837E-899A2C8C667C",
        "groupId": null,
        "id": "F0552465-9A3F-4727-A807-02514F03E7B9",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "conversationId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Inbound email",
                    "subPathSegments": [
                      {
                        "key": "conversation_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "AP note",
                    "subPathSegments": [
                      {
                        "key": "assigneeId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "tagIds",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "AP note",
                    "subPathSegments": [
                      {
                        "key": "tags",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "inboxId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "createMissingTags",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "updateConversation",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Assigned to AP",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "front-service",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tag and assign to AP",
        "nextElementIds": [
          "647BFA06-D703-4556-B73F-D5B3120BB7D8"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Posts an internal comment on a conversation. Comments are team-only notes (not visible to the customer) and support @-mentions of teammates by ID.",
          "elementId": "EXTENSION:::SHARED:::default:::front-service:::addComment",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask AP in a comment Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::front-service:::addComment",
          "legacyElementId": "JS###v1###FrontService###addComment",
          "methodName": "addComment",
          "position": {
            "x": 804,
            "y": 380
          }
        },
        "flowElementId": "BAB23D9C-FBC2-4E24-8455-BF258AB4B8C7",
        "groupId": null,
        "id": "647BFA06-D703-4556-B73F-D5B3120BB7D8",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "conversationId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Inbound email",
                    "subPathSegments": [
                      {
                        "key": "conversation_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "body",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "AP note",
                    "subPathSegments": [
                      {
                        "key": "comment",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "authorId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "addComment",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "AP comment",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "front-service",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask AP in a comment",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the request Result"
          },
          "tools": {},
          "position": {
            "x": 493,
            "y": 49
          }
        },
        "flowElementId": "CE50C623-8C24-4EB3-9A72-F65A9A89D56E",
        "groupId": null,
        "id": "B9400825-06BF-4533-8B12-682AFBC941C2",
        "metaInfo": {
          "aiApiKey": null,
          "aiModel": "claude-sonnet-5",
          "aiProvider": "ANTHROPIC",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "dynamicAiApiKey": {
            "expression": [
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Anthropic key",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Anthropic key"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "files": [],
          "forceParsedOutput": true,
          "langSmithSettings": {
            "enabled": false,
            "apiKey": null,
            "projectName": null,
            "label": "FlowRunner AI-Agent",
            "accountCluster": "US"
          },
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "messagesHistoryEnabled": false,
          "messagesHistoryLimit": 15,
          "onFailElemId": null,
          "resultAlias": "Request",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You read emails that carriers and factoring companies send to a freight brokerage's accounts payable inbox in Front. Reply with JSON only, with these fields:\nkind: quick_pay (the carrier asks to be paid early, usually for a fee), remit_to_change (the carrier asks to change where or how it is paid: bank account, remit-to address or payee name), notice_of_assignment (a factoring company or the carrier says the carrier's invoices are now assigned to a factor, or released from one), other (anything else)\ncarrier: the carrier's name, or empty text\nmcNumber: the carrier's MC or DOT number, or empty text\nloadNumber: the load or order number, or empty text\nproNumber: the PRO number, or empty text\ninvoiceNumber: the carrier's invoice number, or empty text\nhasNumber: true if loadNumber or proNumber is filled in, otherwise false\nlookup: an object with loadNumber and proNumber in which only one is filled: the load number if the email has one, otherwise the PRO number; the other is empty text\namount: the amount asked for, as a number, or 0\nfee: the quick pay fee the carrier accepts as written (for example 3% or $50), or empty text\nfactoringCompany: the factoring company named, or empty text\nnewBankDetails: true if the email gives new bank account or routing numbers, otherwise false\nwarningSigns: anything that looks like payment fraud (urgency, a new email domain, a free email address, pressure to skip a phone call, names that don't match), in one sentence, or empty text\nsummary: one plain sentence saying what the sender asks for"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "From: "
              },
              {
                "id": "RESULT",
                "label": "Inbound email",
                "subPathSegments": [
                  {
                    "key": "senderEmail",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nSubject: "
              },
              {
                "id": "RESULT",
                "label": "Inbound email",
                "subPathSegments": [
                  {
                    "key": "subject",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nAttachments: "
              },
              {
                "id": "RESULT",
                "label": "Inbound email",
                "subPathSegments": [
                  {
                    "key": "attachments",
                    "optional": false
                  },
                  {
                    "index": 0,
                    "last": false
                  },
                  {
                    "key": "filename",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " "
              },
              {
                "id": "RESULT",
                "label": "Inbound email",
                "subPathSegments": [
                  {
                    "key": "attachments",
                    "optional": false
                  },
                  {
                    "index": 1,
                    "last": false
                  },
                  {
                    "key": "filename",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\n"
              },
              {
                "id": "RESULT",
                "label": "Inbound email",
                "subPathSegments": [
                  {
                    "key": "body",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Read the request",
        "nextElementIds": [
          "9797469B-38D5-4661-AC74-DC5C76CD256D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a single conversation by ID with full metadata: subject, status, recipient, assignee, tags, links, custom fields, and counts.",
          "elementId": "EXTENSION:::SHARED:::default:::front-service:::getConversation",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the conversation Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::front-service:::getConversation",
          "legacyElementId": "JS###v1###FrontService###getConversation",
          "methodName": "getConversation",
          "position": {
            "x": 1118,
            "y": 40
          }
        },
        "flowElementId": "40927CD5-A690-4E80-A1D0-41AD0809BFDC",
        "groupId": null,
        "id": "952B558B-7B6A-4DFC-BFB9-AB0922FEB7B3",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "conversationId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Inbound email",
                    "subPathSegments": [
                      {
                        "key": "conversation_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getConversation",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Conversation",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "front-service",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the conversation",
        "nextElementIds": [
          "DDBEF39C-F0C2-44B4-97CD-4A2C7FE7894E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the note for AP Result"
          },
          "position": {
            "x": 148,
            "y": 389
          }
        },
        "flowElementId": "5B780088-55E4-4562-B308-CD9B3D77D5E9",
        "groupId": null,
        "id": "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'Write the note for AP', Error: The placeholder \"AP teammate email\" has no value",
            "valid": false
          },
          "codeArguments": [
            {
              "name": "request",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B9400825-06BF-4533-8B12-682AFBC941C2"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sender",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Inbound email",
                    "subPathSegments": [
                      {
                        "key": "senderEmail",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "existingTags",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Conversation",
                    "subPathSegments": [
                      {
                        "key": "tags",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "952B558B-7B6A-4DFC-BFB9-AB0922FEB7B3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "found",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "McLeod load",
                    "subPathSegments": [
                      {
                        "key": "found",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "233738F9-77AE-4C52-8BD6-0B5CF2BBC58E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "load",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "McLeod load",
                    "subPathSegments": [
                      {
                        "key": "load",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "233738F9-77AE-4C52-8BD6-0B5CF2BBC58E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "documents",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Load documents",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "079E1387-EA19-4B92-ABE6-74E6D0B248A6"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "podType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "POD document type",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "POD document type"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "apTeammate",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "AP teammate email",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "AP teammate email"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const labels = { quick_pay: 'Quick pay', remit_to_change: 'Remit-to change', notice_of_assignment: 'Notice of assignment' };\nconst tag = labels[request.kind] || 'Quick pay';\nconst current = Array.isArray(existingTags) ? existingTags.map(t => t && t.name).filter(Boolean) : [];\nconst tags = [...new Set([...current, tag])];\nconst email = String(apTeammate || '').trim();\nconst lines = [];\nconst who = request.carrier || sender;\n\nif (request.kind === 'quick_pay') {\n  const parts = [request.loadNumber && `load ${request.loadNumber}`, request.proNumber && `PRO ${request.proNumber}`, request.invoiceNumber && `invoice ${request.invoiceNumber}`].filter(Boolean);\n  lines.push(`Quick pay request from ${who}${parts.length ? ` for ${parts.join(', ')}` : ''}${request.amount ? `, amount ${request.amount}` : ''}${request.fee ? `, fee ${request.fee}` : ''}.`);\n} else if (request.kind === 'remit_to_change') {\n  lines.push(`${who} asks to change where they are paid.${request.newBankDetails ? ' The email gives new bank details.' : ''}${request.factoringCompany ? ` Factoring company: ${request.factoringCompany}.` : ''}`);\n} else {\n  lines.push(`Notice of assignment for ${who}${request.factoringCompany ? ` to ${request.factoringCompany}` : ''}.${request.newBankDetails ? ' The email gives new bank details.' : ''}`);\n}\nif (request.mcNumber) lines.push(`MC or DOT on the email: ${request.mcNumber}.`);\n\nif (!request.hasNumber) {\n  lines.push('The email gives no load or PRO number, so nothing was checked in McLeod.');\n} else if (!found || !load) {\n  lines.push(`No McLeod load matches ${[request.loadNumber, request.proNumber].filter(Boolean).join(' or ')}.`);\n} else {\n  const movement = Array.isArray(load.movements) && load.movements[0] || {};\n  const carrierName = load.carrier && load.carrier.name || 'no carrier';\n  lines.push(`McLeod order ${load.orderId}: ${load.statusDescription || load.status}, carrier ${carrierName}, carrier pay ${load.carrierPay && load.carrierPay.totalPay != null ? load.carrierPay.totalPay : 'not set'}. Ready to bill: ${load.readyToBill === 'Y' ? 'yes' : 'no'}.`);\n  const docs = documents && Array.isArray(documents.documents) ? documents.documents : [];\n  const hasPod = docs.some(d => String(d.documentTypeId || '').toUpperCase() === String(podType || 'POD').toUpperCase());\n  lines.push(hasPod ? 'POD is on file in McLeod.' : 'No POD on file in McLeod yet.');\n  if (request.kind === 'quick_pay' && request.amount && load.carrierPay && load.carrierPay.totalPay != null && Number(request.amount) !== Number(load.carrierPay.totalPay)) {\n    lines.push(`The amount asked for (${request.amount}) differs from the carrier pay in McLeod (${load.carrierPay.totalPay}).`);\n  }\n  const domain = s => String(s || '').split('@')[1] || '';\n  if (movement.carrierEmail && domain(movement.carrierEmail).toLowerCase() !== domain(sender).toLowerCase()) {\n    lines.push(`The sender's address (${sender}) is not on the carrier's domain in McLeod (${movement.carrierEmail}).`);\n  }\n}\nif (request.warningSigns) lines.push(`Watch for: ${request.warningSigns}`);\nif (request.kind === 'quick_pay') {\n  lines.push('Your call: approve quick pay or keep standard terms, and reply to the carrier from this conversation.');\n} else {\n  lines.push('Before changing anything, call the carrier on the phone number you already have on file, not one from this email, and confirm the change. Then update the payee and reply here.');\n}\nreturn { tags, assigneeId: email ? `alt:email:${email}` : '', comment: lines.join('\\n') };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "AP note",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the note for AP",
        "nextElementIds": [
          "F0552465-9A3F-4727-A807-02514F03E7B9"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1120,
            "y": 219
          }
        },
        "flowElementId": "6578EDD0-8C07-4E4C-88A0-2F6F6C4B96B0",
        "groupId": null,
        "id": "DDBEF39C-F0C2-44B4-97CD-4A2C7FE7894E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "b74bd4c0-1664-45b7-83ce-e003e90f24d4",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Request",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "hasNumber",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "B9400825-06BF-4533-8B12-682AFBC941C2"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "b74bd4c0-1664-45b7-83ce-e003e90f24d4"
            ]
          },
          "elseComponent": {
            "componentId": "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Load number on it",
          "storeResult": false,
          "thenComponent": {
            "componentId": "233738F9-77AE-4C52-8BD6-0B5CF2BBC58E",
            "componentType": "ELEMENT"
          }
        },
        "name": "Load number on it?",
        "nextElementIds": [
          "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9",
          "233738F9-77AE-4C52-8BD6-0B5CF2BBC58E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 493,
            "y": 219
          }
        },
        "flowElementId": "04C0FC0E-1AA9-4941-B251-A94D5426989D",
        "groupId": null,
        "id": "678BAECF-3331-45D9-AEEA-48600F82F09D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "2495a4f8-1f15-43eb-963c-070306574667",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "McLeod load",
                      "subPathSegments": [
                        {
                          "key": "found",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "233738F9-77AE-4C52-8BD6-0B5CF2BBC58E"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "2495a4f8-1f15-43eb-963c-070306574667"
            ]
          },
          "elseComponent": {
            "componentId": "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Load found",
          "storeResult": false,
          "thenComponent": {
            "componentId": "079E1387-EA19-4B92-ABE6-74E6D0B248A6",
            "componentType": "ELEMENT"
          }
        },
        "name": "Load found?",
        "nextElementIds": [
          "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9",
          "079E1387-EA19-4B92-ABE6-74E6D0B248A6"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Lists the documents McLeod Imaging holds for a load (rate confirmation, BOL, POD and the rest): those attached to the order and, unless turned off, those attached to its movements. Each has the ID that Download Document takes.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoadDocuments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check the paperwork in McLeod Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoadDocuments",
          "legacyElementId": null,
          "methodName": "listLoadDocuments",
          "position": {
            "x": 110,
            "y": 210
          }
        },
        "flowElementId": "7CCDDE90-F66A-412B-9007-C20924F7F9E8",
        "groupId": null,
        "id": "079E1387-EA19-4B92-ABE6-74E6D0B248A6",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "orderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "McLeod load",
                    "subPathSegments": [
                      {
                        "key": "load",
                        "optional": false
                      },
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "233738F9-77AE-4C52-8BD6-0B5CF2BBC58E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeMovementDocuments",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "listLoadDocuments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Load documents",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "mcleod-loadmaster",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Check the paperwork in McLeod",
        "nextElementIds": [
          "1EC4D9DC-B2AF-4F9F-A528-4748AAD5DBA9"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Triggers when a new inbound message arrives in Front. Uses Front Query Language to find conversations updated since the last poll, then walks up to 10 of them to find new inbound messages. If more than 10 conversations receive new inbound messages between polls, the 11th+ may be missed. Polling interval can be customized (minimum 30 seconds); for higher fidelity, use Front's native webhooks.",
          "elementId": "EXTENSION:::SHARED:::default:::front-service:::onNewInboundMessage",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::front-service:::onNewInboundMessage",
          "newElementId": "EXTENSION:::SHARED:::default:::front-service:::onNewInboundMessage",
          "legacyElementId": "JS###v1###FrontService###onNewInboundMessage",
          "methodName": "onNewInboundMessage",
          "position": {
            "x": 132,
            "y": 40
          }
        },
        "flowElementId": "ABABCB8D-F1E1-4257-B341-9A0973A407D0",
        "groupId": null,
        "id": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onNewInboundMessage",
          "frequency": {
            "repeat": {
              "every": 120
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Inbound email",
          "serviceId": "front-service",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "New email in the AP inbox",
        "nextElementIds": [
          "B9400825-06BF-4533-8B12-682AFBC941C2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Finds a load by its order number, PRO number, bill of lading, consignee reference or a stop reference number (McLeod order tracking search) and returns the first match in full, as Get Load does, with every match listed. Returns found: false instead of failing when nothing matches.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::findLoadByNumber",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the load in McLeod Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::findLoadByNumber",
          "legacyElementId": null,
          "methodName": "findLoadByNumber",
          "position": {
            "x": 795,
            "y": 210
          }
        },
        "flowElementId": "365CA4B5-7E61-4E5B-A150-E969456EF42B",
        "groupId": null,
        "id": "233738F9-77AE-4C52-8BD6-0B5CF2BBC58E",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "loadNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "lookup",
                        "optional": false
                      },
                      {
                        "key": "loadNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B9400825-06BF-4533-8B12-682AFBC941C2"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "proNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "lookup",
                        "optional": false
                      },
                      {
                        "key": "proNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B9400825-06BF-4533-8B12-682AFBC941C2"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "billOfLading",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "consigneeReference",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "referenceNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "findLoadByNumber",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "McLeod load",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "mcleod-loadmaster",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the load in McLeod",
        "nextElementIds": [
          "678BAECF-3331-45D9-AEEA-48600F82F09D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "874FDAE6-BAA5-4600-8D03-3EC83E3F0382",
    "groups": [],
    "id": "70231C32-0598-4182-8D06-D45FDD4B8E4A",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Block 'Write the note for AP' has an invalid configuration. Code Argument 'apTeammate' has invalid value. Placeholder Data 'AP teammate email': value is required",
      "executionStaticData": [
        {
          "description": "Your Anthropic API key, used by the block Read the request.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "The Front login email of the person in AP who decides quick pay and remit-to requests.",
          "error": "Placeholder Data 'AP teammate email': value is required",
          "name": "AP teammate email",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The McLeod Imaging document type code your team files PODs under.",
          "error": null,
          "name": "POD document type",
          "type": "STRING",
          "value": ""
        }
      ],
      "initialData": null,
      "initialDataDefaultValues": {},
      "ownerFlowVersionId": null,
      "schedule": null,
      "sharedMemory": {
        "anchor": {
          "missingAnchorPolicy": null,
          "path": null,
          "type": "FLOW_MEMORY"
        },
        "expirationInSec": null
      },
      "wasLive": false
    }
  },
  "slaCalendars": [],
  "slaGoals": [],
  "subFlows": [],
  "exportDate": "2026-11-26T09:37:31.394Z"
}
