{
  "name": "Warp Notes → HubSpot",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {
        "maxResults": 1
      },
      "mapper": {},
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0,
          "name": "Warp Notes webhook"
        },
        "restore": {
          "parameters": {
            "hook": {
              "data": {
                "editable": "true"
              },
              "label": "Warp Notes"
            }
          }
        },
        "parameters": [
          {
            "name": "hook",
            "type": "hook:gateway-webhook",
            "label": "Webhook",
            "required": true
          },
          {
            "name": "maxResults",
            "type": "number",
            "label": "Maximum number of results"
          }
        ],
        "interface": [
          {
            "name": "event",
            "type": "text"
          },
          {
            "name": "version",
            "type": "number"
          },
          {
            "name": "delivery_id",
            "type": "text"
          },
          {
            "name": "attempt",
            "type": "number"
          },
          {
            "name": "history",
            "type": "boolean"
          },
          {
            "name": "sent_at",
            "type": "text"
          },
          {
            "name": "workspace",
            "type": "collection",
            "spec": [
              {
                "name": "id",
                "type": "text"
              },
              {
                "name": "name",
                "type": "text"
              }
            ]
          },
          {
            "name": "note",
            "type": "collection",
            "spec": [
              {
                "name": "id",
                "type": "text"
              },
              {
                "name": "recorded_at",
                "type": "text"
              },
              {
                "name": "source",
                "type": "text"
              },
              {
                "name": "title",
                "type": "text"
              },
              {
                "name": "headline",
                "type": "text"
              },
              {
                "name": "summary",
                "type": "text"
              },
              {
                "name": "action_items",
                "type": "array",
                "spec": {
                  "type": "text"
                }
              },
              {
                "name": "transcript",
                "type": "text"
              },
              {
                "name": "captured_location",
                "type": "collection",
                "spec": [
                  {
                    "name": "lat",
                    "type": "number"
                  },
                  {
                    "name": "lng",
                    "type": "number"
                  }
                ]
              }
            ]
          },
          {
            "name": "company",
            "type": "collection",
            "spec": [
              {
                "name": "id",
                "type": "text"
              },
              {
                "name": "name",
                "type": "text"
              },
              {
                "name": "domain",
                "type": "text"
              },
              {
                "name": "phone",
                "type": "text"
              },
              {
                "name": "email",
                "type": "text"
              },
              {
                "name": "website",
                "type": "text"
              },
              {
                "name": "description",
                "type": "text"
              },
              {
                "name": "address",
                "type": "collection",
                "spec": [
                  {
                    "name": "text",
                    "type": "text"
                  },
                  {
                    "name": "lat",
                    "type": "number"
                  },
                  {
                    "name": "lng",
                    "type": "number"
                  }
                ]
              },
              {
                "name": "territory",
                "type": "text"
              },
              {
                "name": "labels",
                "type": "array",
                "spec": {
                  "type": "text"
                }
              }
            ]
          },
          {
            "name": "people",
            "type": "array",
            "spec": {
              "type": "collection",
              "spec": [
                {
                  "name": "id",
                  "type": "text"
                },
                {
                  "name": "name",
                  "type": "text"
                },
                {
                  "name": "title",
                  "type": "text"
                },
                {
                  "name": "company",
                  "type": "text"
                },
                {
                  "name": "emails",
                  "type": "array",
                  "spec": {
                    "type": "text"
                  }
                },
                {
                  "name": "phones",
                  "type": "array",
                  "spec": {
                    "type": "text"
                  }
                }
              ]
            }
          },
          {
            "name": "primary_person",
            "type": "collection",
            "spec": [
              {
                "name": "id",
                "type": "text"
              },
              {
                "name": "name",
                "type": "text"
              },
              {
                "name": "title",
                "type": "text"
              },
              {
                "name": "company",
                "type": "text"
              },
              {
                "name": "email",
                "type": "text"
              },
              {
                "name": "phone",
                "type": "text"
              }
            ]
          },
          {
            "name": "follow_ups",
            "type": "array",
            "spec": {
              "type": "collection",
              "spec": [
                {
                  "name": "id",
                  "type": "text"
                },
                {
                  "name": "title",
                  "type": "text"
                },
                {
                  "name": "due_local",
                  "type": "text"
                },
                {
                  "name": "time_zone",
                  "type": "text"
                },
                {
                  "name": "all_day",
                  "type": "boolean"
                },
                {
                  "name": "done",
                  "type": "boolean"
                },
                {
                  "name": "completed_at",
                  "type": "text"
                }
              ]
            }
          },
          {
            "name": "recorded_by",
            "type": "collection",
            "spec": [
              {
                "name": "user_id",
                "type": "text"
              },
              {
                "name": "name",
                "type": "text"
              },
              {
                "name": "email",
                "type": "text"
              }
            ]
          }
        ]
      }
    },
    {
      "id": 2,
      "module": "hubspotcrm:MakeAPICall",
      "version": 1,
      "parameters": {},
      "mapper": {
        "url": "/crm/v3/objects/companies/search",
        "method": "POST",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "qs": [],
        "body": "{\"filterGroups\":[{\"filters\":[{\"propertyName\":\"domain\",\"operator\":\"EQ\",\"value\":\"{{ifempty(lower(1.company.domain); \"none.invalid\")}}\"}]},{\"filters\":[{\"propertyName\":\"name\",\"operator\":\"EQ\",\"value\":\"{{ifempty(1.company.name; \"none.invalid\")}}\"}]}],\"properties\":[\"name\",\"domain\"],\"limit\":1}"
      },
      "metadata": {
        "designer": {
          "x": 300,
          "y": 0,
          "name": "Find the company by domain or name"
        },
        "restore": {
          "expect": {
            "method": {
              "label": "POST"
            }
          }
        },
        "parameters": [
          {
            "name": "__IMTCONN__",
            "type": "account:hubspotcrm",
            "label": "Connection",
            "required": true
          }
        ],
        "expect": [
          {
            "name": "url",
            "type": "text",
            "label": "URL",
            "required": true
          },
          {
            "name": "method",
            "type": "select",
            "label": "Method",
            "required": true,
            "validate": {
              "enum": [
                "GET",
                "POST",
                "PUT",
                "PATCH",
                "DELETE"
              ]
            }
          },
          {
            "name": "headers",
            "type": "array",
            "label": "Headers",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "qs",
            "type": "array",
            "label": "Query String",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "body",
            "type": "any",
            "label": "Body"
          }
        ]
      },
      "filter": {
        "name": "Only new notes",
        "conditions": [
          [
            {
              "a": "{{1.event}}",
              "b": "note.created",
              "o": "text:equal"
            }
          ]
        ]
      }
    },
    {
      "id": 3,
      "module": "hubspotcrm:MakeAPICall",
      "version": 1,
      "parameters": {},
      "mapper": {
        "url": "/crm/v3/objects/contacts/search",
        "method": "POST",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "qs": [],
        "body": "{\"filterGroups\":[{\"filters\":[{\"propertyName\":\"email\",\"operator\":\"EQ\",\"value\":\"{{ifempty(lower(1.primary_person.email); \"none@none.invalid\")}}\"}]}],\"properties\":[\"email\",\"firstname\",\"lastname\"],\"limit\":1}"
      },
      "metadata": {
        "designer": {
          "x": 600,
          "y": 0,
          "name": "Find the contact by email"
        },
        "restore": {
          "expect": {
            "method": {
              "label": "POST"
            }
          }
        },
        "parameters": [
          {
            "name": "__IMTCONN__",
            "type": "account:hubspotcrm",
            "label": "Connection",
            "required": true
          }
        ],
        "expect": [
          {
            "name": "url",
            "type": "text",
            "label": "URL",
            "required": true
          },
          {
            "name": "method",
            "type": "select",
            "label": "Method",
            "required": true,
            "validate": {
              "enum": [
                "GET",
                "POST",
                "PUT",
                "PATCH",
                "DELETE"
              ]
            }
          },
          {
            "name": "headers",
            "type": "array",
            "label": "Headers",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "qs",
            "type": "array",
            "label": "Query String",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "body",
            "type": "any",
            "label": "Body"
          }
        ]
      }
    },
    {
      "id": 4,
      "module": "hubspotcrm:MakeAPICall",
      "version": 1,
      "parameters": {},
      "mapper": {
        "url": "/crm/v3/owners",
        "method": "GET",
        "headers": [],
        "qs": [
          {
            "key": "email",
            "value": "{{ifempty(lower(1.recorded_by.email); \"none@none.invalid\")}}"
          },
          {
            "key": "limit",
            "value": "1"
          }
        ],
        "body": ""
      },
      "metadata": {
        "designer": {
          "x": 900,
          "y": 0,
          "name": "Find the owner by the rep's email"
        },
        "restore": {
          "expect": {
            "method": {
              "label": "GET"
            }
          }
        },
        "parameters": [
          {
            "name": "__IMTCONN__",
            "type": "account:hubspotcrm",
            "label": "Connection",
            "required": true
          }
        ],
        "expect": [
          {
            "name": "url",
            "type": "text",
            "label": "URL",
            "required": true
          },
          {
            "name": "method",
            "type": "select",
            "label": "Method",
            "required": true,
            "validate": {
              "enum": [
                "GET",
                "POST",
                "PUT",
                "PATCH",
                "DELETE"
              ]
            }
          },
          {
            "name": "headers",
            "type": "array",
            "label": "Headers",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "qs",
            "type": "array",
            "label": "Query String",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "body",
            "type": "any",
            "label": "Body"
          }
        ]
      }
    },
    {
      "id": 5,
      "module": "json:TransformToJSON",
      "version": 1,
      "parameters": {
        "space": ""
      },
      "mapper": {
        "object": "<b>{{1.note.title}}</b><br><br>{{1.note.summary}}<br><br>{{if(length(1.note.action_items) > 0; \"Action items:\"; emptystring)}}<br>{{join(1.note.action_items; \"<br>\")}}<br><br>Recorded by {{1.recorded_by.name}} in Warp Notes"
      },
      "metadata": {
        "designer": {
          "x": 1200,
          "y": 0,
          "name": "Escape the note body"
        },
        "restore": {
          "parameters": {
            "space": {
              "label": "Empty"
            }
          }
        },
        "parameters": [
          {
            "name": "space",
            "type": "select",
            "label": "Indentation",
            "validate": {
              "enum": [
                "tab",
                "2",
                "4"
              ]
            }
          }
        ],
        "expect": [
          {
            "name": "object",
            "type": "any",
            "label": "Object"
          }
        ]
      }
    },
    {
      "id": 6,
      "module": "hubspotcrm:MakeAPICall",
      "version": 1,
      "parameters": {},
      "mapper": {
        "url": "/crm/v3/objects/notes",
        "method": "POST",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "qs": [],
        "body": "{\"properties\":{\"hs_timestamp\":\"{{1.note.recorded_at}}\",\"hs_note_body\":{{5.json}},\"hubspot_owner_id\":\"{{4.body.results[1].id}}\"}}"
      },
      "metadata": {
        "designer": {
          "x": 1500,
          "y": 0,
          "name": "Create the note"
        },
        "restore": {
          "expect": {
            "method": {
              "label": "POST"
            }
          }
        },
        "parameters": [
          {
            "name": "__IMTCONN__",
            "type": "account:hubspotcrm",
            "label": "Connection",
            "required": true
          }
        ],
        "expect": [
          {
            "name": "url",
            "type": "text",
            "label": "URL",
            "required": true
          },
          {
            "name": "method",
            "type": "select",
            "label": "Method",
            "required": true,
            "validate": {
              "enum": [
                "GET",
                "POST",
                "PUT",
                "PATCH",
                "DELETE"
              ]
            }
          },
          {
            "name": "headers",
            "type": "array",
            "label": "Headers",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "qs",
            "type": "array",
            "label": "Query String",
            "spec": [
              {
                "name": "key",
                "type": "text",
                "label": "Key"
              },
              {
                "name": "value",
                "type": "text",
                "label": "Value"
              }
            ]
          },
          {
            "name": "body",
            "type": "any",
            "label": "Body"
          }
        ]
      }
    },
    {
      "id": 7,
      "module": "builtin:BasicRouter",
      "version": 1,
      "mapper": null,
      "metadata": {
        "designer": {
          "x": 1800,
          "y": 0
        }
      },
      "routes": [
        {
          "flow": [
            {
              "id": 8,
              "module": "hubspotcrm:MakeAPICall",
              "version": 1,
              "parameters": {},
              "mapper": {
                "url": "/crm/v4/objects/notes/{{6.body.id}}/associations/default/contacts/{{3.body.results[1].id}}",
                "method": "PUT",
                "headers": [],
                "qs": [],
                "body": ""
              },
              "metadata": {
                "designer": {
                  "x": 2100,
                  "y": -150,
                  "name": "Attach the note to the contact"
                },
                "restore": {
                  "expect": {
                    "method": {
                      "label": "PUT"
                    }
                  }
                },
                "parameters": [
                  {
                    "name": "__IMTCONN__",
                    "type": "account:hubspotcrm",
                    "label": "Connection",
                    "required": true
                  }
                ],
                "expect": [
                  {
                    "name": "url",
                    "type": "text",
                    "label": "URL",
                    "required": true
                  },
                  {
                    "name": "method",
                    "type": "select",
                    "label": "Method",
                    "required": true,
                    "validate": {
                      "enum": [
                        "GET",
                        "POST",
                        "PUT",
                        "PATCH",
                        "DELETE"
                      ]
                    }
                  },
                  {
                    "name": "headers",
                    "type": "array",
                    "label": "Headers",
                    "spec": [
                      {
                        "name": "key",
                        "type": "text",
                        "label": "Key"
                      },
                      {
                        "name": "value",
                        "type": "text",
                        "label": "Value"
                      }
                    ]
                  },
                  {
                    "name": "qs",
                    "type": "array",
                    "label": "Query String",
                    "spec": [
                      {
                        "name": "key",
                        "type": "text",
                        "label": "Key"
                      },
                      {
                        "name": "value",
                        "type": "text",
                        "label": "Value"
                      }
                    ]
                  },
                  {
                    "name": "body",
                    "type": "any",
                    "label": "Body"
                  }
                ]
              },
              "filter": {
                "name": "Contact found",
                "conditions": [
                  [
                    {
                      "a": "{{3.body.results[1].id}}",
                      "o": "exist"
                    }
                  ]
                ]
              }
            }
          ]
        },
        {
          "flow": [
            {
              "id": 9,
              "module": "hubspotcrm:MakeAPICall",
              "version": 1,
              "parameters": {},
              "mapper": {
                "url": "/crm/v4/objects/notes/{{6.body.id}}/associations/default/companies/{{2.body.results[1].id}}",
                "method": "PUT",
                "headers": [],
                "qs": [],
                "body": ""
              },
              "metadata": {
                "designer": {
                  "x": 2100,
                  "y": 150,
                  "name": "Attach the note to the company"
                },
                "restore": {
                  "expect": {
                    "method": {
                      "label": "PUT"
                    }
                  }
                },
                "parameters": [
                  {
                    "name": "__IMTCONN__",
                    "type": "account:hubspotcrm",
                    "label": "Connection",
                    "required": true
                  }
                ],
                "expect": [
                  {
                    "name": "url",
                    "type": "text",
                    "label": "URL",
                    "required": true
                  },
                  {
                    "name": "method",
                    "type": "select",
                    "label": "Method",
                    "required": true,
                    "validate": {
                      "enum": [
                        "GET",
                        "POST",
                        "PUT",
                        "PATCH",
                        "DELETE"
                      ]
                    }
                  },
                  {
                    "name": "headers",
                    "type": "array",
                    "label": "Headers",
                    "spec": [
                      {
                        "name": "key",
                        "type": "text",
                        "label": "Key"
                      },
                      {
                        "name": "value",
                        "type": "text",
                        "label": "Value"
                      }
                    ]
                  },
                  {
                    "name": "qs",
                    "type": "array",
                    "label": "Query String",
                    "spec": [
                      {
                        "name": "key",
                        "type": "text",
                        "label": "Key"
                      },
                      {
                        "name": "value",
                        "type": "text",
                        "label": "Value"
                      }
                    ]
                  },
                  {
                    "name": "body",
                    "type": "any",
                    "label": "Body"
                  }
                ]
              },
              "filter": {
                "name": "Company found",
                "conditions": [
                  [
                    {
                      "a": "{{2.body.results[1].id}}",
                      "o": "exist"
                    }
                  ]
                ]
              }
            }
          ]
        }
      ]
    }
  ],
  "metadata": {
    "instant": true,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "slots": null,
      "confidential": false,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": {
      "orphans": []
    }
  }
}
