APIs & Integrations

AqsaQayyum
Member

How to create actions

SOLVE

Hi, 

I have created private application and done it's authentication. It's working fine.

Now, I want to create multiple actions for my application. How can I do this. I want to create actions like following attached screenshot.
What are the steps for it.

Screenshot 2024-01-19 at 9.26.30 PM.pngScreenshot 2024-01-19 at 9.27.09 PM.png


0 Upvotes
1 Accepted solution
zach_threadint
Solution
Guide

How to create actions

SOLVE

Hi @AqsaQayyum 👋

 

Based on my experience, testing custom workflow actions before making them available to your app users can be difficult.

 

First, I'd suggest creating a Test Public App (separate to your "Production" app, that only you will install within Test HubSpot Accounts). Make sure to set the status of your test custom action to "published". This can be achieved within your custom action definition like this:

 

 

{
    "actionUrl": "https://www.example.com",
    "published": true,
    
    ...
    ...
    ... 

    "objectTypes": [
        "CONTACT",
        "DEAL",
        "COMPANY",
        "TICKET"
    ]
}

 

 

You'll then need to install your Test HubSpot Public App within a Test HubSpot Account/Portal. Then create a Workflow within that test portal in order to debug your custom action.

 

Note that sometimes the changes you make to your custom action via API can take a while to be reflected within HubSpot. It's been a while since I last tested this, but previously changes were taking anywhere between 5 and 30 minutes to be reflected in HubSpot. Hopefully things have improved since then🤞

 

I hope this proves useful. Please let me know if you have any follow-up questions.

All the best,

Zach

--

Zach Klein
HubSpot Integrations & App Developer
Meanjin / Brisbane, Australia



Say g'day


If my post helped answer your query, please consider marking it as a solution.


View solution in original post

0 Upvotes
6 Replies 6
zach_threadint
Guide

How to create actions

SOLVE

Hi @AqsaQayyum 👋

 

Just to confirm, are you referring to HubSpot Custom Workflow Actions? If so, as far as I'm aware, you won't be able to achieve this with a HubSpot Private App. You'll instead need to create a "Public" App and then create your Custom Workflow Actions via API. Here's HubSpot's official documentation for this feature.

 

I hope this proves useful. Please let me know if you have any follow-up questions.

All the best,

Zach

--

Zach Klein
HubSpot Integrations & App Developer
Meanjin / Brisbane, Australia



Say g'day


If my post helped answer your query, please consider marking it as a solution.


0 Upvotes
AqsaQayyum
Member

How to create actions

SOLVE

Hi @zach_threadint ,

Hope you are doing good. 

Can you please check my query ?


Best Regards,
Aqsa Qayyum

0 Upvotes
AqsaQayyum
Member

How to create actions

SOLVE

Hi @zach_threadint ,

Yeah I want to create Hubsppot custom workflow actions.
I created publc application and tried following API by passing my APP_ID and Developer_Key. I got respoonse from this API but didn't know where I could see it's reflection or changes on my hubspot application UI.

this is the API that I tried:

app.post('/action', async (req, res) => {
try {
const requestData =
{
"objectTypes": [
"CONTACT"
],
"inputFields": [
{
"typeDefinition": {
"name": "staticInput",
"type": "string",
"fieldType": "text"
},
"supportedValueTypes": [
"STATIC_VALUE"
],
"isRequired": true
},
{
"typeDefinition": {
"name": "objectInput",
"type": "string",
"fieldType": "text"
},
"supportedValueTypes": [
"OBJECT_PROPERTY"
],
"isRequired": true
},
{
"typeDefinition": {
"name": "optionsInput",
"type": "enumeration",
"fieldType": "select",
},
"supportedValueTypes": [
"STATIC_VALUE"
]
}
],
"inputFieldDependencies": [
{
"dependencyType": "SINGLE_FIELD",
"dependentFieldNames": [
"objectInput"
],
"controllingFieldName": "staticInput"
}
],
"outputFields": [
{
"typeDefinition": {
"name": "myOutput",
"type": "string",
"fieldType": "text"
},
"supportedValueTypes": [
"STATIC_VALUE"
]
}
],
"objectRequestOptions": {
"properties": [
"email"
]
},
"labels": {
"en": {
"inputFieldLabels": {
"staticInput": "Static Input",
"objectInput": "Object Property Input",
"optionsInput": "External Options Input"
},
"actionName": "My Extension",
"actionDescription": "My Extension Description",
"appDisplayName": "My App Display Name",
"actionCardContent": "My Action Card Content"
}
},
"functions": [
{
"functionType": "POST_ACTION_EXECUTION",
"functionSource": "exports.main = (event, callback) => {\r\n callback({\r\n outputFields: {\r\n myOutput: \"example output value\"\r\n }\r\n });\r\n}"
},
{
"functionType": "POST_FETCH_OPTIONS",
"functionSource": "exports.main = (event, callback) => {\r\n callback({\r\n \"options\": [{\r\n \"label\": \"Big Widget\",\r\n \"description\": \"Big Widget\",\r\n \"value\": \"10\"\r\n },\r\n {\r\n \"label\": \"Small Widget\",\r\n \"description\": \"Small Widget\",\r\n \"value\": \"1\"\r\n }\r\n ]\r\n });\r\n}"
}
]
};

headers: {
// 'Content-Type': 'application/x-www-form-urlencoded'
}
});

console.log("action response checking ====", response);

} catch (error) {
console.error('Error during token exchange:', error.response ? error.response.data : error.message);
res.status(500).send('Error during token exchange');
}
});


