Can support forms be submitted via the forms API?

SOLVE
kaious
Top Contributor

If we setup a support form to create conversations directly into our support inbox as detailed here: https://www.hubspot.com/product-updates/support-conversations can that form receive submissions via the forms API like a normal HubSpot marketing hub form?

0 Upvotes
1 Accepted solution

Accepted Solutions
kaious
Solution
Top Contributor

Went ahead and tested it, and yes, you can submit via the API. Just have to grab the API name for the issue and details fields (which are TICKET.subject and TICKET.content respectively, in case anyone else is wondering)

 

 

View solution in original post

10 Replies 10
kaious
Solution
Top Contributor

Went ahead and tested it, and yes, you can submit via the API. Just have to grab the API name for the issue and details fields (which are TICKET.subject and TICKET.content respectively, in case anyone else is wondering)

 

 

View solution in original post

sharonlicari
Community Manager

Thank you for sharing this @kaious 

 

Have a great rest of the week!

 

Best,

Sharon


¿Sabías que la Comunidad está disponible en Español?
¡Participa hoy en conversaciones en el idioma de tu preferencia,cambiando el idioma en tus configuraciones!

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


0 Upvotes
ellefsen
Member

@kaious are you using the AJAX method? I've tried submitting these fields as you describe, but I'm still unable to get past validation. If I add "TICKET.subject" to the fieldname I get an "Error in 'fields.TICKET.subject'. Field 'TICKET.subject' isn't in form definition".

 

Any ideas?

0 Upvotes
kaious
Top Contributor

Hi @ellefsen - we're using a custom form built on our website which collects the data and passes it to HubSpot via the forms API directly from our server, as opposed to a form embed (https://developers.hubspot.com/docs/methods/forms/forms_overview)

 

And make sure you're using a specific ticket form, not a general hubspot form (ie setup here: https://app.hubspot.com/live-messages-settings/{YOURPORTALID}/inboxes/edit/3246/forms )

 

Not sure if it's any help, but here's the body of the API call we're making:

 

{"fields":
[
{
"name":"email",
"value":"kaitestfeedbackformgeneral3@graphicfood.com"
},
{
"name":"joyous_source",
"value":"info-end-user.js"
},
{
"name":"firstname",
"value":"Kai"
},
{
"name":"lastname",
"value":"Crow"
},
{
"name":"phone",
"value":"987636792390"
},
{
"name":"TICKET.subject",
"value":"Joyous user enquiry form - Kai Crow"
},
{
"name":"TICKET.content",
"value":"And another test!"
}
],"context":{"pageUri":"http://localhost:3000/on-behalf-of","pageName":"About Joyous"},"skipValidation":true}
 
*Maybe that last skip validation piece is the key?
 
This is how the ticket shows up in HubSpot:
Screen Shot 2019-08-30 at 10.22.05 AM.png
doublesharp
Participant

I can confirm that I was unable to get this to work until I added 

skipValidation: true

to the form data. Thanks!

0 Upvotes
clickbitsmh
Member

I can confirm that the fields TICKET.subject and TICKET.content are only accepted when skipValidation is set to true. 

 

But with skipValidation, the API does not decline invalid email addresses. If I submit an email address like "abcdef", the API responds with status code 200 but has not created a ticket. So te end user submits our custom form, our server receives a status code 200, but the submitted ticket content is lost.

How can I ensure that a ticket has been created or get a failure status code if not?

0 Upvotes
kaious
Top Contributor

If it's just email address you want to validate, could you not build the validation on the form directly rather than waiting for the API response? (just a javascript regex validation on field update or something along those lines)

0 Upvotes
clickbitsmh
Member

I'm already validating the email address on the form, but I don't know the exact validation algorithm hubspot uses. If for some reason my validation passes but hubspot declines the email address, there is no ticket in hubspot but the end user did not get an error message.

0 Upvotes
kaious
Top Contributor

I think if you're ensuring the email address follows the valid pattern for an email address, you'll be pretty safe. Here's something on how HS validates, not sure if it's useful.

https://developers.hubspot.com/docs/faq/how-does-hubspot-validate-email-addresses

 

Also, I believe if the email address is found to be invalid, there will still be a contact and ticket created, just they will not be sent an email.

0 Upvotes
kaious
Top Contributor

Sorry @ellefsen, also the endpoint we're using is https://api.hsforms.com/submissions/v3/integration/submit/ - so I believe that is the AJAX method?

 

 

0 Upvotes