Hi quicksketch,

I'm really sorry if this is a duplicate request. I did several searches in the issues, but did not see anything like this, which I find surprising, hence this pre-apology :-]

Ok, so it would be really neat to be able have a webhook (ala webhooks.org) field in the configuration of a webform to specify where to do an HTTP post of a form submission. The script will parse this data and do something cool with it, like update my CRM, or ERP system.

This would open up the things you can do with form submissions immensely! I could create a script on one of my servers that is called by webform whenever a form is submitted.

Hope this makes sense, and again if this has been asked already somewhere else, just let me know. I'd love to see how to do it.

Regards,
Enrique.

Comments

dwieeb’s picture

It sounds like the functionality you're describing is already built-in to Drupal. Drupal has quite a few hooks. You can create a custom module and use hook_form_alter() (a webhook that lets you hook into any Drupal form, including webforms) along with the Form API to specify a custom submit handler, where you can do anything you want.

quicksketch’s picture

A very old version of Webform actually used to have this functionality, where you could simply change the POST location of a Webform from being the Drupal site to some completely different URL. Unfortunately the confusion caused by this was significant, and it caused Webform not to store or process forms at all (including bypassing all validation, doh).

Anyway I think having this "web hook" textfield might not be bad idea, but it should probably exist outside the main Webform project. You can (relatively easily) add the ability to send the data to an additional URL by adding another #submit handler to the form, as described in the documentation here: http://drupal.org/node/1291574

Using the drupal_http_request() function, you can pass the original POST data forward to another URL.

enrique.delgado’s picture

Thanks, I think you get what I'm trying to do.

Instead of taking the approach that the older version of Webform did (having the form action point to an arbitrary URL, bypassing validation and such), I'm wanting to leave the submit and validation process (all of the process, in fact) of Webform intact, but have one more (optional) step in it.

After a Webform has successfully validated a form submission (and it's ready to email and/or save the data in the DB, etc) I also want it to optionally pass the original POST data to another URL as you describe. Yes, I could create a custom module as described in http://drupal.org/node/1291574 to add an additional #submit handler, but wouldn't it be nice if this was done by just having one more setting in Webform? It could be one textfield that expects a URL that said "Upon a valid form submission, also forward the form data to this external webhook" or something like that.

If you are amicable to it, I'd love to begin a new project with a module that complements the Webform module, and that adds such a functionality. Do I have your blessing on the idea?

enrique.delgado’s picture

Update: This feature request spawned the creation of this contrib module: http://drupal.org/sandbox/enrique.delgado/1786762. The module has been submitted for review as a proper contrib module. Wish me luck! :-]

enrique.delgado’s picture

Hi quicksketch,

I thought this day would never come, but lo and behold, my very first drupal module is now a full project! This achieves what we have been discussing here:

http://drupal.org/project/webform_remote_post

W00t!

quicksketch’s picture

Status: Active » Fixed

Yay! Nice. I'll be sure to reference it when others request this particular feature. It's actually a pretty good candidate for simple and direct SalesForce integration. Thanks for your contribution to Drupal!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.