Receiving webhooks from JotForm

  • Profile Image
    jetdb
    Asked on July 30, 2017 at 09:07 AM

    Hi,

    its supposed to send me the fields data + IP and other info upon submit, right ?

    In the webhook address I have something like "http://some.dns.net:5555" will there be a problem with that

    And I need to know what is the incoming request type should be "POST" ,right ? , I will be using an autoit server script to capture it, so anyone who can give some examples and explain how the post comes through will be great

    Thanks In Advance

     

  • Profile Image
    Mike
    Answered on July 30, 2017 at 10:11 AM

    Yes, the webhook will send the form data with internal submission details. The data is posted in multipart/form-data content type. You will need to test submission to the custom port, but it will most likely work.

    You can also test the webhook using free https://requestb.in service.

    We have some webhook processing PHP script examples provided here.

  • Profile Image
    liyam
    Answered on July 30, 2017 at 01:36 PM

    A multipart form data means that the data submitted is not encoded and by concept can handle different types of submissions other than text.

    With the response that you got, there is nothing significant to it. Conceptually, it can handle submission of an array, but with that specific information, there is no array in it. 

    If you can try using https://requestb.in/ as Mike has suggested, you should be able to see the information posted through the webhooks.

    But if you do not want to use that service and you wish to make use of your own script, you can try this code: 

    <?php

    $file = 'textfile.txt';
    $post = stripslashes_deep($_REQUEST);
    $post_content = print_r($post, TRUE);
    $fp = fopen($file, 'w') or die('Could not open file!');
    fwrite($fp, $post_content) or die('Could not write to file');
    fclose($fp);

    ?>

    Just make sure you have a textfile.txt file in the same directory and have its permissions to writeable.

    If you will see on the code, there is a variable there called $_REQUEST. In PHP, this is a global variable that is used for capturing submitted data. Since the information submitted via webhooks is array, then you should try handling it as an array, for which I used print_r() function to be able to write the data to the textfile.

    I suppose you might need more information since this can sound a bit more complicated, so feel free to get back to us if you need questions or additional information.

    Thanks.

  • Profile Image
    jetdb
    Answered on August 01, 2017 at 01:37 PM

    Thanks,

    1.What is the actual procedure to accept the webhook POST do I need to do a http request from my side to open\read the data (to the forms address), if you can add a few details what is requested and POSTed from sides from what address to what address ..

    2. Does the post received as json ?

  • Profile Image
    Nik_C
    Answered on August 01, 2017 at 03:29 PM

    Please refer to these articles: 

    https://www.jotform.com/blog/85-Send-Instant-Submission-Notifications-with-Webhooks

    https://www.jotform.com/help/245-How-to-Setup-a-Webhook-with-JotForm

    Also here http://api.jotform.com/docs/#form-id-webhooks you can find how the POST methods work.

    How the post is received depends on which webhook you used or created. You can use the existing ones: http://api.jotform.com/docs/#form-id-webhooks or create a new one http://api.jotform.com/docs/#post-form-id-webhooks.

    If you have any further questions please let us know.

    Thank you!

     

  • Profile Image
    jetdb
    Answered on August 01, 2017 at 04:39 PM

    Thanks,

    I now downloaded jotform-api-php-master.zip

    Using the webhook integration method

    How do I point to a PHP file, do I set the hook like: http://example.ddns.net/info.php:8000/ <--is this correct ?

  • Profile Image
    Chriistian
    Answered on August 01, 2017 at 06:25 PM

    If your code resides in info.php, you can point it to http://example.ddns.net/info.php.

    Let us know if you need further assistance.

     

     

  • Profile Image
    liyam
    Answered on August 01, 2017 at 11:20 PM

    Just an addition:

    You do not need to use the actual JotForm API if what you simply need to do is make use of webhooks.

    Basically what webhooks does is sending POST data via cURL, or from the back end of the process. Meaning, while you have made your submission and you reached your destination Thank you page, webhooks delivers your posts data to your other destination without the need for your browser to visit that page or URL.

    Also, $_POST and $_REQUEST vars contain arrays, so you will need your script to process it for that. If you recall, I used the print_r() function in order to process and print the data because print_r() function is specifically used for printing array data.

    If you need clarification on this, please let us know.

  • Profile Image
    jetdb
    Answered on August 05, 2017 at 12:25 PM

    Thanks

    Again, I would like to know little more about this process (as i see 2 variables are used in the php example $_REQUEST and  $_POST and i want to try with another scripting language ..)

    if I send an html (in an embedded form) when some one goes to my link (to my web server address) in the browser ,from where exactly the request needs to be made when using the web hook and to what address

    1. Do I need to make a request to the thankyou page?, is the thankyou page always the same address?

    * if the data is transmitted directly then What exactly is the webhook sending ? , like in What protocol ? what's better fitted to accept the data is it HTTP or TCP ?

    * like how for example does RequestBin pull the data and from where exactly

    Does it make a request based on first receiving a header of "Content-Type: multipart/form-data ..."

    And then tells the source where to send the data or the data is accepted directly from the webhook app ?

     

  • Profile Image
    jonathan
    Answered on August 05, 2017 at 05:25 PM

    #1 

    Yes you will need to make the request in your thank you page since you will need to use your own script.

    #2

    The protocol should be https or http depending on your website security.

    #3 

    Have you tried your webooks at https://requestb.in/ ? You should be able to inspect and debug the result.

    I hope this answers the questions. Let us know if you need further assistance.

  • Profile Image
    liyam
    Answered on August 05, 2017 at 09:00 PM

    To answer your questions/concerns: 

    You are saying that I need to send an http request to the thank you page based on the header I first received from the webhook ?

    No. Sending HTTP request to your Thank you page uses the Send POST data option of your form. This is different to using the webhooks integration feature. You can check this guide to know how to enable the sending of HTTP POST to Thank you page feature: https://www.jotform.com/help/51-How-to-Post-Submission-Data-to-Thank-You-Page 

    The webhooks integration feature does not require you to enable the option on sending POST data to thank you page. It sends the POST data, not to the thank you page but to your designated URL. For this reason, you will not be able to view the submitted information. It directly sends the data somewhere else without you seeing it. For this reason that if you wish to see the data submitted via webhooks, we recommend using https://requestb.in/.

    You do not have to mind the header information when sending POST data. It is only used for identifying what data is being sent. What you need to look into is the request information being sent which is in array format.

    will i need to include my api key in this process still trying to understand how this process is done .. ?

    No, you do not need to include your API key when using webhooks or enabling the Send Post data.

    I did try to use  https://requestb.in/ ? Just to take a look but I do want to try doing this with my script

    Using the services of RequestBin is specifically for testing purposes of what REQUEST or POST data is being sent by your form. As mentioned on their page, "RequestBin gives you a URL that will collect requests made to it and let you inspect them in a human-friendly way."

    Surely, you can use it with your script or other scripting languages if you like such as ASP, ASP.net, PERL, Python, C#, etc. So long as it can handle REQUEST or POST data submissions.

    Perhaps, you can share with us some details of your script so we can assist you better and provide you more specific how-to's. 

    Feel free to get back to us if you have additional questions. 

  • Profile Image
    jetdb
    Answered on August 06, 2017 at 07:21 AM

    Thanks Liyam,

    You will not be able to view the submitted information. It directly sends the data somewhere else without you seeing it. 

    I don't understand, if I have set the webhook to send the data back to me, the only reason I can think of as to why the form's data wont be sent is if the form contains sensitive data and measures have been taken to send the data to a "secured" else where 

    maybe there should be some option in the webhook app "allow sending the form data directly to this address ..(not recommended if the form contains sensitive data)"  meaning if the form does not contain any sensitive data and the operator consents the feature willingly ..

    Then perhaps what can be another safe way to retrieve data for a certain submit using the API ? , If the webhook can at least send the submission ID then that can be used as a trigger to using the api to retrieve the data based on a submission ID ?

    Demonstrating any code can't help if you are 100% sure the webhook sends the data else where  ..

    Thanks

  • Profile Image
    liyam
    Answered on August 06, 2017 at 12:03 PM

    As we have mentioned previously on this thread, you can make use of requestBin (https://requestb.in/) to make your tests for your form. 

    The point of using webhook is this: 

    1) You have website Point A which goes to to Point B every time you make a submission.
    2) You insert a webhook to send data from Point A to Point C. So every time someone sends a form submission and goes to Point B, but without the user getting any idea that the data sends to point C.
    3) The logic here is that the data is sent to Point C, but the page that the person can see does not go to Point C.

    Here is a sample form:
    https://form.jotformpro.com/72174947448973 

    Next, after making a submission through that form, visit this page: 
    https://requestb.in/1aj44na1?inspect 

    To answer your concern "maybe there should be some option in the webhook app "allow sending the form data directly to this address":

    As I have mentioned, you can send HTTP request to your Thank you page. Your thank you page can be any address that you like. This is a better solution I believe for you since you are having difficulty understanding the usage of webhooks. I also would suggest that you ignore first the usage of webhooks and use the How to Post Submission Data to Thank You Page.  Please check this guide to know how to enable the sending of HTTP POST to Thank you page feature: https://www.jotform.com/help/51-How-to-Post-Submission-Data-to-Thank-You-Page  

     

  • Profile Image
    jetdb
    Answered on August 06, 2017 at 02:28 PM

    Hi liyam,

    thanks for all the patience

    I tried what you recommended https://www.jotform.com/help/51-How-to-Post-Submission-Data-to-Thank-You-Page

    And set the "REDIRECT TO EXTERNAL LINK" to my address so this time I was able to receive the data !!

    Thank you very much !!