APIs & Integrations

nikodev
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Best way to associate a batch of tickets to a contact

Hi there, 

 

Trying to do something that I suppose is somewhat advanced...looking for some input from some of you smart people. 

 

I have a form that gives the ability to enter ticket information to submit multiple tickets, dyanmically, based on user input.  I plan on batch creating tickets based on this data. 

 

The form also has inputs for contact information which I'll be submitting to the appropriate endpoint. 

 

My problem: I need to associate each batch of tickets to the contact that fills out that form. 

 

Does anyone know of a good way to go about achieving this?

 

You have no idea how much of a help it would be. I've put in just about 100 hours on this project over the last 2 weeks. 

 

Please help me 🙂🙃

A8 Labs

5 Replies 5
nikodev
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Best way to associate a batch of tickets to a contact

In the event that anyone ever has the misfortune of running into a similar issue, I'll explain what I ended up doing, the short version. 

Made the contact post request -> created a conditional to check whether it was a 200, or a 409. If it was a 409, I accessed the message property, and extracted the contactId that is held within a string and stored it in a variable. 

If 200, got the id held in the response. 

Batch created the tickets. Put the response in an array and recorded the length. Iterated to build an object with the contactId I stored earlier,extract each id from the ticket creation response and fuse them into objects to satisfy the requirements of the batch associations endpoint. Sent that off. At the time of writing, I'm now tracking down and killing bugs.

It was no easy task for me. 

A8 Labs

tominal
Guide | Partner
Guide | Partner

Best way to associate a batch of tickets to a contact

Hey @nikodev,

I'm hoping this is a form outside of HubSpot so that you have control over the ticket/contact creation. If so, have you checked out the Associations API? You can build an array of inputs to immediately associate those tickets to contacts.

Hope this helps.


Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com
nikodev
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Best way to associate a batch of tickets to a contact

Hey @tominal ,

Thanks for the response. I have checked out the associations API, but I'm not quite sure how I'd go about collecting the appropriate IDs to make the appropriate associations at the the same time as I'm submitting these tickets/contacts for creation. Would you mind expanding on that a bit? 

A8 Labs

0 Upvotes
tominal
Guide | Partner
Guide | Partner

Best way to associate a batch of tickets to a contact

This is all dependent on whether you are working outside of HubSpot, but store the response data of the tickets and contacts you're creating in variables. Then you can post those IDs to the associations API to associate them all in bulk.

Hope that helps.


Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com
0 Upvotes
nikodev
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Best way to associate a batch of tickets to a contact

Sorry - I didn't respond to that part of your question in my previous reply. I am working outside of HubSpot. Using serverless functions to take care of submissions. This is a good idea, I'm going to try accessing the response data appropriately to send the association request as the last step of my function. This will be interesting. Thank you. 

A8 Labs