Get Leads

This guide assists you with gathering leads

Getting Leads from a Chatbot

The Get Leads API endpoint allows you to retrieve leads generated from a chatbot's conversations. By using this endpoint, you can obtain names, phone numbers, and emails from users who interact with your chatbots.

Endpoint

GET https://www.chatbase.co/api/v1/get-leads

Request Headers

The API request must include the following header:

  • Authorization: Bearer <Your-Secret-Key> - The secret key for authenticating the API request.

Request Body Parameters

  • chatbotId (string, required): The ID of the chatbot for which you want to retrieve leads.

  • startDate (string): Represents the start date of the date range for fetching conversations. The date should be in "Year-Month-Day" format (e.g., 2023-07-10, not 2023-7-10).

  • endDate (string): Represents the end date of the date range for fetching conversations. The date should be in "Year-Month-Day" format (e.g., 2023-07-13, not 2023-7-13).

  • page (string): Specifies the page number of the results for pagination.

  • size (string): Indicates the number of results per page, which is also used for pagination.

Example Requests

curl --request GET \
     --url 'https://www.chatbase.co/api/v1/get-leads?chatbotId=%5BYour%20Chatbot%20ID%5D&startDate=2023-01-01&endDate=2023-12-12&page=1&size=10' \
     --header 'accept: application/json'
const options = {method: 'GET', headers: {accept: 'application/json'}};

fetch('https://www.chatbase.co/api/v1/get-leads?chatbotId=%5BYour%20Chatbot%20ID%5D&startDate=2023-01-01&endDate=2023-12-12&page=1&size=10', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
import requests

url = "https://www.chatbase.co/api/v1/get-leads?chatbotId=%5BYour%20Chatbot%20ID%5D&startDate=2023-01-01&endDate=2023-12-12&page=1&size=10"

headers = {"accept": "application/json"}

response = requests.get(url, headers=headers)

print(response.text)
GET /api/v1/get-leads?chatbotId=%5BYour%20Chatbot%20ID%5D&startDate=2023-01-01&endDate=2023-12-12&page=1&size=10 HTTP/1.1
Accept: application/json
Host: www.chatbase.co


Responses

  • 200: Returns an array collectedCustomers[] containing conversations that match the provided filters. These conversations represent leads generated by the chatbot.
  • 400: If the start/end dates provided are invalid.
  • 401: If the API request is unauthorized.
  • 404: If the provided chatbot ID is invalid and does not correspond to any existing chatbot.
  • 500: If there is an internal server error while processing the request.

Example Response

{  
  "data": [  
    {  
      "id": 0,  
      "created_at": "string",  
      "chatbot_owner_user_id": "string",  
      "chatbot_id": "string",  
      "phone": "string",  
      "email": "string",  
      "name": "string"  
    }  
  ]  
}

By making use of the Get Leads API endpoint, you can retrieve and analyze potential leads generated through the chatbot interactions.