Webhooks Guide

Last updated 17/10/2024

You can configure your OpenFi account to send webhook events to a specific endpoint when a lead is either created or updated.

To enable webhooks, follow these steps:

  • Create an endpoint that can receive the data from OpenFi.

  • Provide the OpenFi team with the endpoint URL so they can set up the events to be sent to that endpoint

Once the webhook is enabled, OpenFi will send a POST request to your endpoint.

Event Types

Once the webhook is enabled, OpenFi will send a POST request to your endpoint with event data in JSON format. The payload will include the following key fields:

  • type: This field indicates the event type, which can be "lead.created" or "lead.updated".

  • lead: This field contains detailed information about the lead. 

The lead data includes:

  • id: The unique identifier for the event

  • lead.id: A unique identified for the lead, that is consistent along all events fired for that specific lead

  • source: The origin of the lead (e.g., WhatsApp).

  • status: The status of the lead (e.g., “In Progress”, "Successful").

  • contact: Information about the lead's contact info, including the contact's firstName, lastName, and email. In case you have some custom fields set up on the contact level, those will be passed within the request as well.

  • communicationChannels: The communication channels used by the lead (e.g., WhatsApp).

  • messages: An array of messages exchanged between the lead and the system, each containing id, type (e.g., Incoming or Outgoing), content, and timestamps.

  • attributes: Additional lead attributes such as the deposit amount, mortgage type, mortgage amount, call availability, mortgage timeline, and any borrowing blockers. In case you have some custom lead attributes set up on the contact level, those will be passed within the request as well.

Webhook example payloads

lead.created event

This is the example of an event that gets triggered upon lead creation. The "type":"lead.created" part determines this is a new lead.

