APIs & Integrations

JTannenbaum
Member

Webhook Response into Enumeration

Hey all,

I have an automation that uses a webhook to fire a GET request to an API. The response I get back contains a response body with something like this:

"TotalProductNames":";PRODUCT1;PRODUCT2;PRODUCT3"

I can use a checkbox when I test my webhook to indicate that this is an 'output action' and then reference it elsewhere in my automation.

 

As you might have gathered from the format, I would like this to be an enumeration value which appends to a multiple checkbox property against my chosen record type (company).

 

By default. the 'output action' value is a string, and I need to transform it into an enumeration.

 

I have some garbage code that I intuited that looks like this:

def main(event):
  # Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.
  raw_product_names = event.get('inputFields').get('raw_product_names')
  # Return the output data that can be used in later actions in your workflow.
  return {
    "outputFields": {
      "total_product_names": raw_product_names
    }
  }

As hubspot's prompting I've prepared my properties like this before the code:

JTannenbaum_0-1716990919092.png

I've also gone ahead and set up the output like this:

JTannenbaum_1-1716991021214.png

My question is - how can I get this to work? I simply want to populate this multi select checkbox from a webhook.

 

Any ideas or comments are appreciated.

 

 



0 Upvotes
6 Replies 6
SteveHTM
Guide | Partner
Guide | Partner

Webhook Response into Enumeration

@JTannenbaum - how about using the Python split function to seperate out the HubSpot view of the proiperty into a proper ennumertated type?

https://www.w3schools.com/python/ref_string_split.asp

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
JTannenbaum
Member

Webhook Response into Enumeration

Cheers Steve, so I tried that and it says "success" but I don't actually know how to check this because nothing changed against the test company I was asked to select. I am also not sure what would happen if it ever gets a value that's not already an option in the enum list.

thumbnail_image.pngthumbnail_image (1).png

 




0 Upvotes
SteveHTM
Guide | Partner
Guide | Partner

Webhook Response into Enumeration

A couple of extra thoughts:

- Since you are extracting data from the values stored in existing ennumerated type, it seems impossible that you could get an "invalid" product name generated when you split the composite string. 

- When you return your ennumerated value from the custom code, the next step is usually to copy it to an object property or properties. If this succeeds then you have a set of valid contents. If you copy/store it this way, then you will basically close the loop - the targeted internal HubSpot property values will be back to the "valuea;valueb;valuec;" type of format. I presume that you want some logic that manipulates the values in the code before simply copying them back to a property?

- If you inserted a new erroneous value then you will get an error when you pass back the controlling workflow and try to store in a object property.

 

I'm not sure if this is helping?

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Webhook Response into Enumeration

Hi @JTannenbaum ,

 

Couldn't you just use a 'Copy to property' action after your coded action to store the result of your coded action in the property of the enrolled company?



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


JTannenbaum
Member

Webhook Response into Enumeration

Hi Teun,

Thanks for your response. Copy to property is absolutely the end-goal of what I'm attemping, but the challenge is getting the data into a format that a multiple checkbox property will accept.

  1. My raw data coming in gets flagged as a possible 'output action'
  2. I select my data and it gets saved as an output action with an "Abc" (string) formatting type. This means that I cannot copy to action into a multiple checkbox.
  3. I use the custom code above to transform the string into an array.
  4. I define the output from the custom code as an enumeration type, and manually add the enumeration options underneath.
  5. I take the custom code output and Copy To Property into a multiple checkbox.

At least, that's the plan. The problem is that I don't really know how I can test that my custom code is doing what I want. I know a bit of python, do I need to define that my output is an array in code? How can I test it?

 

Essentially I want to go from ";Product1;Product2" to ["Product1","Product2"] in such a way that Hubspot will recognize it.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Webhook Response into Enumeration

Hi, @JTannenbaum 👋 Welcome to our community! Thanks for your post. I'd like to invite some of our community members to join the conversation — hey @Teun @SteveHTM @Mike_Eastwood, do you have any recent experience or tips you can share with @JTannenbaum?

 

Thank you for taking a look! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes