Not receiving `hsFormCallback` after form submission

Added my tracking code to my nextjs site

<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/abcd.js"></script>

and my form is getting submitted to hubspot properly. However, I want to allow the user to schedule a call on chilipiper. How do I do it?
I have been using this listener which I use on hubspot landing pages footer but it doesn’t seem to work. Not getting any messages after form submission.

 useEffect(() => {
 let lead = {};
 const hubspotCallback = (event) => {
 console.log("event", event);
 if (event.data.type === "hsFormCallback") {
 if (event.data.eventName === "onFormSubmit") {
 for (var key in event.data.data) {
 if (Array.isArray(event.data.data[key].value)) {
 event.data.data[key].value = event.data.data[key].value.toString().replaceAll(",", ";");
 }
 lead[event.data.data[key].name] = event.data.data[key].value;
 }
 if (Object.keys(lead).length <= 1) {
 lead = event.data.data;
 }
 } else if (event.data.eventName === "onFormSubmitted") {
 ChiliPiper.submit(cpTenantDomain, cpRouterName, {
 map: true,
 lead: lead,
 });
 }
 }
 console.log("lead", lead);
 };
 window.addEventListener("message", hubspotCallback);
 return () => {
 window.removeEventListener("message", hubspotCallback);
 };
 }, []);

Can someone help me on this?

Hi Devcer! I’m the PMM at Chili Piper.

Just brought this back to our CS team and they recommended you get in touch with your CSM or AM so y’all can look at it together. This is definitely our team should be able to help with. :orange_heart:

Hi Madeleine, I was able to figure out a way that works. I disabled the `Non-hubspot forms` setting for my form and started submitting the data through hubspot API. and on success callback I have called the Chilipiper methods for scheduling. Thanks again for your help. :slightly_smiling_face: