APIs & Integrations

mshcruz
Member

Specifying Zoom webinar ID when creating a HubSpot workflow via REST API

Hello,

 

I'm trying to create a HubSpot workflow that, upon submission of a form, adds the respondent to a Zoom webinar.

This can be done via HubSpot's web interface by using a form as the workflow's trigger and setting the webinar ID in an "Add Contact to Zoom Webinar" action.

 

However, I'm having some trouble doing the same via REST API. 

Following the instructions in the documentation (https://legacydocs.hubspot.com/docs/methods/workflows/v3/create_workflow), I used a GET request (GET /automation/v3/workflows/:workflowId) to retrieve a similar workflow and inspect the fields to be used in a POST request.

The response was the following (edited for brevity and privacy):

{
  "name": "Test Zoom Integration Workflow",
  "onlyEnrollsManually": false,
  "type": "DRIP_DELAY",
  "segmentCriteria": [
    [
      {
        "page": "",
        "operator": "HAS_FILLED_OUT_FORM",
        "form": "my-form-id-123",
        "filterFamily": "FormSubmission",
        "withinTimeMode": "PAST"
      }
    ]
  ],
  "actions": [
    {
      "type": "EXTENSION",
      "metadata": {},
      "extensionId": 5689175,
      "extensionInstanceVersion": 1,
      "extensionDefinitionId": 67,
      "extensionDefinitionVersion": 10,
      "actionId": 1,
      "stepId": 1
    }
  ]

  //...
}

 

The action's metadata field in the response is returned as empty (it was not edited), so it seems the response doesn't include the webinar ID that is necessary for the integration.

 

In any case, based on the above response, I was able to create the workflow sending the following payload in a POST request to /automation/v3/workflows:

{
    name: 'Workflow Created via REST API',
    type: 'DRIP_DELAY',
    onlyEnrollsManually: false,
    actions: [
      {
        type: 'EXTENSION',
        metadata: {},
        extensionInstanceVersion: 1,
        extensionDefinitionId: 67,
        extensionDefinitionVersion: 10,
        extensionId: 6217401,
        actionId: 1,
        stepId: 1,
      },
    ],
    segmentCriteria: [
      [
        {
          withinTimeMode: 'PAST',
          page: '',
          filterFamily: 'FormSubmission',
          form: 'my-form-id-123',
          operator: 'HAS_FILLED_OUT_FORM',
        },
      ],
    ],
  };

 

The problem, as expected, is that the action "Add Contact to Zoom Webinar" doesn't include the Zoom webinar ID.

 

I checked the request done by the web interface, and the actions part of its payload looked like this:

"actions": {
    "1": {
      "actionId": 1,
      "portalId": 12345,
      "flowId": 67890,
      "connection": null,
      "actionType": "AUTOMATION_EXTENSION",
      "actionTypeId": "1-67",
      "metadata": {
        "actionType": "AUTOMATION_EXTENSION",
        "extensionInstanceId": 6217401,
        "extensionInstanceVersion": 1,
        "extensionInstance": {
          "extensionDefinitionId": 67,
          "extensionDefinitionVersion": 10,
          "fields": [
            {
              "fieldKey": "webinarId",
              "fieldValue": { "valueType": "STATIC", "value": "123 123 1234" }
            }
          ],
          "objectRequestOptions": { "properties": [] }
        }
      },
      "outputFields": null
    }
  },

 

This request includes the webinar ID, so I tried different ways to add the same fields in the request I'm making, but they all failed.

For example:

- Request payload:

{
    name: 'Workflow created via API',
    type: 'DRIP_DELAY',
    onlyEnrollsManually: false,
    actions: [
      {
        type: 'EXTENSION',
        metadata: {
          fields: [
            {
              fieldKey: 'webinarId',
              fieldValue: { valueType: 'STATIC', value: '123 1234 1234' },
            },
          ],
        },
        extensionInstanceVersion: 1,
        extensionDefinitionId: 67,
        extensionDefinitionVersion: 10,
        extensionId: 6217401,
        actionId: 1,
        stepId: 1,
      },
    ],
    segmentCriteria: [
      [
        {
          withinTimeMode: 'PAST',
          page: '',
          filterFamily: 'FormSubmission',
          form: 'my-form-id-1234',
          operator: 'HAS_FILLED_OUT_FORM',
        },
      ],
    ],
  };

- Response (status 400): 

{
  "status": "error",
  "message": "Invalid input JSON on line 1, column 271: Cannot deserialize instance of `com.hubspot.automationextensions.models.extension.value.MissingTypeMetadata$Json` out of START_ARRAY token",
  "correlationId": "123-123-123"
}

 

So my question is: What field(s) should be used to specify the webinar ID when creating a workflow linked to a Zoom webinar?

 

Any help is appreciated!

0 Upvotes
3 Replies 3
webdew
Guide | Diamond Partner
Guide | Diamond Partner

Specifying Zoom webinar ID when creating a HubSpot workflow via REST API

Hi @dennisedson Thaks for tagging.
@mshcruz ,

Hope this will help for creating workflow:
$hapi_key = 'demo'; // Hubspot API
$url = 'https://api.hubapi.com/automation/v3/workflows?hapikey='.$hapi_key;
$data_url = 'https://www.domain.com/page'; // Url for action perform
$data = '{
"name": "Workflow for product Sync",
"type": "DRIP_DELAY",
"onlyEnrollsManually": true,
"actions": [
{
"type": "DELAY",
"delayMillis": 360000
},
{
"type": "WEBHOOK",
"url": "'.$data_url.'",
"method": "POST"
}
]
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$headers = array();
$headers[] = 'Content-Type: application/json';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);

$result = json_decode($result);


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 Upvotes
mshcruz
Member

Specifying Zoom webinar ID when creating a HubSpot workflow via REST API

Hello @webdew,

 

Thanks for the reply and the sample code.

Unfortunately that's not quite what I'm looking for.

 

I'm able to create other kinds of workflows via API, even using actions related to extensions, like an action related to a Salesforce campaign.

In this case, the problem is that, although I'm able to create the workflow with an "Add Contact to Zoom Webinar" action, I cannot find a way to specify the ID of the webinar for this action in the payload of the request. 

 

For instance, when using the action related to Salesforce, I can specify the campaign ID like this:

{
 type: 'SET_SALESFORCE_CAMPAIGN_MEMBERSHIP',
 status: 'Responded',
 campaignId: '1234567890ABC',
}

The above fields were present when retrieving a similar workflow that has this action, so I just used the same structure.

But for Zoom webinars, using the structure from a GET request doesn't work for a POST, as shown in the original post.

 

Any suggestions are appreciated! Thank you!

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Specifying Zoom webinar ID when creating a HubSpot workflow via REST API

@webdew , any thoughts on this?

0 Upvotes