{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "50AB5349-D4DA-4AE0-B460-AD0FEAB63658",
    "name": "GoCardless: failed payment retried or chased"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": 158.54604044945245,
        "y": 26.005786530051523,
        "zoom": 0.5
      },
      "autoSave": true,
      "descriptions": {
        "flow": "When a GoCardless payment fails, an AI agent reads the failure reason. Retryable failures are retried in GoCardless; for the rest the customer gets an email. Every outcome is logged to Google Sheets.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a GoCardless payment fails, an AI agent reads the failure reason. Retryable failures are retried in GoCardless; for the rest the customer gets an email. Every outcome is logged to Google Sheets.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Fires when something happens to a payment - submitted, confirmed, paid out, failed, charged back. Use for accounting automations, customer notifications, or syncing payment state to your system.",
          "elementId": "EXTENSION:::SHARED:::default:::gocardless:::onPaymentEvent",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::gocardless:::onPaymentEvent",
          "newElementId": "EXTENSION:::SHARED:::default:::gocardless:::onPaymentEvent",
          "legacyElementId": "JS###v1###GoCardlessService###onPaymentEvent",
          "methodName": "onPaymentEvent",
          "position": {
            "x": 110,
            "y": 200
          }
        },
        "flowElementId": "9F4E87CA-9BBE-4CC4-A655-8489196377D2",
        "groupId": null,
        "id": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'Payment failed', Error: OAuth Connection is required",
            "valid": false
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onPaymentEvent",
          "frequency": {
            "repeat": {
              "every": 300
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Failed payment event",
          "serviceId": "gocardless",
          "slaConditions": [],
          "staticData": {
            "action": "failed"
          },
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "Payment failed",
        "nextElementIds": [
          "C908435E-C351-4886-B7B3-7313A7F1AB28"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Fetch one payment - amount, currency, status, charge date, links to mandate/customer.",
          "elementId": "EXTENSION:::SHARED:::default:::gocardless:::getPayment",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the payment Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::gocardless:::getPayment",
          "legacyElementId": "JS###v1###GoCardlessService###getPayment",
          "methodName": "getPayment",
          "position": {
            "x": 400,
            "y": 200
          }
        },
        "flowElementId": "A1D0ABBB-3944-42CC-A14A-569AAEF06641",
        "groupId": null,
        "id": "C908435E-C351-4886-B7B3-7313A7F1AB28",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "paymentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Failed payment event",
                    "subPathSegments": [
                      {
                        "key": "links",
                        "optional": false
                      },
                      {
                        "key": "payment",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Get the payment', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getPayment",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Payment",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "gocardless",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the payment",
        "nextElementIds": [
          "1C3FC4E6-E3A2-4263-998D-872BAFEFC64B"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Retry refused Result"
          },
          "position": {
            "x": 642,
            "y": 722
          }
        },
        "flowElementId": "CE8D9A7E-C102-4015-AF45-07FFC837FF81",
        "groupId": null,
        "id": "4186F12C-6D1B-498E-A2CA-BED0811EFB41",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Retry refusal",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "Retry refused",
        "nextElementIds": [
          "B77E8D57-54DC-462F-9B73-CA3DF6B08571"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the log row Result"
          },
          "position": {
            "x": 1316,
            "y": 388
          }
        },
        "flowElementId": "A15BCD9C-CB75-4E54-8CEF-D77E4D96C36A",
        "groupId": null,
        "id": "A010D9A3-306B-45D0-9A68-4EC44F8B8573",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "paymentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "amount",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "amount",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "currency",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "currency",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "givenName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Customer",
                    "subPathSegments": [
                      {
                        "key": "given_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "familyName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Customer",
                    "subPathSegments": [
                      {
                        "key": "family_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Customer",
                    "subPathSegments": [
                      {
                        "key": "company_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Customer",
                    "subPathSegments": [
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cause",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Failed payment event",
                    "subPathSegments": [
                      {
                        "key": "details",
                        "optional": false
                      },
                      {
                        "key": "cause",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "reason",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Failure reading",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "reason",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1D2D6DED-5CE6-4523-BBFE-005615673F47"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const name = [givenName, familyName].filter(Boolean).join(' ') || companyName || '';\nconst base = {\n  Date: new Date().toISOString().slice(0, 10),\n  Payment: paymentId,\n  Customer: name,\n  Email: email || '',\n  Amount: (Number(amount) / 100).toFixed(2) + ' ' + currency,\n  Failure: cause || '',\n  Decision: reason || '',\n};\nreturn {\n  retried: { ...base, Outcome: 'Retried in GoCardless' },\n  emailed: { ...base, Outcome: 'Customer emailed' },\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Log row",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the log row",
        "nextElementIds": [
          "848F8FD6-B422-400A-990E-473C2A7EA4AA"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 996,
            "y": 400
          }
        },
        "flowElementId": "5CFB8C66-3B16-46B3-802E-35975617E721",
        "groupId": null,
        "id": "848F8FD6-B422-400A-990E-473C2A7EA4AA",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "ee4f313b-cde6-4889-9a4c-90266d37d65e",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Failure reading",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "retry",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "1D2D6DED-5CE6-4523-BBFE-005615673F47"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "ee4f313b-cde6-4889-9a4c-90266d37d65e"
            ]
          },
          "elseComponent": {
            "componentId": "B77E8D57-54DC-462F-9B73-CA3DF6B08571",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Worth retrying",
          "storeResult": false,
          "thenComponent": {
            "componentId": "F5F7F6A9-9159-42A4-88D9-7A9795C2A4C6",
            "componentType": "ELEMENT"
          }
        },
        "name": "Worth retrying?",
        "nextElementIds": [
          "F5F7F6A9-9159-42A4-88D9-7A9795C2A4C6",
          "B77E8D57-54DC-462F-9B73-CA3DF6B08571"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Retry a failed payment. Only works for payments in 'failed' state and within the scheme's retry window (about 21 days). After that, you have to create a fresh payment.",
          "elementId": "EXTENSION:::SHARED:::default:::gocardless:::retryPayment",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Retry the payment Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::gocardless:::retryPayment",
          "legacyElementId": "JS###v1###GoCardlessService###retryPayment",
          "methodName": "retryPayment",
          "position": {
            "x": 646,
            "y": 394
          }
        },
        "flowElementId": "50BAE998-E8DE-4418-B6DE-3716B9FE14EA",
        "groupId": null,
        "id": "F5F7F6A9-9159-42A4-88D9-7A9795C2A4C6",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "paymentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "chargeDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Retry the payment', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "retryPayment",
          "onFailElemId": "4186F12C-6D1B-498E-A2CA-BED0811EFB41",
          "packageId": "default",
          "resultAlias": "Retried payment",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "gocardless",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Retry the payment",
        "nextElementIds": [
          "2C1B1056-2B12-4BDE-89A6-D336C391A865"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the failure reason Result"
          },
          "tools": {},
          "position": {
            "x": 1270,
            "y": 200
          }
        },
        "flowElementId": "BA95E0A8-2453-4480-8443-5C94336DB6DB",
        "groupId": null,
        "id": "1D2D6DED-5CE6-4523-BBFE-005615673F47",
        "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": "Failure reading",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You handle failed GoCardless Direct Debit payments for a business. Decide whether to retry the payment, and write a short email to the customer. Reply with JSON only, with these fields:\nretry: true when a second attempt is likely to succeed, such as insufficient_funds or refer_to_payer. false when the mandate or bank account no longer works (mandate_cancelled, mandate_expired, bank_account_closed, bank_account_transferred, invalid_bank_details, direct_debit_not_enabled), when the payer disputed or reversed the charge (authorisation_disputed, return_on_odp), or when GoCardless says it will retry the payment itself (will_attempt_retry is true).\nreason: one plain sentence saying why the payment failed and why you chose to retry or not.\nemailSubject: the subject line of an email to the customer about this payment.\nemailBody: a plain-text email to the customer. Greet them by name, state the amount in normal currency format and what it was for, explain in plain words why the payment did not go through, and say what to do next: make sure funds are available if it was a funds problem, or set up their bank details again if the mandate or account no longer works. If GoCardless will retry on its own, say when it will be collected again if you know. Sign off as the accounts team. Never use placeholders in brackets."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "Failed payment "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Payment",
                "subPathSegments": [
                  {
                    "key": "id",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nAmount: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Payment",
                "subPathSegments": [
                  {
                    "key": "amount",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Payment",
                "subPathSegments": [
                  {
                    "key": "currency",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " (in the smallest currency unit, so 1500 GBP means 15.00 GBP)\nWhat it was for: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Payment",
                "subPathSegments": [
                  {
                    "key": "description",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nReference: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Payment",
                "subPathSegments": [
                  {
                    "key": "reference",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nCharge date: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Payment",
                "subPathSegments": [
                  {
                    "key": "charge_date",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nFailure cause: "
              },
              {
                "id": "RESULT",
                "label": "Failed payment event",
                "subPathSegments": [
                  {
                    "key": "details",
                    "optional": false
                  },
                  {
                    "key": "cause",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nBank reason code: "
              },
              {
                "id": "RESULT",
                "label": "Failed payment event",
                "subPathSegments": [
                  {
                    "key": "details",
                    "optional": false
                  },
                  {
                    "key": "reason_code",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nWhat GoCardless says: "
              },
              {
                "id": "RESULT",
                "label": "Failed payment event",
                "subPathSegments": [
                  {
                    "key": "details",
                    "optional": false
                  },
                  {
                    "key": "description",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nGoCardless will retry it itself: "
              },
              {
                "id": "RESULT",
                "label": "Failed payment event",
                "subPathSegments": [
                  {
                    "key": "details",
                    "optional": false
                  },
                  {
                    "key": "will_attempt_retry",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nCustomer: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "given_name",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "family_name",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Customer",
                "subPathSegments": [
                  {
                    "key": "company_name",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Read the failure reason",
        "nextElementIds": [
          "A010D9A3-306B-45D0-9A68-4EC44F8B8573"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fetch one mandate - scheme, status, next earliest charge date, links to customer and bank account.",
          "elementId": "EXTENSION:::SHARED:::default:::gocardless:::getMandate",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the mandate Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::gocardless:::getMandate",
          "legacyElementId": "JS###v1###GoCardlessService###getMandate",
          "methodName": "getMandate",
          "position": {
            "x": 690,
            "y": 200
          }
        },
        "flowElementId": "C46EF92E-4662-44BB-B100-28D3079CF90A",
        "groupId": null,
        "id": "1C3FC4E6-E3A2-4263-998D-872BAFEFC64B",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "mandateId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "links",
                        "optional": false
                      },
                      {
                        "key": "mandate",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C908435E-C351-4886-B7B3-7313A7F1AB28"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Get the mandate', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getMandate",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Mandate",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "gocardless",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the mandate",
        "nextElementIds": [
          "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fetch one customer's full profile - name, email, address, language, identity numbers. Use when you have a customer ID and need their details for display or downstream logic.",
          "elementId": "EXTENSION:::SHARED:::default:::gocardless:::getCustomer",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the customer Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::gocardless:::getCustomer",
          "legacyElementId": "JS###v1###GoCardlessService###getCustomer",
          "methodName": "getCustomer",
          "position": {
            "x": 980,
            "y": 200
          }
        },
        "flowElementId": "87C3BAD8-5EB4-4558-A768-86529C7B096A",
        "groupId": null,
        "id": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "customerId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Mandate",
                    "subPathSegments": [
                      {
                        "key": "links",
                        "optional": false
                      },
                      {
                        "key": "customer",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1C3FC4E6-E3A2-4263-998D-872BAFEFC64B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Get the customer', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getCustomer",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Customer",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "gocardless",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the customer",
        "nextElementIds": [
          "1D2D6DED-5CE6-4523-BBFE-005615673F47"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends emails through Gmail for AI agents to automate customer communication.",
          "elementId": "EXTENSION:::SHARED:::default:::gmail-service:::sendMessage",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Email the customer Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::gmail-service:::sendMessage",
          "legacyElementId": "JS###v1###GmailService###sendMessage",
          "methodName": "sendMessage",
          "position": {
            "x": 1000,
            "y": 714
          }
        },
        "flowElementId": "BE73059E-FFFA-455E-B42A-2D34433EA50D",
        "groupId": null,
        "id": "B77E8D57-54DC-462F-9B73-CA3DF6B08571",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "to",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Customer",
                    "subPathSegments": [
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "29FC3B8F-5B82-443B-84C0-A0167E7A85C8"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Failure reading",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "emailSubject",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1D2D6DED-5CE6-4523-BBFE-005615673F47"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "bodyType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "plain"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "bodyContent",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Failure reading",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "emailBody",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "1D2D6DED-5CE6-4523-BBFE-005615673F47"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "from",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cc",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "bcc",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "attachments",
              "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": "sendMessage",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Customer email",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "gmail-service",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Email the customer",
        "nextElementIds": [
          "D766BDD2-B996-404C-9023-D683A7ED66B4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds new data rows to Google Sheets for AI agents to store processed results, log user interactions, or collect data from automated workflows. Perfect for building databases, tracking metrics, saving form submissions, or creating data collection pipelines.",
          "elementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRow",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Log the customer notice Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRow",
          "legacyElementId": "JS###v1###GoogleSheets###addRow",
          "methodName": "addRow",
          "position": {
            "x": 1320,
            "y": 716
          }
        },
        "flowElementId": "59DB37A4-A0AE-4545-9E64-2371087BDE73",
        "groupId": null,
        "id": "D766BDD2-B996-404C-9023-D683A7ED66B4",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sheetId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "row",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Log row",
                    "subPathSegments": [
                      {
                        "key": "emailed",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A010D9A3-306B-45D0-9A68-4EC44F8B8573"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Log the customer notice', Error: Document is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "addRow",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Notice log",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "google-sheets",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Log the customer notice",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds new data rows to Google Sheets for AI agents to store processed results, log user interactions, or collect data from automated workflows. Perfect for building databases, tracking metrics, saving form submissions, or creating data collection pipelines.",
          "elementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRow",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Log the retry Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRow",
          "legacyElementId": "JS###v1###GoogleSheets###addRow",
          "methodName": "addRow",
          "position": {
            "x": 278,
            "y": 396
          }
        },
        "flowElementId": "2CACAE44-63CA-45CD-A133-FA3ED6B4DE19",
        "groupId": null,
        "id": "2C1B1056-2B12-4BDE-89A6-D336C391A865",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sheetId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "row",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Log row",
                    "subPathSegments": [
                      {
                        "key": "retried",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A010D9A3-306B-45D0-9A68-4EC44F8B8573"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Log the retry', Error: Document is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "addRow",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Retry log",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "google-sheets",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Log the retry",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "000F3F15-8ECA-4066-BCE5-DC433AF2B01B",
    "groups": [],
    "id": "C320194C-4962-49EE-9156-6BF904CCE257",
    "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": "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.",
      "executionStaticData": [
        {
          "description": "Anthropic API key the AI agent uses.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        }
      ],
      "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-18T10:14:18.221Z"
}
