New onSubmit Action for Standalone Forms: Send Webhook

My idea is: Add Webhook functionality to Standalone Form onsubmit Actions

I think these groups of people would benefit from this idea: Everyone who enjoys the versatility of standalone forms

Why I think they would benefit from this idea: Webhook being in its own regard an extremely versatile tool, adding this to the Standalone onsubmit functionality seems like a fantastic idea.

Any code or resources to support this idea: Hopefully a lot of the heavy lifting dev work is already done in the campaign Action send webhook.

Are you willing to work on this idea?: I’m full of ideas but my talents lie elsewhere, so I yield to experts on this. I would love to contribute coffee.

What skills and resources do you need to explore this further?

Hello @entrepositive,

If you want to do this today you can:

  1. Create a form with an action > Segment
  2. Use the segment to start a campaign
  3. Call the webhook from your campaign

I think that adding this functionality to the form is a “bad idea”.
Simply because it would become a synchronous action that would slow down the submission of the form.
Indeed, we would have to wait for the webhook to be properly executed before being able to display the confirmation message (or the switch to the thank you page).
Moreover, in the event of a no response, how should this be handled in Mautic? Do we have to call back later, if so when, according to which business rule, how many times?

The fact that this is managed asynchronously in a campaign is surely the best possible use case.

This is my feedback on your suggestion.

I hope to continue the discussion,
Pierre

4 Likes

Hey @pierre_a ,

Thank you for the input. This is the kind of insight I couldn’t come up with myself at my current level of experience. I’ve learned something new today. Thanks!

EP

1 Like

I know this is a little bit of an old thread, a while back I did put in a suggestion to add form ID to the configuration when defining a system webhook. This is the post.

2 Likes

Actually, this feature already exists. It’s just does not use the word webhook.

Standalone forms have an action called “Post results to another form,” which functions as a HTTP post request. Webhooks can be used for this, pasting the URL into the “Post URL” field. See below.

1 Like

Unfortunately it seems to have some problems, as soon as there are HTML of file Upload fields. I tested it again today and got those errors in the log:

[2023-05-19 15:25:46] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Call to a member function getProfileFields() on null" at /var/www/vhosts/tape.twentyzen.com/httpdocs/app/bundles/FormBundle/EventListener/FormSubscriber.php line 219 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to a member function getProfileFields() on null at /var/www/vhosts/[HOST_PLACEHOLDER]/httpdocs/app/bundles/FormBundle/EventListener/FormSubscriber.php:219)"} {"hostname":"[HOST_PLACEHOLDER]","pid":2847113}
1 Like

Yip, the form just hangs :frowning:

you are correct, in fact this action is a little more interested than that, it is possible, depending on the context, to return a value back to the user browser, also mautic will send not only the form data but additional information like the contact id and field values. I will explain this in more detail in my Mauticon session next Thursday: “How to Prevent duplicate submission of a Mautic Form - Case Study and Technical Discussion”

2 Likes

Ah, I wonder if the form enctype can be controlled in your case, to multipart/form-data. Maybe from headers?

EP