Webhook is used to send HTTP requests to a third-party app or web service every time an event (when conditions are met) occurs.


ARTICLE NAVIGATION

This URL of the app or web service that’s hit by the API request is called a callback URL.

For eg: When a deal is won, you can send a request to generate an invoice from a third party app using a webhook request.  

Who could possibly configure this? 

  • Admin of the account

  • Developers with REST API skills

You may configure HTTP URLs and associate them in workflow rules to automate the entire process.

Let’s see how to configure one such case. 

Scenario: When a deal is won, an external invoice generator automatically generates an invoice via a webhooks request. 

How to set up a Webhook request?

 

Workflow:

 

  1. Login as admin.

  2. Go to Admin Settings > Workflows > Create Workflow.

  3. Add a Name, example: Generate invoice when deal is won using Webhooks and a Description, example:  For every deal won, automatically generate an invoice from the Invoice generator app using webhooks.

  1. Choose the Record type: Deal.

  2. Configure your Workflow’s, 

           Execution trigger: Once, when it’s created or updated

           Conditions: Deal Property > Deal stage > is in > {Pipeline}:Won

  1. Now choose an action from the drop-down.
    Action: Trigger Webhook

  2. In the overlay that comes up, 

  1. Choose the Request type as POST. (We are creating an object(invoice)).

 

            The request types available are:

REQUEST TYPE

PURPOSE

POST

Create an object

GET

Fetch one or more objects

PUT/PATCH

Update an object

DELETE

Remove an object

  

Note: Each 3rd party app uses the request type in a different way, but most applications follow standard methods.


REQUEST TYPE

FIELDS

GET or DELETE

  • The callback URL (required)

  • Authentication parameter (optional)

  • Custom headers (optional)

POST, PUT or PATCH

  • The callback URL (required)

  • Authentication parameter (optional)

  • Custom headers (optional)

  • Encoding (required)

  • Content type (required)

  • Content (required)

    

b:  Enter the Call Back URL, for eg.: https://invoice-generator.com/#/1

      If you want to add the deal’s id as a placeholder use the insert placeholder option


c:  If the third-party application’s URL that is going to be hit requires authentication, check the Required Authentication option. You can authenticate either with,

  • Username and password

  • Your account(third party app’s) API key (click I have API key)

d:  Click Add custom headers to include information with the content such as security details, API version details, and so on. A custom header has to be entered as a header-value pair in the following format: X-Sample-CustomHeader1: VALUE.


Note: 
1. The trigger will not be executed when a header is given with spaces in between, like X-Sample Custom Header1: VALUE. Although, if space is entered at the end of the header(X-Sample-CustomHeader1 : VALUE), it will be skipped.
2. A header with more than one value should be separated by delimiters (don’t use comma or colon). 
3. To add a second header, enter the custom header and value pair in the next line.

 

e:  Select the encoding format (eg.JSON) and choose the Simple or Advanced content (Deal details) that need to be sent as a part of the webhook request.


Note: The other encoding formats available are XML and  X-FORM-URLENCODED.

     

f:  Click Test our URL with current settings

The response_ received section would imply the status of the request, such as failure or success.


g:  Save the settings.


7. Click Save & Start the workflow immediately or click Save to save and activate the webhook later. 

How do I test if my Webhooks request is working?

You can test a sample case using the Test URL option. The callback status code comes up as a toaster message. 

If the callback status codes are between 200 and 299, the callback is a success

Status codes other than 2xx indicate failure of the callback. 


Note:
1. You will receive an email mentioning the Callback URL that failed.
2. Your application will retry sending the request for an hour from then.
3. On continued failure, the web application will retry sending the request for the next 2 days before permanently terminating the Webhook request.