JotForm User Guide / Advanced Features /

How to Setup a Webhook with JotForm

How to Setup a Webhook with JotForm

What is a Webhook?

A webhook is a technique used to send HTTP POST notifications to a URL. They can be used to connect apps together or just send data - read more.

  1. Open your form in the form builder and click on the settings tab, go to the integrations section and search WebHooks or filler the result in the dropdown with "Other".
    WebHooks Integration
    WebHooks Integration
  2. Add your WebHook URL.
    WebHook URL

To inspect or debug a webhook request, you can use RequestBin. Simply create a Request Bin and set the endpoint URL in your form's webhook (as seen in the screenshot on step 2). Make an actual submission to your form and then check the collected data on Request Bin.

Request Bin Endpoint

Example:

Request Bin Sample Output
Request Bin Sample Output

Here's an example PHP script that you may want to try on Webhook. This is a simple mailer script that will send the form submissions data to your email through Webhook.

<?php
//convert json data to php
$result = $_REQUEST['rawRequest'];
$obj = json_decode($resulttrue);

//Change with your emails
$emailfrom = "john@example.com"//Sender or From Email
$emailto = "paul@example.com"//Recipient, you can predefine or use a field value e.g. $obj['q4_email']
$subject = "You've got a new submission"//Email Subject Title

//Do not edit
$id = $_POST['submissionID']; //Get submission ID
$submissionURL = 'https://www.jotform.com/submission/'.$id//Construct submission URL

$headers = "From: " . $emailfrom . "\r\n";
$headers .= "Reply-To: ". $emailfrom . "\r\n"//Optional
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";

//New method, get data from the submissions page
$html = new DOMDocument;
$html->loadHTML(file_get_contents($submissionURL));
$body = $html->getElementsByTagName('body')->item(0);

//get html code after the body tag
foreach ($body->childNodes as $child){
    $html->appendChild($html->importNode($childtrue));
}

//make the table responsive so it appears nicely on email
$body = $html->getElementsByTagName('table');
foreach ($body as $width) {
    $width->setAttribute('width''100%');
}
$body = $html->saveHTML();

//Send email
@mail($emailto$subject$body$headers);
?>

Code: https://pastebin.com/raw/AmG72bve.

Make sure to replace the field names and emails with the ones from your form, you can also add fields if you prefer.

You can find more useful scripts here: Webhook PHP Script Examples.

If you have questions, post it below.

Contact Support:
Our customer support team is available 24/7 and our average response time is between one to two hours.
Our team can be contacted via:
Contact JotForm Support: https://www.jotform.com/contact/

Send Comment

17 Comments...

  • Jisan Mehran

    I was wondering how to send user account data to jotform using an API from jotform? I want jotform to automatically create an account for my clients when they sign up for an account on my website. Someone referred me to jotform's API page but I am not sure how to set up the system. I apologize if you see additional messages about this matter. I have not received any reply as of yet.

  • Jisan Mehran

    Hello, if I have my clients create an account on my website, then is there a way to have the forms they fill out save without them having to go through to hassle of finding an email? Or is there a way to have them automatically create an account on jotform when they sign up for an account on my website?

  • ACSIntake

    Hello,
    I am trying to create a form where the submission is sent to an email in plain text. However, I am read that this is not possible. The other option was a webhook. Please advise on how to go about doing this or if Jotforms will have this feature added back.
    Thank you

  • isrutig

    where do I copy http://pastebin.com/raw/AmG72bve
    can you please give us more instructions

  • rstiffler

    what if my endpoint requires an authorization header with a bearer token. Is there a place or method to enter that data in the webhook url?

  • iDeaologyCreativeLab

    I want to set it up to do sms notification and also

    and have the form submissions sent to my email

    can I use the sample scripts?

  • chad001

    Hello,

    Can someone help me how to do this in step-by-step. I had created a form in jotform and I want also that someone who submitted my form will receive a text message.

    Thanks in advance.

  • CRM_JOT

    Not able to test with request bin
    request bin url for my Form:
    http://requestbin.fullcontact.com/1fwmmin1

  • dave

    sending text message notation to customer phone number

  • OyeOk

    How do i send this post data in json format instead of multipart form??

  • abusamer

    It is not readily obvious what the field names are when parsing the rawRequest from the $_POST. It would be extremely helpful to have a procedure that builds php variables automatically.

  • researchpaperstobuy

    So where does this code above go to? To ASP default.aspx or?

  • ankeshibs

    Please provide me help step by step

  • Jakob

    Will I get the users Public IP as well at my webhook endpoint? I really need that for geo-receverse his country....

  • leojh

    Is is possible to set a secret key to authenticate against an API?

  • John Sheehan

    Thanks for the link to RequestBin! We have additional tools for debugging webhooks as well (including those that let you capture and forward to your live endpoints). Be sure to check them out: https://www.runscope.com

  • mdevane

    I am attempting to set up a direct integration to webmerge.me, but the problem appears to be the lack of ability on Jotform's end to generate the proper POST command with name/value pairs.

    Am I missing an option somewhere or is the POST command simply immature at this time?

    Thanks, Mark