{
   "id":"654e1fd2-XYZ-XYZ-XXYZ-aa6da8b65803",
   "lead":{
      "id":"71d2da30-XYZ-XYZ-XXYZ-28fd992d7f5c",
      "source":"test",
      "status":"In Progress",
      "contact":{
         "id":"afa4d776-XYZ-XYZ-XXYZ-7dc6687f31ec",
         "attributes":{
            
         },
         "communicationChannels":[
            {
               "id":"48c13b57-XYZ-XYZ-XXYZ606d5f29ad7e",
               "type":"test",
               "externalId":"0d5a8671-XYZ-XYZ-XXYZ-10556a2b2b28"
            }
         ]
      },
      "messages":[
         {
            "id":"e11eb803-XYZ-XYZ-XXYZ-5ac0e48a3e71",
            "type":"Outgoing",
            "content":"Thanks for checking out OpenFi, feel free to ask me any questions.\n\nYou’re ahead of the competition looking at how our AI can superpower your business. It would be great to understand your industry, so I can help you best.",
            "updatedAt":"2024-10-17T07:05:55.671Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         }
      ],
      "createdAt":"2024-10-17T07:05:55.671Z",
      "updatedAt":"2024-10-17T07:05:55.671Z",
      "attributes":{
         
      }
   },
   "type":"lead.created"
}

lead.updated event

This is the example of an event that gets triggered on lead update, and it has the "type":"lead.updated" identifier. A separate lead.updated event is sent every time there is an update on the contact or lead attributes. Please find an example of the webhook event body below.

{
   "id":"8ad907f5-XYZ-XYZ-XXYZ-414ff41000a3",
   "lead":{
      "id":"71d2da30-XYZ-XYZ-XXYZ-28fd992d7f5c",
      "source":"test",
      "status":"In Progress",
      "contact":{
         "id":"afa4d776-XYZ-XYZ-XXYZ-7dc6687f31ec",
         "attributes":{
            "email":null,
            "lastName":null,
            "firstName":null
         },
         "communicationChannels":[
            {
               "id":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e",
               "type":"test",
               "externalId":"0d5a8671-XYZ-XYZ-XXYZ-10556a2b2b28"
            }
         ]
      },
      "messages":[
         {
            "id":"c6f8c841-XYZ-XYZ-XXYZ-94477b0c967e",
            "type":"Incoming",
            "content":"increase travel bookings",
            "updatedAt":"2024-10-17T07:09:47.195Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"4175f530-XYZ-XYZ-XXYZ-e265edde35ab",
            "type":"Outgoing",
            "content":"There might be an opportunity to streamline your sales process and help you earn more by increasing travel bookings. Would tomorrow between 2pm and 4pm or Wednesday between 10am and 12pm be a good time to speak with one of our team members?",
            "updatedAt":"2024-10-17T07:09:47.195Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"e11eb803-XYZ-XYZ-XXYZ-5ac0e48a3e71",
            "type":"Outgoing",
            "content":"Thanks for checking out OpenFi, feel free to ask me any questions.\n\nYou’re ahead of the competition looking at how our AI can superpower your business. It would be great to understand your industry, so I can help you best.",
            "updatedAt":"2024-10-17T07:05:55.770Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"ed94b7e7-XYZ-XYZ-XXYZ-f8768083ae00",
            "type":"Incoming",
            "content":"I am a travel agent",
            "updatedAt":"2024-10-17T07:09:28.409Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"6bc5f76f-XYZ-XYZ-XXYZ-7e595fd86acc",
            "type":"Outgoing",
            "content":"As a travel agent, what are some of your commercial goals? Are you looking to increase bookings, reduce the time spent on follow-ups, or perhaps minimise time spent on unqualified leads?",
            "updatedAt":"2024-10-17T07:09:37.727Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         }
      ],
      "createdAt":"2024-10-17T07:05:55.671Z",
      "updatedAt":"2024-10-17T07:09:47.195Z",
      "attributes":{
         "industry":"Travel",
         "commercialGoals":"increase travel bookings",
         "callAvailability":null
      }
   },
   "type":"lead.updated"
}

lead.updated event for successful/qualified leads

With each attribute update, a new lead.updated event will get fired. However, once all of the required attributes have been collected, the lead.updated event will have the lead.status as "Successful" instead of "In Progress" as it is the case with all the preceding leads.

{
   "id":"8f366966-XYZ-XYZ-XXYZ-0100e79268f8",
   "lead":{
      "id":"71d2da30-XYZ-XYZ-XXYZ-28fd992d7f5c",
      "source":"test",
      "status":"Successful",
      "contact":{
         "id":"afa4d776-XYZ-XYZ-XXYZ-7dc6687f31ec",
         "attributes":{
            "email":null,
            "lastName":null,
            "firstName":null
         },
         "communicationChannels":[
            {
               "id":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e",
               "type":"test",
               "externalId":"0d5a8671-XYZ-XYZ-XXYZ-10556a2b2b28"
            }
         ]
      },
      "messages":[
         {
            "id":"c6f8c841-XYZ-XYZ-XXYZ-94477b0c967e",
            "type":"Incoming",
            "content":"increase travel bookings",
            "updatedAt":"2024-10-17T07:09:47.195Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"4175f530-XYZ-XYZ-XXYZ-e265edde35ab",
            "type":"Outgoing",
            "content":"There might be an opportunity to streamline your sales process and help you earn more by increasing travel bookings. Would tomorrow between 2pm and 4pm or Wednesday between 10am and 12pm be a good time to speak with one of our team members?",
            "updatedAt":"2024-10-17T07:09:56.152Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"9cf1414b-XYZ-XYZ-XXYZ-5ccc0511e0b0",
            "type":"Incoming",
            "content":"Wednesday 10am",
            "updatedAt":"2024-10-17T07:13:14.859Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"73960680-XYZ-XYZ-XXYZ-89c630e23b7c",
            "type":"Outgoing",
            "content":"Ok that's it!\n\nI've scheduled a call for you on Wednesday at 10am. Is there anything else you would like to know or discuss in the meantime?",
            "updatedAt":"2024-10-17T07:13:14.859Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"e11eb803-XYZ-XYZ-XXYZ-5ac0e48a3e71",
            "type":"Outgoing",
            "content":"Thanks for checking out OpenFi, feel free to ask me any questions.\n\nYou’re ahead of the competition looking at how our AI can superpower your business. It would be great to understand your industry, so I can help you best.",
            "updatedAt":"2024-10-17T07:05:55.770Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"ed94b7e7-XYZ-XYZ-XXYZ-f8768083ae00",
            "type":"Incoming",
            "content":"I am a travel agent",
            "updatedAt":"2024-10-17T07:09:28.409Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         },
         {
            "id":"6bc5f76f-XYZ-XYZ-XXYZ-7e595fd86acc",
            "type":"Outgoing",
            "content":"As a travel agent, what are some of your commercial goals? Are you looking to increase bookings, reduce the time spent on follow-ups, or perhaps minimise time spent on unqualified leads?",
            "updatedAt":"2024-10-17T07:09:37.727Z",
            "communicationChannelId":"48c13b57-XYZ-XYZ-XXYZ-606d5f29ad7e"
         }
      ],
      "createdAt":"2024-10-17T07:05:55.671Z",
      "updatedAt":"2024-10-17T07:13:14.859Z",
      "attributes":{
         "industry":"Travel",
         "commercialGoals":"increase travel bookings",
         "callAvailability":"Wednesday 10am"
      }
   },
   "type":"lead.updated"
}