loading..
< View all articles in API & Webhooks.

How can I use webhooks in LeadSquared?

Webhooks are HTTP callback requests sent to a URL of your choice in response to some Event occurring. They offer simple and effective server to server communication without long running connections. When an Event occurs in the source site, Webhooks makes an HTTP request to the URL configured. LeadSquared allows you to use Webhooks so that you can integrate your web applications with LeadSquared. Some of the common use cases where you might find Webhooks useful include Posting Form data to another application or Posting Lead data to another application and so on.

Prerequisites

  • You are admin user of LeadSquared
  • You have logged in to LeadSquared.
  • You have the Webhook URL that you want to interact with.

Procedure

1. Navigate to  My Account > Settings>API and Webhooks > click in Webhooks

Webhook

2.  Click on Add Webhook button to add a new Webhook.

Webhook

3. Select the Event which should trigger the HTTP callback request.

  •  Lead Creation: This allows you to publish events to another application when a new lead is created.
  • Lead Update: This allows you to publish events to another application when existing lead details are updated.
  • Landing Page Submission: This allows you to publish events to another application when a visitor submits on your landing page. If you select this option, you can choose whether the trigger should happen to all the landing pages or only to certain specific landing pages. If you un-check the check box, shown, you can enter the landing page URLs.

Multiple Landing pages

  • Lead Activity Creation: This allows you to invoke your services when a Lead performs an activity such as website visit, email link click or a user posts a custom activity on the lead record. An example use case of for Lead Activity webhook is capture here.

Activity Selection

  • Lead Stage Change:  This allows you to invoke webhook when the lead stage changes. You can select any stage or specific stage transition.

Stage Change

  • Lead Ownership Change:
    This allows you to invoke webhook when Lead onwership changes.

4. Enter the application URL that you want to interact with. Events will be published to this URL. You may use a HTTP or a HTTPS URL. In most cases HTTP is sufficient, but HTTPS can be useful if your data is sensitive.

You must verify the URL before proceeding.Click on the Verify button. You will see a success message if it is verified. Otherwise, it will show that there is an error. Also add a relevant description.

URL Verified

5. On adding the connector, you can see the status of connectors as Enabled.

webhook 1

6. You are all set to receive information from LeadSquared. Information is sent as a HTTP POST request to the URL which you specify.

7. You can view the webhook execution history. Hover on the Actions button and click on View History. You can see the transmission date, its status and data transmitted.

Histroy

You will see the status as Success if the URL entered returns HTTP code 200. You will see the status as Failure if the URL entered returns a HTTP code other than 200. We try 3 times before marking an attempt as Failure. In addition to this, you will see the status as In Queue if the data is not yet posted to the URL.

You can debug a Failure status by doing a manual HTTP post with the input data to the webhook URL.

8. Click on Show to view the data that is transmitted. Webhook Data window opens up. Here, you can view the data sent and received.

Webhook data

The POST request message contains a JSON document.

Webhook Data Format

1. Landing Page Submission: Content type is application/json. All fields in the landing page are submitted as JSON Key value pairs. Fields with no value are sent as empty strings.

{
 "FirstName": "JOHN",
"LastName": "SMITH",
"EmailAddress": "john.smith@acmeconsulting.com",
"Company": "ACME CONSULTING",
"Phone": "+91-9999988888",
"Address": ""
}

2. Lead Creation: Content type is application/json. All mandatory fields, along with fields that have non empty values are sent as Json Key value pair format. Non Mandatory fields having no values are not sent. Mandatory Fields with no values are sent as empty/null.

{
"ProspectID": "05bbf7c9-d5a0-4553-ad70-202a4e9f26a3",
"FirstName": STEVE,
"LastName": JOHNSON,
"EmailAddress": "steve.johnson@servotech.com",
"DoNotCall": "0",
"DoNotEmail": "0",
"ProspectStage": "Prospect",
"Score": "0",
"StatusCode": "0",
"StatusReason": "0",
"OwnerId": "1378058e-d810-11e2-a437-22000aaa4492",
"CreatedBy": "1378058e-d810-11e2-a437-22000aaa4492",
"CreatedOn": "9/20/2013 12:23:27 PM",
"ModifiedBy": "1378058e-d810-11e2-a437-22000aaa4492",
"ModifiedOn": "9/20/2013 12:23:27 PM",
"JobTitleLevel": "C-Level",
"DoNotEmailDomain": "0",
"NotableEvent": "Created",
"NotableEventdate": "9/20/2013 12:23:27 PM",
"SourceReferrer": "",
"LastVisitDate": 19/09/2013,
"OwnerIdName": "Tenant User",
"CreatedByName": "Tenant User",
"ModifiedByName": "Tenant User"
}

3. Lead Update:  Content type is application/json. ProspectID, FirstName, LastName, Emailaddress fields are always sent. Along with the above 4 fields, fields that are modified are sent in json format as shown below.

{
"Before": {
"ProspectID": "c2f4f322-7d25-4c64-8129-a0a1fb6d4f44",
"FirstName": "CHARLES",
"LastName": "SCHMIDT",
"EmailAddress": "charles@skyway.com",
"DoNotEmail": "1",
"ModifiedBy": "1378058e-d810-11e2-a437-22000aaa4492",
"ModifiedOn": "9/20/2013 1:03:18 PM",
"NotableEventdate": "9/20/2013 1:03:18 PM",
"ModifiedByName": "Kiranmayi"
},
"After": {
"ProspectID": "c2f4f322-7d25-4c64-8129-a0a1fb6d4f44",
"FirstName": "CHARLES",
"LastName": "SCHMIDT",
"EmailAddress": "devi1@mailinator.com",
"DoNotEmail": "0",
"ModifiedBy": "b927b254-d81a-11e2-a437-22000aaa4492",
"ModifiedOn": "9/20/2013 1:15:20 PM",
"NotableEventdate": "9/20/2013 1:15:20 PM",
"ModifiedByName": "Shainki Bansal"
}

4. Lead Activity Creation – We support both system and custom events to be configured. Here is a detailed document which describes the data we post for respective events.

Activity Webhook Information