Custom Workflow Action not calling Action URL

Hi all,

I’m following the Custom Workflow Actions tutorial to create an integration of Hubspot with an external SMS service.

I managed to create the workflow action definition, but can’t get the functions to work.

I’ve defined my function as follows, using Webhook.site as actionUrl

{
 "actionUrl": "https://webhook.site/cbf139bf-cae4-48f3-896b-41d130c91fe6",
 "published": true,
 "objectTypes": [
 "CONTACT"
 ],
 "inputFields": [
 {
 "typeDefinition": {
 "name": "smsText",
 "type": "string",
 "fieldType": "text"
 },
 "supportedValueTypes": [
 "STATIC_VALUE"
 ],
 "isRequired": true
 }
 ],
 "inputFieldDependencies": [],
 "outputFields": [
 {
 "typeDefinition": {
 "name": "status",
 "type": "bool",
 "fieldType": "booleancheckbox"
 },
 "supportedValueTypes": [
 "STATIC_VALUE"
 ]
 }
 ],
 "objectRequestOptions": {
 "properties": [
 "hs_object_id",
 "email",
 "phonenumber"
 ]
 },
 "labels": {
 "en": {
 "inputFieldLabels": {
 "smsText": "Message"
 },
 "outputFieldLabels": {
 "status": "Success"
 },
 "actionName": "Send SMS (via Zenvia)",
 "actionDescription": "Send SMS via Zenvia SMS integration",
 "appDisplayName": "Zenvia SMS",
 "actionCardContent": "Dispatches an SMS message to a contact's mobile phone through Zenvia SMS integration"
 },
 "pt-br": {
 "inputFieldLabels": {
 "smsText": "Mensagem"
 },
 "outputFieldLabels": {
 "status": "Sucesso"
 },
 "actionName": "Enviar SMS (Zenvia)",
 "actionDescription": "Envia mensagem SMS por meio da integra\u00e7\u00e3o com a Zenvia",
 "appDisplayName": "Zenvia SMS",
 "actionCardContent": "Dispara SMS para o n\u00famero de celular de um contato utilizando a integra\u00e7\u00e3o com a Zenvia"
 }
 },
 "functions": [
 {
 "functionType": "PRE_ACTION_EXECUTION",
 "functionSource": "exports.main = (event, callback) => {\n\n callback({\n \"data\": {\n \"hs_object_id\": event[\"object\"][\"objectId\"],\n \"phone\": event[\"object\"][\"phonenumber\"] ,\n \"text\": event[\"inputFields\"][\"smsText\"] \n }\n });\n}\n"
 },
 {
 "functionType": "POST_ACTION_EXECUTION",
 "functionSource": "exports.main = (event, callback) => {\n callback({\n \"outputFields\": {\n \"status\": \"true\" ,\n \"hs_execution_state\": \"SUCCESS\" \n }\n });\n}\n"
 }
 ]
}

However, when I test the custom action, I receive no requests on Webhook.site.

Also, Hubspot throws a “The response body for this request was empty” error on the cumsto action step of the workflow.

Am I missing something?

Hi @danilo_amorim!
Good afternoon and thank you for your patience! Here’s more info on webhooks in workflows: How to Trigger Webhooks in HubSpot Contact-Based Workflows
When you’re working with a third party app in a webhook or integration action, HubSpot can only see what the integration provides in terms of details for errors. You could try opening a support ticket with a link to your workflow and the API endpoint, headers, body, and response/error you got, but I’m afraid there wouldn’t be much more insight than what’s in the action logs regarding the error details, so I would actually recommend reaching out to the third party SMS app if possible.
If you can include the name of the SMS app, perhaps one of our HubSpot champions with expertise in webhooks and integrations with that third party app can lend some insight! @ChristinaKay @Jaycee_Lewis @ChrisoKlepke any thoughts?
Thank you,
Jessie
HubSpot Community Moderator

Hi Jessie, thank you for the reply.

Unfortonately, My company currently have a very basic Hubspot plan that doesn’t support sending webhooks straight from the Workflow. It would be very helpful, indeed.

Instead, I’m developing a custom Hubspot App to connect to my company’s account.

I managed to figure it out by myself in the meantime.

The PRE_ACTION_EXECTION function example on Custom Workflow Actions docs doesn’t work for me at all.. I suspect it’s because in the example there’s no “return” clause for the callback function.

Here’s a function example that is now working for me:

 exports.main = function(event, callback) { 
 return callback(transformRequest(event)); 
 }

 function transformRequest(request) { 
 return { 
 webhookUrl: request.webhookUrl, 
 body: JSON.stringify(request), 
 contentType: 'application/json', 
 accept: 'application/json', 
 httpMethod: 'POST' ,
 httpHeaders: {
 'xxx' : 'yyyy'
 }
 }; 
 }