Webhooks
20 min
with the webhooks app in , you can create custom webhooks, custom mailhooks, and webhook responses custom webhook module use the custom webhook module to instantly trigger a from any third party service this module generates a unique webhook url that services call to send data to each uses its own webhook you can't use the same webhook in multiple create a new webhook to create a new webhook from the custom webhook module in the builder, search for the webhooks > custom webhook module in the app search next to the webhook dropdown, click add in webhook name , give your webhook a unique name optionally, in api key authentication , add one or multiple api keys click + add api key click create a keychain in name , give your new keychain a unique name in api key value , enter a key for your new keychain it must contain ascii characters and be no more than 512 characters store it in a safe place; for security reasons, you won't be able to view it afterwards click create add additional api keys as needed in requests, include api keys in the x make apikey header click save you've now added a new webhook for the custom webhook module generates a url and starts listening for requests define the webhook data structure (optional) it is recommended to define the data structure for incoming webhook requests a data structure tells what values to expect from third party services calling the webhook without one, accepts all incoming data without validation unexpected or invalid data won't be flagged at the webhook, and later modules that depend on that data may return errors you can define a webhook data structure when you create a webhook or call the webhook url method how when to use it create a webhook when creating a webhook, in advanced settings > data structure , add a new data structure or select an existing one you know the data values in advance and want to validate incoming data call the webhook send a test request with sample data to the webhook url from your third party service or postman you want to see the data values available to map in later modules re call the webhook in the custom webhook module settings, click detect new values and send another test request with new sample data you want to change the data structure if you use the calling or re calling webhook method doesn't create a reusable data structure in the data structures section and stores the data structure internally with the webhook does not validate incoming data supported incoming data formats supports the following incoming data formats query string form data json if a webhook receives data in both the query string and either form data or json data at the same time, the system combines the data into a single bundle if the request contains duplicate data in different formats, the query string takes precedence and overwrites the data that was received in the other formats it is not recommended to duplicate data in query strings, form data, and json query string get https //hook make com/yourunique32characterslongstring?name=make\&job=automate form data post https //hook make com/yourunique32characterslongstring content type application/x www form urlencoded name=integrobot\&job=automate multipart post https //hook make com/yourunique32characterslongstring content type multipart/form data; boundary= generatedboundary \ generatedboundary content disposition form data; name="file"; filename="file txt" content type text/plain content of file txt \ generatedboundary content disposition form data; name="name" make \ generatedboundary in order to receive files encoded with multipart/form data , it is necessary to configure a data structure with a collection type field that contains the nested fields name , mime and data the field name is a text type and contains the name of the uploaded file the mime is a text type and contains a file in the \[mime] format https //en wikipedia org/wiki/mime the field data is a buffer type and contains binary data for the file being transferred json post https //hook make com/yourunique32characterslongstring content type application/json {"name" "integrobot", "job" "automate"} to access the original json, open the webhook's settings and enable the json pass through option the maximum allowed webhook's payload size ( content length ) is 5 mb (5 242 880 bytes) regardless of the subscription tier enable webhook request headers (optional) optionally, to use headers from incoming webhook requests in your , enable request headers in the webhooks > custom webhooks module, click edit or add next to webhook toggle advanced settings select yes in get request headers you've now enabled request headers x make apikey is a reserved word if you use it, you will not receive the value as it is automatically sanitized edit webhook settings you can edit a webhook after creating it if you have a team admin , team member , or team restricted member role to edit webhook settings go to webhooks on the left sidebar click the three dot menu next to a webhook click edit edit the fields you want to change and save use the table below to understand all webhook settings from the custom webhook module setting description api key authentication provides an optional extra layer of security to control access management for example, you can control a user's access by adding, removing, or updating api keys ip restrictions an allowed list of ip addresses delimited by comma only webhook requests that come from the specified ips will be processed use cidr notation to allow list a subnet leave empty if you want to allow requests from all ips data structure select an existing data structure or create a new data structure for the webhook will use the data structure to validate the incoming data requests that don't pass validation will be rejected with http status code 400 get request headers extracts headers data from the webhook request and makes the data available for mapping in the scenario get request http method extracts the http method from the request and makes the method available for mapping in the scenario json pass through passes json payloads to subsequent modules in the scenario as a text string, as opposed to breaking the payload down into mappable fields the webhook section applies only to webhooks from the custom webhooks module custom mailhook module custom mailhook is an instant trigger module that can be triggered by sending an email to the email address generated by this module the maximum size of an email, including its attachments, that you send to a mailhook is 25 mb example the custom mailhook module monitors your incoming emails without the need to have a scheduled run of the add the custom mailhook module to your (webhooks > custom mailhook) generate a mailhook email address, and copy the address to the clipboard save and run the open your email account settings, and configure forwarding use the email address generated by the custom mailhook module in step 2 (above) as the forwarding address for gmail click the cogwheel in the top right corner, and then click see all settings open the forwarding and pop/imap tab click the add a forwarding address button enter the email address you have generated and copied in step 2 above, and click next after that, a popup window will appear click proceed a confirmation link has been sent to your mailhook run the custom mailhook module to see this code in the output under bundle > text if you use gmail for work or school, you don't need to verify the forwarding address enable the forwarding, and save changes add other desired modules to the then save and activate the now, every time a new email is received in your email account, the custom mailhook module in your is triggered and receives the email message data the sender and various recipient addresses (to cc and bcc ) are resolved in the data structure of the incoming mail reply to can be found in the header section webhook response module the default response to a webhook call contains a simple text, "accepted " the response is returned to the webhook's caller right away during the execution of the custom webhook module you can easily test it like this place the custom webhook module in your add a new webhook in the module's configuration copy the webhook's url to your clipboard run the the custom webhook module should be waiting for the webhook call (see on the right) open a new browser window, paste the copied url in the address bar and press enter the custom webhook module will be triggered and the browser will display the following page these are default responses when the does not contain the webhook response module http status code body webhook accepted in the queue 200 accepted webhook queue full 400 queue is full if you wish to customize the webhook's response, employ the module webhook response the configuration of the module contains two fields status and body the status field should contain http response status codes https //en wikipedia org/wiki/list of http status codes like 2xx for success (e g 200 for ok), 3xx for redirection (e g 307 for temporary redirect), 4xx for client errors (e g 400 for bad request), etc the body field should contain anything that will be accepted by the webhook's call it can be a simple text, html, xml, json, etc it is advisable to set the content type header to the corresponding mime type https //en wikipedia org/wiki/media type text/plain for plain text, text/html for html, application/json for json, application/xml for xml, etc these are additional default responses when the does contain the webhook response module http status code body encounters an error 500 failed to complete the timeout for sending a response is 180 seconds if the response is not available within that period, returns a '200 accepted' status html response example configure the webhook response module as follows status 2xx success http status code, https //en wikipedia org/wiki/list of http status codes#2xx success e g 200 body html code, e g \<!doctype html> \<html lang="en"> \<head> \<meta charset="utf 8"> \<title>thank you!\</title> \</head> \<body>thank you, {{1 name}}, for your request! \</body> \</html> custom headers key content type value text/html it will produce an html response that will be displayed like this in a web browser redirect example configure the webhook response module as follows status 3xx redirection http status code https //en wikipedia org/wiki/url redirection#http status codes 3xx , e g 303 custom headers key location value the url you would like to redirect to troubleshooting webhooks a common problem when working with webhooks is missing some of the data values that you wanted to map in later modules to add new values, re determine the data structure in the custom webhook module in the builder, open the webhooks > custom webhook module click detect new values send a request with sample data from your third party service to the webhook url you've now de determined the data structure the new data values that detected are ready to map in later modules