Tools
Webhooks
8 min
webhook trigger the webhook trigger allows one app to automatically notify engini through a predefined http callback that an event has occurred it allows real time communication and data exchange between different apps to engini to use this activity, follow these steps when adding your workflow choose for the trigger “webhook” software follow the next steps to learn how to define this activity url the url is automatically created by engini it’s not possible to edit it click on the icon to the right of the url to copy it each webhook url is unique to the specific workflow you created method specifies the type of request that should be sent by the external application the method’s default value is “post” to define a method, follow the next steps click on the empty field choose from the tooltip the method you want to use learn more about the method types in http requests guide relative url (optional) specifies the endpoint url that the trigger will listen to for incoming http requests to learn more about relative url click here load json/xml sample to load the sample, there are two options using documentation obtain the json/xml payload sample from the documentation of the system that sends the webhook click on the blue sentence to enter a sample of the incoming request payload and engini will try to parse it and create the structure of the incoming request for you to use in the following activities to extract data from the incoming request using the running log wait to receive a webhook enter the run history log in engini expand the webhook output block and scroll to the end of it copy the entire “responsebody” value as seen selected in the image below switch back to edit mode and click on the blue sentnce and paste the copied json as seen in the image below body structure is exactly where you can see the structure of your json it visually displays the "skeleton" of your data showing the hierarchy and data types (like string, number, or collection) confirming that the system understands the json so you can use its data in the next steps important the webhook default response is 200 status code send webhook response a workflow that is triggered with a webhook will normally send a 200 status code response upon receiving the request adding the “send webhook response” activity to a workflow that is triggered with a webhook allows you to customize the response the workflow will return you can place this activity in different places inside the workflow, depending on the response you want to send back and when to send it choose the core software and click on the “send webhook response” action to define the webhook response follow the next steps status code – click on the field and choose from the tooltip the status code you want to return body type click on the right errow and choose from the tooltip the body type the activity supports 4 body type application/json file (application/octet stream) text/plain text/xml body – click on the empty field to enter the response body you want to return add headers additional metadata about the request, such as the type of data the engini can accept, the length of the request body, and authentication information click on the “add headers” button to add a header click on the key field to enter the key, and on the value field to enter a value each header consists of a key value pair, where the key is the name of the parameter, and the value is the data associated with that parameter click on the “add key” button to add more keys redirect example to set up a webhook response redirect, configure the webhook response module as outlined below status code define a 3xx redirection http status code, such as 303, in the ‘status code’ field click on the field and choose from the tooltip the status code you want to return ou can select one of these redirect status codes 301 – moved permanently 301 indicates a permanent url redirection the requested resource has been permanently moved to a new url subsequent requests should use the new url 302 – found/temporary redirect 302 signifies a temporary redirection it tells the client to temporarily visit a different url future requests should still use the original url 303 – see other 303 advises the client to visit another url it is typically used in response to a post request, redirecting the user to another page to retrieve the response 307 – temporary redirect 307 indicates a temporary redirection similar to 302 but preserves the method (get, post, etc ) used in the original request for future requests 308 – permanent redirect 308 is similar to 301 but preserves the method (get, post, etc ) used in the original request for future requests it signifies a permanent url redirection headers add the following custom header details key location value the url you intend to redirect to for example, “https //www enginiexample com” this configuration directs the response to a specified url upon trigger relative url in the context of webhooks, a relative url is a way to specify a resource’s link relative to the webhook’s endpoint instead of providing the full and absolute url, a relative url allows you to insert dynamic parameters or variables into the link when the webhook is triggered, you can utilize the values received in the properties for further processing within your workflow using a relative url example, let’s consider the following scenario suppose you have the following webhook endpoint url https //workflowapi engini io/webhook/v2/123engini456example/{itemid} when you want to utilize this link and replace the value of “itemid,” you specify the desired value in the appropriate place within the url for instance, if you want to trigger the workflow with an “itemid” of 123, use the following url https //workflowapi engini io/webhook/v2/123engini456example/123 customization the “itemid” is just an example and can be named and used as per your preferences you can also include multiple properties separated by commas in the url to pass and process various data as needed for example, you can format your url like this https //workflowapi engini io/webhook/v2/{property1}/{property2}/{property3}