How to Set Up a Webhook with Jotform

June 20, 2022

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.

Send Instant Submission Notifications with Webhooks

To add a webhook and send submissions to your endpoint

  1. Go to the Settings tab in the Form Builder.
  2. Click Integrations on the left.
  3. Search for “Webhooks”.
  4. Select WebHooks.
  5. Enter the endpoint URL in the Add WebHook field.
  6. Finally, click the Complete Integration button.
form-builder-add-webhooks-integration-min.png

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

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

// 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($child, true));
}
// 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);
?>

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

Check out the “Webhook PHP Script Examples” guide to find more helpful scripts.

Rules and Limitations

Below are key points you must consider to accomplish the webhook request.

  • Jotform has a 30 seconds timeout to accomplish a request. 
  • The endpoint where Jotform sends the webhook data may have limitations that would prevent the request from being processed. They include the following but are not limited to:
    • Timeout to close the connection on the endpoint.
    • The maximum size of data accepted may be lower than the submission data.
    • Firewall rules on the endpoint.
  • Additionally, if your form data is encrypted, Jotform sends the webhook data as encrypted. 
Was this guide helpful?
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:

Support Forum: https://www.jotform.com/answers/

Contact Jotform Support: https://www.jotform.com/contact/

Send Comment:

Jotform Avatar
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Comments:

  • Gabriele Sannicandro
  • Kurniawan Sugi Purwanto