Can yoou please let me knoe about it. Thank you so much.

Best Regards,
Aqsa Qayyum.
0 Upvotes
zach_threadint
Solution
Guide

How to create actions

SOLVE

Hi @AqsaQayyum 👋

 

Based on my experience, testing custom workflow actions before making them available to your app users can be difficult.

 

First, I'd suggest creating a Test Public App (separate to your "Production" app, that only you will install within Test HubSpot Accounts). Make sure to set the status of your test custom action to "published". This can be achieved within your custom action definition like this:

 

 

{
    "actionUrl": "https://www.example.com",
    "published": true,
    
    ...
    ...
    ... 

    "objectTypes": [
        "CONTACT",
        "DEAL",
        "COMPANY",
        "TICKET"
    ]
}

 

 

You'll then need to install your Test HubSpot Public App within a Test HubSpot Account/Portal. Then create a Workflow within that test portal in order to debug your custom action.

 

Note that sometimes the changes you make to your custom action via API can take a while to be reflected within HubSpot. It's been a while since I last tested this, but previously changes were taking anywhere between 5 and 30 minutes to be reflected in HubSpot. Hopefully things have improved since then🤞

 

I hope this proves useful. Please let me know if you have any follow-up questions.

All the best,

Zach

--

Zach Klein
HubSpot Integrations & App Developer
Meanjin / Brisbane, Australia



Say g'day


If my post helped answer your query, please consider marking it as a solution.


0 Upvotes
AqsaQayyum
Member

How to create actions

SOLVE

Hi @zach_threadint ,

Can you please let me know about following query:

How to delete the published action which is created using custom code actions.



Best Regards,
Aqsa Qayyum.

0 Upvotes
AqsaQayyum
Member

How to create actions

SOLVE

Hi @zach_threadint ,

It worked with Publish :  true. 
Thank you so much for help.


Can you please let me know about following query too.
I have some user defined custom fields. Which I want to show them as dynamic inputs in the action.

I have coded like following :
/////////

const fetchCustomFields = async () => {
let response = {};
try {
response = await axios.get('https://url/api/v1/custom-fields', {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${olcAuthToken}`
},
});
} catch (error) {
throw error;
}
return response?.data?.data;
}


My Actual Action Code
////////////////

app.post('/action', async (req, res) => {
const inputFields = [];
try {
const customFields = await fetchCustomFields();
customFields?.forEach(field => {
inputFields.push(
{
typeDefinition: {
name: field.key,
label: field.value,
type: 'string',
fieldType: 'text'
 
},
"supportedValueTypes": ["STATIC_VALUE"],
isRequired: true
});
});
const requestData =
{
"published":true,
"objectTypes": [
"CONTACT"
],
"inputFields": [

...inputFields,


],
"labels": {
"en": {
"inputFieldLabels": {
"staticInput": "Static Input",
"objectInput": "Object Property Input",
"optionsInput": "External Options Input"
},
"actionName": "Send PostCard3" + '_' + Math.floor(Math.random() * 0.3184),
"actionDescription": "My Extension Description",
"appDisplayName": "My App Display Name",
"actionCardContent": "My Action Card Content"
}
},
"functions": [
{
"functionType": "POST_ACTION_EXECUTION",
"functionSource": "exports.main = (event, callback) => {\r\n callback({\r\n outputFields: {\r\n myOutput: \"example output value\"\r\n }\r\n });\r\n}"
},
{
"functionType": "POST_FETCH_OPTIONS",
"functionSource": "exports.main = (event, callback) => {\r\n callback({\r\n \"options\": [{\r\n \"label\": \"Big Widget\",\r\n \"description\": \"Big Widget\",\r\n \"value\": \"10\"\r\n },\r\n {\r\n \"label\": \"Small Widget\",\r\n \"description\": \"Small Widget\",\r\n \"value\": \"1\"\r\n }\r\n ]\r\n });\r\n}"
}
]


Now the issue I am facing above code is not fetching the latest custom fields added by user after the action is published. How can I show the latest custom fields as inputs in the action, even after my action is published. 


Best Regards,
Aqsa Qayyum.




0 Upvotes