Skip to main content

HubSpot integration with Ory Actions

HubSpot is an inbound marketing, sales, and customer service platform. It provides a suite of tools and services that allow businesses to manage and optimize their online presence, including website content, email marketing, social media, lead generation, and analytics.

Ory can synchronize user data with HubSpot via the HubSpot Contacts API.

To integrate HubSpot with your Ory Network project:

  1. Create a HubSpot account and set up the necessary contact lists for your customer data.
  2. Create a private app access token in HubSpot.
  3. In your Ory Network project, set up an Ory Action trigger that sends data to HubSpot destination when a specific event, such as successful registration, occurs.
  4. Test the integration to ensure that data is routed correctly from your application to HubSpot.

Configuration

Follow these steps to configure an integration that adds every newly registered user to your HubSpot contacts:

info

Not sure what Jsonnet is? Read the Ory Actions webhook guide.

  1. Create a Jsonnet file. It transforms the identity data from Ory to a format HubSpot understands.

    ./hubspot_identify.jsonnet
    function(ctx) {
    properties: {
    email: ctx.identity.traits.email,
    firstname: ctx.identity.traits.name, # User's first name taken from the "name" identity trait.
    # ... # You can get more user data depending on the identity schema you're using.
    },
    }
  2. To use this Jsonnet snippet, encode it to Base64 and save it to the clipboard:

    cat hubspot_identify.jsonnet | base64 | pbcopy
  3. Define the Ory Action as a JSON object. Remember to replace the placeholders with your data.

    ./webhook-action.json
    {
    "hook": "web_hook",
    "config": {
    "response": {
    "ignore": true
    },
    "auth": {
    "type": "api_key",
    "config": {
    "name": "Authorization",
    "value": "Bearer {PRIVATE_APP_ACCESS_TOKEN}",
    "in": "header"
    }
    },
    "url": "https://api.hubapi.com/crm/v3/objects/contacts",
    "method": "POST",
    "body": "base64://{BASE64_ENCODED_JSONNET}"
    }
    }
  4. Add this action to your Ory Network project using the Ory CLI.

  • Use this command to trigger this action after all successful registrations:

    ory patch identity-config {project-id} \
    --add "/selfservice/flows/registration/after/hooks/0=$(cat webhook-action.json)" \
    --format yaml
  • Alternatively, use this command to trigger the action only for registrations with social sign-in profiles:

    ory patch identity-config {project-id} \
    --add "/selfservice/flows/registration/after/oidc/hooks/0=$(cat webhook-action.json)" \
    --format yaml
tip

Read this document to learn more about choosing the authentication/registration method that triggers the action.