Create Chatbot
Request
To talk to a chatbot you need to make a POST
request to https://www.chatbase.co/api/v1/create-chatbot
with the Headers: Authorization: Bearer <Your-Secret-Key>
and payload that looks like:
const payload = { chatbotName: 'Example name', sourceText: 'Example text data up to the character limit on your plan...' };
or
const payload = { chatbotName: 'Example name', urlsToScrape: ['https://www.example.com/', 'https://www.example.com/blog/1'] };
If you provide a urlsToScrape
, Chatbase will scrape the pages you provide for its text content.
Example Requests
cURL
curl https://www.chatbase.co/api/v1/create-chatbot \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <Your-API-Key>' \ -d '{"urlsToScrape": ["https://www.chatbase.co/docs/chat", "https://www.chatbase.co/docs/create-chatbot"], "chatbotName": "Chatbase"}'
Javascript
const res = await fetch('/api/create-chatbot', { method: 'POST', headers: { Authorization: `Bearer <Your-Secret-Key>`, 'Content-Type': 'application/json' }, body: JSON.stringify({ chatbotName: 'example chatbot', sourceText: 'Source text......' }) }); const data = await res.json(); console.log(data); // {chatbotId: 'exampleId-123'}
Response
{"chatbotId": "exampleId-123"}