Why Webhooks?


Through Webhooks, you can send HTTP requests to a third-party application every time when an event or action occurs on your application.


Simply put, when an event happens in your webpage, you can notify a third party application automatically without continuously polling for data. 


Let’s say you have an e-commerce website and you have a billing application integrated with your application. So every time when a purchase happens, you can notify the billing system automatically using their webhook URL.


Freshmarketer Webhooks:


Using Freshmarketer Webhooks, you can automatically push data to your application through which you can have a simple one to one connection that runs automatically.


Whenever an event occurs in Freshmarketer, a POST event will be sent in a JSON format to the Webhook URL you’ve configured.


The URL will be called automatically every time when a specified action/event happens for the contacts in Freshmarketer. For example, whenever a new contact is added, you can configure Freshmarketer to push data to your application’s webhook URL automatically.


Configure Webhooks in Freshmarketer:


Drag and drop the Webhooks block that’s under the Actions.




Click on ‘Choose or Create a Webhook’. The below popup will be shown providing the option to choose from the list of available webhooks or create a new one.


Click ‘Create New Webhook’.



A popup window will be loaded where you can configure your Webhook URL’s details. 



Webhook name: Provide a name for the Webhook


URL: Input your webhook URL. If there are any required parameters on your URL, you can add them as a placeholder using the below option.



Required Authentication:


If your third-party application URL is protected and requires authentication, you can authenticate using two ways. Through Basic, you can pass a Username and Password and through Token, a token or API key can be passed to authenticate and help access the URL.



Add Custom Header: 


If your Webhook URL requires any additional information with the content such as security information, etc. those can be added as custom headers by enabling this option.


 


Add custom payload:


Apart from default event trigger information, you can add your own custom contact/event properties in your payload as well. Those events will be sent as JSON data on the HTTP request body.



Sample Payload:


"Headers": {

    "Content-Type": "application/json;charset=UTF-8"

  },

  "Body": {

    "event_type": "List",

    "data": {

      "contact": {

        "first name": "test_contact_fname",

        "mobile": "1234567890",

        "email": "testuser@freshmarketer.com"

      },

      "event_details": {

        "list_id": "100",

        "contact_id": "200"

      },

      "custom_data": {

        "name": "test_contact_fname",

        "salary": "123",

        "age": "12"

      }

    },

    "id": "7c076336-6072-4be3-a86f-b7255dbd0d63",

    "event": "list.add_contact",

    "event_category": "system",

    "event_time": 1563186327795

  }

}


Test your Webhooks:


You can test your Webhook URL with sample data. The response status received should be 200 and any other response other than that is considered as a failure. This helps you identify if your Webhook URL is valid or not.





Click on 'Create Webhook' once the configuration is completed.


Sample Journey using Webhooks:


Here the Webhook URL will be called whenever the contacts from the list ‘Test’ clicks on the email campaign ‘Sample’ that has been sent.