Advanced Features

Track Chatbot Usage At Real-time

If you wish to restrict your chatbot access to subscribed users and deduct message credits post-chat, follow these steps:


Setup Process

Step 1: Mandate the Leads Form to Track User Information

Require users to complete the leads form upon initiating their first message. This ensures all user interactions with your chatbot are preceded by their details being logged as shown in the screen below (note the settings in the red box). Mandate Leads Form This configuration allows our chatbot to relay real-time data such as email, phone number, and name from the leads when they converse with your bot.

Step 2: Implement a Webhook to Monitor Messages

Set up webhooks as per the Webhook Setup Guide. Following this, you will receive chat events, which help track a specific user's chatbot interactions. Here is an example payload:

{
  "messages": [
    {
      "role": "assistant",
      "content": "👋 Hello there! I'm Chat Data AI, your go-to source for all things about Chat Data!"
    },
    {
      "role": "assistant",
      "content": "By the way, you can create a chatbot like me for your website! 😮"
    },
    {
      "role": "user",
      "content": "How to integrate with Discord?"
    }
  ],
  "answer": {
    "role": "assistant",
    "content": "You can follow the [guide](https://www.chat-data.com/api-reference#section/Chat-Data-Website-Guide/Discord-Bot-Integration) to integrate your chatbot with Discord.",
    "score": 0.8503905227042547
  },
  "client_ip": "xx.xx.xx.xx",
  "chatbot_id": "654aee418bc9a33b0e50d0ad",
  "source": "widget",
  "cost_credits": 20,
  "conversation_id": "dbf24043-83a6-47fb-b241-9865de3877c9",
  "lead": {
    "uuid": "28239132-671d-4b1f-9d43-1c7b70985ede",
    "email": "[email protected]",
    "name": "User"
  }
}
Previous
Save Chat History In Your Own Storage