Zendesk Sell Outbound and Inbound Example

The following example is a Zendesk Sell configuration with multiple outbound workflows and an inbound workflow.

{
  "$version": "2",
  "api": {
    "base_url": "https://api.getbase.com",
    "rate_limit": {
      "app": {
        "requests": 10,
        "period": 1
      }
    },
    "pagination": {
      "style": {
        "type": "page",
        "page_number": {
          "param": "page",
          "value": 1
        },
        "page_size": {
          "param": "per_page",
          "value": 25
        }
      },
      "parser": {
        "next_page_url": {
          "!jq": ".meta.links.next_page"
        }
      }
    }
  },
  "auth": {
    "zendesk_oauth2": {
      "type": "oauth2",
      "configuration": {
        "authorization_base_url": "https://api.getbase.com/oauth2/authorize",
        "client_id": "",
        "client_secret": "",
        "scopes": [
          "read",
          "write",
          "profile"
        ],
        "token_url": "https://api.getbase.com/oauth2/token",
        "refresh_url": "https://api.getbase.com/oauth2/token"
      }
    }
  },
  "data_intake": [
        {
            "name": "zendesk_webhook",
            "type": "webhook",
            "scope": "workflow",
            "create": {
                "!http": {
                    "body": {
                        "enabled": true,
                        "url": "${webhook.url}"
                    },
                    "method": "PUT",
                    "path": "forms/${custom_data.form.value}/webhooks/${webhook.id}"
                }
            },
            "delete": {
                "!http": {
                    "method": "DELETE",
                    "path": "forms/${custom_data.form.value}/webhooks/${webhook.id}"
                }
            }
        }
    ],
  "workflows": [
    {
      "label": "Create and Update Leads in Zendesk Sell",
      "description": "Create and Update Leads in Zendesk Sell",
      "name": "create-lead-zendesk",
      "type": "automations",
      "auth": "zendesk_oauth2",
      "setup": {
        "connect": {
          "label": "Connect",
          "describe_connection": {
            "!pipe": [
              {
                "!http": {
                  "method": "GET",
                  "path": "/v2/users/self"
                }
              },
              {
                "!jq": ".body | {account_id: .data.id, description: (if .data.team_name | length > 0  then .data.team_name + \" - \" + .data.email else .data.email end)}"
              }
            ]
          }
        },
        "select": {
          "label": "Select Tags",
          "description": "You can associate one or more tags from ZendeskSell to the Lead being created",
          "form_fields": [
            {
              "label": "Tags (optional)",
              "id": "leads-tags",
              "type": "multiselect",
              "required": false,
              "placeholder": "Select Tag(s)",
              "options": {
                "!pipe": [
                  {
                    "!http": {
                      "method": "GET",
                      "path": "/v2/tags?resource_type=lead",
                      "pagination": true
                    }
                  },
                  {
                    "!jq": "[.body.items[] | .data | {display: .name, value: .id}]"
                  }
                ]
              }
            }
          ]
        },
        "map": {
          "label": "Mapping",
          "describe_source": {
            "label": "ActiveCampaign",
            "options": {
              "!resource": "ActiveCampaignContact.fields"
            }
          },
          "describe_target": {
            "label": "Zendesk Sell",
            "options": {
              "!pipe": [
                {
                  "!jq": "[\"first_name\", \"last_name\", \"organization_name\",\"status\", \"source_id\", \"title\", \"description\", \"industry\", \"website\", \"email\", \"phone\", \"mobile\", \"fax\", \"twitter\", \"facebook\", \"linkedin\", \"skype\"]"
                },
                {
                  "!http": {
                    "method": "GET",
                    "path": "/v2/lead/custom_fields"
                  }
                },
                {
                  "!jq": "${piped_content.1} + [.body.items[].data.name]"
                },
                {
                  "!jq": "[\"last_name\", \"email\"] as $required | map(. as $input | {id: ., title: . | split(\"_\") | join(\" \"), required: (if ($required | index($input) == null) then false else true end) })"
                }
              ]
            }
          }
        }
      },
      "data_pipeline": {
        "source": {
          "!resource": "ActiveCampaignContact"
        },
        "target": {
          "!pipe": [
            {
              "!jq": "[\"first_name\", \"last_name\", \"organization_name\",\"status\", \"source_id\", \"title\", \"description\", \"industry\", \"website\", \"email\", \"phone\", \"mobile\", \"fax\", \"twitter\", \"facebook\", \"linkedin\", \"skype\", \"tags\"]"
            },
            {
              "!jq": "${custom_data.tags | default} as $tags | if ($tags | length) > 0 then {tags: ${custom_data.tags} | map(.display)} else null end"
            },
            {
              "!jq": "${piped_content.0} | ${piped_content.1} as $core_fields | with_entries(select((.key as $k | $core_fields | index($k)))) + (with_entries(select((.key as $k | $core_fields | index($k) | not))) | {custom_fields: .}) + ${piped_content.2}"
            },
            {
              "!jq": ".email"
            },
            {
              "!http": {
                "method": "POST",
                "path": "https://api.getbase.com/v2/leads/upsert?email=${piped_content.4}",
                "body": {
                  "data": "${piped_content.3}"
                },
                "headers": {
                  "Content-Type": "application/json"
                }
              }
            }
          ]
        }
      }
    },
    {
      "label": "Create and Update Contacts in Zendesk Sell",
      "description": "Create and Update Contacts in Zendesk Sell",
      "name": "create-contact-zendesk",
      "type": "automations",
      "auth": "zendesk_oauth2",
      "setup": {
        "connect": {
          "label": "Connect",
          "describe_connection": {
            "!pipe": [
              {
                "!http": {
                  "method": "GET",
                  "path": "/v2/users/self"
                }
              },
              {
                "!jq": ".body | {account_id: .data.id, description: (if .data.team_name | length > 0  then .data.team_name + \" - \" + .data.email else .data.email end)}"
              }
            ]
          }
        },
        "select": {
          "label": "Select Tags",
          "description": "You can associate one or more tags from ZendeskSell to the Lead being created",
          "form_fields": [
            {
              "label": "Tags (optional)",
              "id": "contacts-tags",
              "type": "multiselect",
              "required": false,
              "placeholder": "Select Tag(s)",
              "options": {
                "!pipe": [
                  {
                    "!http": {
                      "method": "GET",
                      "path": "/v2/tags?resource_type=lead",
                      "pagination": true
                    }
                  },
                  {
                    "!jq": "[.body.items[] | .data | {display: .name, value: .id}]"
                  }
                ]
              }
            }
          ]
        },
        "map": {
          "label": "Mapping",
          "describe_source": {
            "label": "ActiveCampaign",
            "options": {
              "!resource": "ActiveCampaignContact.fields"
            }
          },
          "describe_target": {
            "label": "Zendesk Sell",
            "options": {
              "!pipe": [
                {
                  "!jq": "[\"first_name\", \"last_name\", \"name\",\"is_organization\", \"creator_id\",\"owner_id\",\"customer_status\", \"customer_status\", \"creator_id\", \"title\", \"description\", \"industry\", \"website\", \"email\", \"phone\", \"mobile\", \"fax\", \"twitter\", \"facebook\", \"linkedin\", \"skype\"]"
                },
                {
                  "!http": {
                    "method": "GET",
                    "path": "/v2/contact/custom_fields"
                  }
                },
                {
                  "!jq": "${piped_content.1} + [.body.items[].data.name]"
                },
                {
                  "!jq": "[\"last_name\", \"email\"] as $required | map(. as $input | {id: ., title: . | split(\"_\") | join(\" \"), required: (if ($required | index($input) == null) then false else true end) })"
                }
              ]
            }
          }
        }
      },
      "data_pipeline": {
        "source": {
          "!resource": "ActiveCampaignContact"
        },
        "target": {
          "!pipe": [
            {
              "!jq": "[\"first_name\", \"last_name\", \"name\",\"is_organization\", \"creator_id\",\"owner_id\",\"customer_status\", \"customer_status\", \"creator_id\", \"title\", \"description\", \"industry\", \"website\", \"email\", \"phone\", \"mobile\", \"fax\", \"twitter\", \"facebook\", \"linkedin\", \"skype\", \"tags\"]"
            },
            {
              "!jq": "${custom_data.tags | default} as $tags | if ($tags | length) > 0 then {tags: ${custom_data.tags} | map(.display)} else null end"
            },
            {
              "!jq": "${piped_content.0} | ${piped_content.1} as $core_fields | with_entries(select((.key as $k | $core_fields | index($k)))) + (with_entries(select((.key as $k | $core_fields | index($k) | not))) | {custom_fields: .}) + ${piped_content.2}"
            },
            {
              "!jq": ".email"
            },
            {
              "!http": {
                "method": "POST",
                "path": "https://api.getbase.com/v2/contacts/upsert?email=${piped_content.4}",
                "body": {
                  "data": "${piped_content.3}"
                },
                "headers": {
                  "Content-Type": "application/json"
                }
              }
            }
          ]
        }
      }
    },
    {
      "label": "Zendesk Sell",
      "description": "Create and Update Contacts in ActiveCampaign",
      "name": "zendesk-sell-forms",
      "type": "generic",
      "data_intake": "zendesk_webhook",
      "auth": "zendesk_oauth2",
      "resource_type": "form",
      "setup": {
        "connect": {
          "label": "Connect",
          "describe_connection": {
            "!pipe": [
              {
                "!http": {
                  "method": "GET",
                  "path": "/me"
                }
              },
              {
                "!jq": ".body | {account_id: .email, description: [.alias, .email] | join(\" - \")}"
              }
            ]
          }
        },
        "select": {
          "label": "Select Form",
          "description": "Select a form from the list.",
          "describe_selection": {
            "resource_id": {
              "!jq": "${custom_data.form.value}"
            },
            "display": {
              "!jq": "${custom_data.form.display}"
            }
          },
          "form_fields": [
            {
              "label": "Choose Your Form",
              "type": "dropdown",
              "id": "form",
              "placeholder": "Select Form",
              "options": {
                "!pipe": [
                  {
                    "!http": {
                      "method": "GET",
                      "params": {
                        "page_size": 200
                      },
                      "path": "/forms",
                      "pagination": true
                    }
                  },
                  {
                    "!jq": "[.body.items[] | {display: .title, value: .id}]"
                  }
                ]
              }
            }
          ]
        },
        "map": {
          "label": "Mapping",
          "describe_source": {
            "label": "Zendesk Sell",
            "options": {
              "!pipe": [
                {
                  "!http": {
                    "method": "GET",
                    "path": "/forms/${custom_data.form.value}"
                  }
                },
                {
                  "!jq": "[.body.fields[]|{title, id, type}]"
                }
              ]
            }
          },
          "describe_target": {
            "label": "ActiveCampaign",
            "options": {
              "!resource": "ActiveCampaignContact.fields"
            }
          }
        }
      },
      "data_pipeline": {
        "source": {
          "!jq": "[.form_response | .answers[] | { key: .field.id, value: (.text // .email // .date // .boolean // .url // .number // .phone_number // .file_url // .payment.amount // .choices.labels // .choice.label // .choice.other ) }] | from_entries"
        },
        "target": {
          "!resource": "ActiveCampaignContact"
        }
      }
    }
  ]
}