{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "91ADBA51-EA4E-4514-BB60-F8760262389B",
    "name": "Dittofeed: bounces and opt-outs back to HubSpot"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -59.322799097065456,
        "y": 3.882618510158011,
        "zoom": 0.9
      },
      "autoSave": false,
      "descriptions": {
        "flow": "Checks self-hosted Dittofeed for new email bounces and subscription changes. A bounce is logged to a Google Sheet and flagged on the HubSpot contact; a subscription change writes the user's current subscription groups onto the contact.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Checks self-hosted Dittofeed for new email bounces and subscription changes. A bounce is logged to a Google Sheet and flagged on the HubSpot contact; a subscription change writes the user's current subscription groups onto the contact.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1286,
            "y": 49
          }
        },
        "flowElementId": "EAD93E68-F841-471B-9B6A-B4CE2C45C62E",
        "groupId": null,
        "id": "FB381E12-9CE3-4733-9437-75E63B2E0BDC",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "461096ad-604d-451b-90ac-f24ae841e8b0",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Event details",
                      "subPathSegments": [
                        {
                          "key": "email",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "3BD2F422-512A-47D4-A98F-4B9249488993"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "461096ad-604d-451b-90ac-f24ae841e8b0"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Email on file",
          "storeResult": false,
          "thenComponent": {
            "componentId": "E2DBF9B3-F22F-40A1-BB47-B9EC3E43C9A0",
            "componentType": "ELEMENT"
          }
        },
        "name": "Email on file?",
        "nextElementIds": [
          "E2DBF9B3-F22F-40A1-BB47-B9EC3E43C9A0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "router",
          "isFirstElement": false,
          "blockDefinitionId": "router",
          "casesViewMode": {
            "31cf7435-63ff-4e65-88e8-6cb24e5804fa": "SIMPLE",
            "58c487da-7398-435e-9c99-d05f952c3ab4": "SIMPLE"
          },
          "position": {
            "x": 880,
            "y": 349
          }
        },
        "flowElementId": "A8C28590-DE85-40CB-A3CD-9B8112BB8A31",
        "groupId": null,
        "id": "B05ECF14-5107-4AA3-BEFC-78B0AA96687C",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Event kind",
          "storeResult": true,
          "switchCases": [
            {
              "defaultCase": false,
              "id": "31cf7435-63ff-4e65-88e8-6cb24e5804fa",
              "label": "Bounce",
              "nextComponents": [
                {
                  "componentId": "3B6149FE-434B-4B79-9FA6-C5F22D28E943",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "DFEmailBounced"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": false,
              "id": "58c487da-7398-435e-9c99-d05f952c3ab4",
              "label": "Subscription change",
              "nextComponents": [
                {
                  "componentId": "D7DC345F-2217-4E0F-A042-D3CEAD034327",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "DFSubscriptionChange"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": true,
              "id": "13d831e8-39c1-410e-a4d1-dfce94879753",
              "label": "Everything Else",
              "nextComponents": [],
              "type": "SIMPLE",
              "value": null
            }
          ],
          "switchExpression": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Event details",
                "subPathSegments": [
                  {
                    "key": "event",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "3BD2F422-512A-47D4-A98F-4B9249488993"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Bounce or subscription change?",
        "nextElementIds": [
          "3B6149FE-434B-4B79-9FA6-C5F22D28E943",
          "D7DC345F-2217-4E0F-A042-D3CEAD034327"
        ],
        "nextGroupIds": [],
        "type": "VALUE_ROUTER"
      },
      {
        "clientMetadata": {
          "notes": "Updates an existing contact in HubSpot with new property values. Only the properties specified in the request will be updated, leaving all other contact data unchanged. Property updates include optional timestamps for historical tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::hubspot:::updateContact",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Flag the address in HubSpot Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::hubspot:::updateContact",
          "legacyElementId": "JS###v1###HubSpotService###updateContact",
          "methodName": "updateContact",
          "position": {
            "x": 893,
            "y": 640
          }
        },
        "flowElementId": "88F429C6-4B8D-4F3A-BF17-5012CA6C65DB",
        "groupId": null,
        "id": "4B1F6E8C-D2D2-4A43-8956-4D2344EA0D11",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "vid",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Contact search",
                    "subPathSegments": [
                      {
                        "key": "results",
                        "optional": false
                      },
                      {
                        "index": 0,
                        "last": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E2DBF9B3-F22F-40A1-BB47-B9EC3E43C9A0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "properties",
              "type": "COMPLEX_LIST",
              "value": [
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "property",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "PLACEHOLDER_DATA",
                            "label": "HubSpot bounce property",
                            "subPathSegments": null,
                            "type": "EXECUTION_CONTEXT_STATIC_DATA",
                            "value": "HubSpot bounce property"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "value",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "true"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                }
              ]
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Flag the address in HubSpot', 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": "updateContact",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Flagged contact",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "hubspot",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Flag the address in HubSpot",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Lists users with their properties and segments, optionally only those in given segments or subscription groups (POST /api/admin/users/). Returns a cursor for the next page.",
          "elementId": "EXTENSION:::SHARED:::default:::dittofeed:::listUsers",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Look up the user in Dittofeed Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::dittofeed:::listUsers",
          "legacyElementId": null,
          "methodName": "listUsers",
          "position": {
            "x": 519,
            "y": 40
          }
        },
        "flowElementId": "822E5D07-4A80-4B0E-8160-DE79C030CCFA",
        "groupId": null,
        "id": "904B624D-CFC4-4B14-8A11-5BA3E2DEEB95",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "userIds",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Dittofeed event",
                      "subPathSegments": [
                        {
                          "key": "userId",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "9B04BF46-8C4B-4B24-ACE0-2319465E73ED"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "includeSubscriptions",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "direction",
              "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": "listUsers",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Dittofeed user",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "dittofeed",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Look up the user in Dittofeed",
        "nextElementIds": [
          "3BD2F422-512A-47D4-A98F-4B9249488993"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List the subscribed groups Result"
          },
          "position": {
            "x": 141,
            "y": 779
          }
        },
        "flowElementId": "E5F859CB-9532-4A27-B3FC-3C8D7A0C2C90",
        "groupId": null,
        "id": "51E44855-9856-435C-8DB2-55F49ADD85C4",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "subs",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Subscriptions",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "37369A81-9194-4817-A683-7A2918502307"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const groups = (subs && subs.subscriptionGroups) || [];\nconst names = groups.filter(g => g.isSubscribed).map(g => g.name);\nreturn { value: names.length ? names.join(', ') : 'None', count: names.length };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Subscribed groups",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "List the subscribed groups",
        "nextElementIds": [
          "ACD07A46-9D78-4D23-B7DA-D52D82BAFFF0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Finds contacts whose properties meet the conditions you set, such as a lead status, a lifecycle stage or a date property before or after a moment, using HubSpot's CRM search. Conditions in Filters must all be met; each Filter Group is an alternative. Returns up to 200 contacts per call, with a cursor for the next page; HubSpot stops a search at 10,000 results, and a contact created or changed in the last few moments may not be found yet.",
          "elementId": "EXTENSION:::SHARED:::default:::hubspot:::searchContactsByProperty",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the contact in HubSpot Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::hubspot:::searchContactsByProperty",
          "legacyElementId": "JS###v1###HubSpotService###searchContactsByProperty",
          "methodName": "searchContactsByProperty",
          "position": {
            "x": 1260,
            "y": 340
          }
        },
        "flowElementId": "BDDAAD82-833D-4DDE-AB0E-F792A3439548",
        "groupId": null,
        "id": "E2DBF9B3-F22F-40A1-BB47-B9EC3E43C9A0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "filters",
              "type": "COMPLEX_LIST",
              "value": [
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "propertyName",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "email"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "operator",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "EQ"
                          }
                        ],
                        "mode": "BASIC",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "value",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "ELEMENT_RESULT",
                            "label": "Event details",
                            "subPathSegments": [
                              {
                                "key": "email",
                                "optional": false
                              }
                            ],
                            "type": "ELEMENT_LINK",
                            "value": "3BD2F422-512A-47D4-A98F-4B9249488993"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                }
              ]
            },
            {
              "name": "filterGroups",
              "type": "COMPLEX_LIST",
              "value": []
            },
            {
              "name": "query",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "after",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the contact in HubSpot', 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": "searchContactsByProperty",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Contact search",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "hubspot",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the contact in HubSpot",
        "nextElementIds": [
          "B05ECF14-5107-4AA3-BEFC-78B0AA96687C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Returns every subscription group of the workspace and whether the user is subscribed to it (GET /api/admin/users/subscriptions).",
          "elementId": "EXTENSION:::SHARED:::default:::dittofeed:::getUserSubscriptions",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the user's subscriptions Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::dittofeed:::getUserSubscriptions",
          "legacyElementId": null,
          "methodName": "getUserSubscriptions",
          "position": {
            "x": 131,
            "y": 210
          }
        },
        "flowElementId": "3CEDDF46-6DF1-49FE-842A-4F2DB95DB96E",
        "groupId": null,
        "id": "37369A81-9194-4817-A683-7A2918502307",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "userId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Event details",
                    "subPathSegments": [
                      {
                        "key": "userId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3BD2F422-512A-47D4-A98F-4B9249488993"
                  }
                ],
                "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": "getUserSubscriptions",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Subscriptions",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "dittofeed",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Read the user's subscriptions",
        "nextElementIds": [
          "51E44855-9856-435C-8DB2-55F49ADD85C4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 516,
            "y": 649
          }
        },
        "flowElementId": "C832114F-10CA-476D-83B5-4543E5153737",
        "groupId": null,
        "id": "68D0E1CB-C531-4046-A92A-BDAF324FC346",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "5165fb91-96ed-4224-a226-0a734ae3d24c",
                "nestedOperation": null,
                "operation": "arrayIsNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Contact search",
                      "subPathSegments": [
                        {
                          "key": "results",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E2DBF9B3-F22F-40A1-BB47-B9EC3E43C9A0"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "ARRAY",
                "values": []
              }
            ],
            "grouping": [
              "5165fb91-96ed-4224-a226-0a734ae3d24c"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Bounced contact found",
          "storeResult": false,
          "thenComponent": {
            "componentId": "4B1F6E8C-D2D2-4A43-8956-4D2344EA0D11",
            "componentType": "ELEMENT"
          }
        },
        "name": "Bounced contact in HubSpot?",
        "nextElementIds": [
          "4B1F6E8C-D2D2-4A43-8956-4D2344EA0D11"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 546,
            "y": 479
          }
        },
        "flowElementId": "2506E147-848E-42E8-9D46-CFCE8FB20CB2",
        "groupId": null,
        "id": "D7DC345F-2217-4E0F-A042-D3CEAD034327",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "9ecc90f1-85e7-457d-b97d-5446da4daf7d",
                "nestedOperation": null,
                "operation": "arrayIsNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Contact search",
                      "subPathSegments": [
                        {
                          "key": "results",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E2DBF9B3-F22F-40A1-BB47-B9EC3E43C9A0"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "ARRAY",
                "values": []
              }
            ],
            "grouping": [
              "9ecc90f1-85e7-457d-b97d-5446da4daf7d"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Contact found",
          "storeResult": false,
          "thenComponent": {
            "componentId": "37369A81-9194-4817-A683-7A2918502307",
            "componentType": "ELEMENT"
          }
        },
        "name": "Contact in HubSpot?",
        "nextElementIds": [
          "37369A81-9194-4817-A683-7A2918502307"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Updates an existing contact in HubSpot with new property values. Only the properties specified in the request will be updated, leaving all other contact data unchanged. Property updates include optional timestamps for historical tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::hubspot:::updateContact",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write preferences to HubSpot Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::hubspot:::updateContact",
          "legacyElementId": "JS###v1###HubSpotService###updateContact",
          "methodName": "updateContact",
          "position": {
            "x": 515,
            "y": 770
          }
        },
        "flowElementId": "791C9A0C-0A14-427F-B38B-F6B9C2F67B83",
        "groupId": null,
        "id": "ACD07A46-9D78-4D23-B7DA-D52D82BAFFF0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "vid",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Contact search",
                    "subPathSegments": [
                      {
                        "key": "results",
                        "optional": false
                      },
                      {
                        "index": 0,
                        "last": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E2DBF9B3-F22F-40A1-BB47-B9EC3E43C9A0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "properties",
              "type": "COMPLEX_LIST",
              "value": [
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "property",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "PLACEHOLDER_DATA",
                            "label": "HubSpot subscriptions property",
                            "subPathSegments": null,
                            "type": "EXECUTION_CONTEXT_STATIC_DATA",
                            "value": "HubSpot subscriptions property"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "value",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "ELEMENT_RESULT",
                            "label": "Subscribed groups",
                            "subPathSegments": [
                              {
                                "key": "value",
                                "optional": false
                              }
                            ],
                            "type": "ELEMENT_LINK",
                            "value": "51E44855-9856-435C-8DB2-55F49ADD85C4"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                }
              ]
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Write preferences to HubSpot', 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": "updateContact",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Updated contact",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "hubspot",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Write preferences to HubSpot",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires for each new event Dittofeed records, your own or an internal one. Filter by name to watch, for example, DFEmailBounced, DFEmailOpened, DFMessageFailure or DFSubscriptionChange.",
          "elementId": "EXTENSION:::SHARED:::default:::dittofeed:::onNewEvent",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::dittofeed:::onNewEvent",
          "newElementId": "EXTENSION:::SHARED:::default:::dittofeed:::onNewEvent",
          "legacyElementId": null,
          "methodName": "onNewEvent",
          "position": {
            "x": 110,
            "y": 40
          }
        },
        "flowElementId": "5492222F-4FDD-43CF-AE47-132150D54E51",
        "groupId": null,
        "id": "9B04BF46-8C4B-4B24-ACE0-2319465E73ED",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onNewEvent",
          "frequency": {
            "repeat": {
              "every": 300
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Dittofeed event",
          "serviceId": "dittofeed",
          "slaConditions": [],
          "staticData": {
            "event": [
              "DFEmailBounced",
              "DFSubscriptionChange"
            ]
          },
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "New bounce or subscription change",
        "nextElementIds": [
          "904B624D-CFC4-4B14-8A11-5BA3E2DEEB95"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Searches the messages Dittofeed sent, with their latest status, newest first by default (GET /api/admin/deliveries/). Returns a cursor for the next page.",
          "elementId": "EXTENSION:::SHARED:::default:::dittofeed:::searchDeliveries",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the bounced message Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::dittofeed:::searchDeliveries",
          "legacyElementId": null,
          "methodName": "searchDeliveries",
          "position": {
            "x": 526,
            "y": 340
          }
        },
        "flowElementId": "65FD5A46-CA23-45A5-BD37-0254F73EE1C9",
        "groupId": null,
        "id": "3B6149FE-434B-4B79-9FA6-C5F22D28E943",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "userId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Event details",
                    "subPathSegments": [
                      {
                        "key": "userId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3BD2F422-512A-47D4-A98F-4B9249488993"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "journeyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "statuses",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "DFEmailBounced"
                    }
                  ],
                  "mode": "BASIC",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "startDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "endDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "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": "searchDeliveries",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Bounced message",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "dittofeed",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the bounced message",
        "nextElementIds": [
          "13F21502-CCEC-4C62-ABB8-8F54F25FD10E"
        ],
        "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 bounce Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRow",
          "legacyElementId": "JS###v1###GoogleSheets###addRow",
          "methodName": "addRow",
          "position": {
            "x": 163,
            "y": 640
          }
        },
        "flowElementId": "A61551CF-7B8F-4A24-ABAC-6444F57F23BC",
        "groupId": null,
        "id": "FB62F1D0-CB66-430F-96E7-2B26022303E4",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Deliverability log sheet",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Deliverability log sheet"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sheetId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 0
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "row",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Log row",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "13F21502-CCEC-4C62-ABB8-8F54F25FD10E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Log the bounce', Error: The placeholder \"Deliverability log sheet\" has no value",
            "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": "Logged bounce",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "google-sheets",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Log the bounce",
        "nextElementIds": [
          "68D0E1CB-C531-4046-A92A-BDAF324FC346"
        ],
        "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 log row Result"
          },
          "position": {
            "x": 163,
            "y": 349
          }
        },
        "flowElementId": "49E3CF21-5F9D-4AF0-8DD1-73E337C9D60D",
        "groupId": null,
        "id": "13F21502-CCEC-4C62-ABB8-8F54F25FD10E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "deliveries",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Bounced message",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "3B6149FE-434B-4B79-9FA6-C5F22D28E943"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "details",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Event details",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "3BD2F422-512A-47D4-A98F-4B9249488993"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const item = ((deliveries && deliveries.items) || [])[0] || {};\nconst variant = item.variant || {};\nreturn {\n  'Bounced at': details.at,\n  'Email': details.email,\n  'Dittofeed user': details.userId,\n  'Subject': variant.subject || '',\n  'Template': item.templateId || details.templateId || '',\n  'Sent at': item.sentAt || '',\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": [
          "FB62F1D0-CB66-430F-96E7-2B26022303E4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the event Result"
          },
          "position": {
            "x": 920,
            "y": 49
          }
        },
        "flowElementId": "5E0D25DA-5207-4713-9338-818072EB4BB9",
        "groupId": null,
        "id": "3BD2F422-512A-47D4-A98F-4B9249488993",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "event",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Dittofeed event",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "9B04BF46-8C4B-4B24-ACE0-2319465E73ED"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "users",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dittofeed user",
                    "subPathSegments": [
                      {
                        "key": "users",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "904B624D-CFC4-4B14-8A11-5BA3E2DEEB95"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "let traits = {};\ntry {\n  traits = typeof event.traits === 'string' ? JSON.parse(event.traits || '{}') : (event.traits || {});\n} catch (e) {\n  traits = {};\n}\nconst user = (users || [])[0] || {};\nconst props = user.properties || {};\nlet fromProfile = '';\nif (props.email) {\n  fromProfile = typeof props.email === 'object' ? props.email.value : props.email;\n} else {\n  const found = Object.values(props).find(p => p && p.name === 'email');\n  fromProfile = found ? found.value : '';\n}\nconst email = String(fromProfile || traits.email || '').trim().toLowerCase();\nreturn {\n  email,\n  userId: event.userId || '',\n  event: event.event,\n  at: event.eventTime || event.processingTime || '',\n  templateId: traits.templateId || '',\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Event details",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Read the event",
        "nextElementIds": [
          "FB381E12-9CE3-4733-9437-75E63B2E0BDC"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "9B04BF46-8C4B-4B24-ACE0-2319465E73ED",
    "groups": [],
    "id": "3EF823F4-4480-46B2-B425-11747FA1A3BB",
    "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": "Internal name of the HubSpot contact property (a single checkbox) that marks an address Dittofeed saw bounce.",
          "error": null,
          "name": "HubSpot bounce property",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "Internal name of the HubSpot contact property (text) that holds the Dittofeed subscription groups the person is subscribed to.",
          "error": null,
          "name": "HubSpot subscriptions property",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "URL or ID of the Google Sheet that logs bounces. Its first tab needs the columns Bounced at, Email, Dittofeed user, Subject, Template, Sent at.",
          "error": null,
          "name": "Deliverability log sheet",
          "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-12-02T01:42:37.357Z"
}
