Can support forms be submitted via the forms API?

SOLVE
Highlighted
Regular 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?

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Regular 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)

 

 

10 Replies 10
Highlighted
Regular 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)

 

 

Highlighted
Community Manager

Thank you for sharing this @kaious 

 

Have a great rest of the week!

 

Best,

Sharon

Reply
0 Upvotes
Highlighted
New 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?

Reply
0 Upvotes
Highlighted
Regular 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
Highlighted
New Member

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

skipValidation: true

to the form data. Thanks!

Reply
0 Upvotes
Highlighted
New Contributor

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?

Reply
0 Upvotes
Highlighted
Regular 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)

Reply
0 Upvotes
Highlighted
New Contributor

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.

Reply
0 Upvotes
Highlighted
Regular 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.

Reply
0 Upvotes
Highlighted
Regular 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?

 

 

Reply
0 Upvotes