This guide assists you with gathering leads.
The Get Leads API endpoint allows you to retrieve leads generated from a agent's conversations. By using this endpoint, you can obtain names, phone numbers, and emails from users who interact with your agents.
GET:https://www.chatzuri.com/api/v1/get-leadsThe API request must include the following headers.
The request should include the following query parameters:
// streamer.js
const axios = require('axios');
const { Readable } = require('stream');
const apiKey = '<Your-Secret-Key>';
const chatId = '<Your Agent ID>';
const apiUrl = 'https://www.chatzuri.com/api/v1/chat';
const messages = [
{ content: '<Your query here>', role: 'user' }
];
const authorizationHeader = `Bearer ${apiKey}`;
async function readChatbotReply() {
try {
const response = await axios.post(apiUrl, {
messages,
chatId,
stream: true,
temperature: 0
}, {
headers: {
Authorization: authorizationHeader,
'Content-Type': 'application/json'
},
responseType: 'stream'
});
const readable = new Readable({
read() {}
});
response.data.on('data', (chunk) => {
readable.push(chunk);
});
response.data.on('end', () => {
readable.push(null);
});
const decoder = new TextDecoder();
let done = false;
readable.on('data', (chunk) => {
const chunkValue = decoder.decode(chunk);
process.stdout.write(chunkValue);
});
readable.on('end', () => {
done = true;
});
} catch (error) {
console.log('Error:', error.message);
}
}
readChatbotReply();The API response will be a JSON object with the following structure:
{
"data": [
{
"id": 0,
"created_at": "string",
"chatbot_owner_user_id": "string",
"chatbot_id": "string",
"phone": "string",
"email": "string",
"name": "string"
}
]
}Response codes:
Returns an array of leads that match the provided filters
If the start/end dates provided are invalid
If the API request is unauthorized
If the agentId provided is invalid
If there is an internal server error
By making use of the Get Leads API endpoint, you can retrieve and analyze potential leads generated through the agent interactions.