Setting up an embedded chatbot post form submission

Hi folks, looking for support on this.

We work with a chatbot service company that has created an experience for visitors post form submission. I’m struggling to understand how to set this up.

There’s a script to be added to the page to enable the chatbot, but the parameters from the form need to flow into that chatbot through attributes. I’ve seen the form options but I don’t see anywhere where I could add a script.

The chatbot needs to show up on the thank you page. Right now the forms are embedded on a content page and so I wish to understand how to add it to the content page post form submission with a thank you text and also understand how I could set it up such that it’s redirected to a thank you page with the embedded chatbot.

Hey @swadib,

Thanks for bringing this to the Community!

It sounds like you’re after two things here. Both depend on where the form is embedded and how the chatbot script reads its attributes. It may be worth reaching out to the support team of the Chatbot service provider to clarify how it should be added to your site, but in the meantime here are few resources to start with:

Could you share whether your content page is hosted on HubSpot or elsewhere, and whether you’re using the standard form module or the raw embed code? That will help others point you in the right direction.

Looking forward to your response!

Sam, Community Manager

If the form is embedded with the classic embed code, you can add an onFormSubmitted callback inside hbspt.forms.create and load the chatbot script there, reading the field values from the submitted data and passing them in as attributes. For forms built in the new editor, listen for the form submission success event on the window instead; the developer docs list the exact event name. The other route is to set the form to redirect to a dedicated thank you page and add the values to the redirect URL, then have the chatbot read them on that page. That second option is easier to test and keeps the content page clean.