Webhooks

Tired of saving backups of your PDFs from your email notifications?  Looking for a way to send your PDF documents to other services?  Well, we’ve got a nice solution.  We have created a new type of notification, called Webhook Delivery.

You have probably seen the term “webhook” before, as we refer to our Merge URLs and Data Routing URLs as Webhook URLs. With this in mind, the process is very similar except we are sending the data to the URL instead of accepting the request from another source.

To set up a new Webhook Delivery, click the Delivery tab when editing your document, then click New Delivery. To finish, enter the URL of the webhook that you want to send your PDF to. There are a few other options, such as the Handshake Key and Conditions which are optional.

mceclip1.png


Now, what data should you expect to receive? The webhook can send the Merge ID, File Name, File Contents, and Fields (note: Fields must be enabled and configured under "More Options"). An easy way to see the data we send is to use a service like RequestBin (https://requestbin.com/).

Example:


$_POST[‘merge_id’] = 12345

$_POST[‘file_name’] = “Contract – John Smith.pdf”

$_POST[‘file_contents’] = base64_encode(“%PDF… (PDF CONTENTS) … %%EOF”)

$_POST['fields'] = array(
     'name' => 'John Smith',
     'email' => 'john.smith@example.com',
);
 

Since we are sending the contents of the PDF, you will need to save that into a PDF file on your server.

Additional settings can be configured by clicking the More Options button:

mceclip2.png

  • Always send this Webhook - Enabled by default, this option determines if conditions should be used for the delivery method.  Disabling this option will allow the delivery to evaluate various conditions to determine if the document should be delivered.
  • Send temporary download url (file_url) - Enabling this option will append a temporary link to download the document to the POST data of the request.
  • Send data using JSON - If enabled, this option will send the body of the POST data in JSON format.
  • Send merge data (uses key: "fields") - This option will append all merge data into the body of the POST data.
  • Append merge data to Webhook URL - Enabling this option will add the merge data to the end of the webhook URL as query parameters.
  • Add extra POST parameters - This option will allow you to add custom POST parameters to the body of the POST request.  This option can also be used to send specific/custom merge fields.  For example, if you wanted to include a contact name in the request, but it is not a merge field in the document template, you can simply add a new merge field by entering the following:
    mceclip3.png
    This will create a new key/value pair on the POST request body, where the key would be "name" and the value would be whatever is passed into the {$Full_Name} merge field.
  • Send custom headers - Enabling this option allows you to add custom headers to the POST request.
  • If an error occurs, send email to - This option will allow emails to be sent to a specified address in the event that Formstack Documents is not able to complete the delivery.



More information on Webhooks: http://webhooks.pbworks.com/

Was this article helpful?
3 out of 4 found this helpful

Comments

0 comments

Article is closed for comments.