Quick StartCreate New ChatbotTrain Chatbot with TextTrain Chatbot with FilesTrain Chatbot with Q&AEnable GPT-4o vision and let user chat with pictureConfigure Chatbot to send lead report to e-mail address
APIGet StartedUsing File for training ChatbotTraining Chatbot using APIGet Lead Report using APIAPI Reference
IntegrationsWordpressGhost BlogWhatsApp IntegrationFacebook Messenger IntegrationMicrosoft Team IntegrationInstagram Integration
Use API to get Lead Report
This tutorial will show you how to get lead report via API.
If your user is chatting with your chatbot via API (custom App), the system will try to qualify the lead about 10 minutes after the last message was sent. For more info on how lead is generated by Chatbot click here
Prerequisite
- You need to have an account with MyBot and created a chatbot. If you have not done this step yet, visit this get-started turorial page to start.
- Generated API key. check API Get Started
Concept
We using API endpoint https://mybot.chat/api/Conversation/{chatbotId}
with query string lead=true to filter the chat session for lead only. Check API reference for all available parameters.
Using Curl
curl --location --request GET 'https://mybot.chat/api/Conversation/--your-chatbotId--?lead=true' \
--header 'Authorization: Bearer --your-api-key--'
Using Javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer --your-api-key--");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://mybot.chat/api/Conversation/--your-chatbotId--?lead=true", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Sample Response from MyBotChat Server
[
{
"id": "82d5435a-d85d-490e-99a0-09b8fa088bcf",
"botId": "772af073-234f-465a-b44c-5a72fddce458",
"title": "2024-05-20T02:10:31.666Z",
"createdOn": "2024-05-20T09:10:31.790689+07:00",
"lastQuestion": "give me a short list of benefit to use your product",
"lastMessage": "Using ShipFast-ASP.NET can bring you the following benefits:\n\n1. Save time: Avoid repeating the same startup process and reduce the time to ship your product to customers.\n2. Reduce stress: By using o...",
"totalMessage": 2,
"saleLeadContact": "bob@example.com",
"saleLeadDetails": "[{\"label\":\"Benefits of ShipFast-ASP.NET\",\"details\":\"Save time, reduce stress, ship faster, get results fast\"}]"
},
{
"id": "93e906e1-4df4-464e-a92d-15ef5cc09165",
"botId": "772af073-234f-465a-b44c-5a72fddce458",
"title": "2024-05-19T09:24:11.464Z",
"createdOn": "2024-05-19T16:24:11.656085+07:00",
"lastQuestion": "ok, my phone is 206 555 5555",
"lastMessage": "Thank you for sharing your phone number, 206 555 5555! I'll make sure to have our team follow up with you to discuss how ShipFast ASP.NET can help your business. We'll be in touch soon!\n\nIn the meanti...",
"totalMessage": 6,
"saleLeadContact": "206 555 5555",
"saleLeadDetails": "[{\"label\":\"Product Interest\",\"details\":\"User asked about the product and its features\"},{\"label\":\"Benefits\",\"details\":\"User asked for a short list of benefits to use the product\"},{\"label\":\"Contact Info\",\"details\":\"User provided phone number for follow-up\"}]"
}
]
Getting Conversation Detail
Using this endpoint https://mybot.chat/api/ChatMessage/{chatbotId}/{sessionId}
to get all message in that chat session
From the previous result, you should see the id
returned, that is sessionId
that can be used to get detail conversation.
Use Javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer --your-api-key--");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://mybot.chat/api/ChatMessage/--your-chatbotId--/--sessionId-from-previous-result--?size=30&start=0", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));