The DLC Chatbot API provides a simple interface for interacting with our document-based chatbot system. You can use this API to integrate the chatbot into your own applications, websites, or services.
All API endpoints are prefixed with /api and return JSON responses.
Currently, the API does not require authentication. However, we recommend implementing appropriate authentication in production environments.
The following endpoints are available:
Check if the API is running.
{
"message": "DLC Chatbot API is online",
"status": "active"
}
Send a question to the chatbot. If no session_id is provided, a new session will be created.
{
"question": "What services does DLC offer?",
"session_id": "optional-session-id"
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| question | string | Yes | The user's question for the chatbot |
| session_id | string | No | Session ID to continue an existing conversation |
{
"answer": "DLC offers consultancy services in artificial intelligence and machine learning...",
"session_id": "550e8400-e29b-41d4-a716-446655440000"
}
Create a new chat session.
{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"created_at": "2023-10-15T14:30:22.123456"
}
Get a list of all chat sessions.
{
"sessions": [
{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"created_at": "2023-10-15T14:30:22.123456"
},
{
"session_id": "550e8400-e29b-41d4-a716-446655440001",
"created_at": "2023-10-15T15:45:10.987654"
}
]
}
Get the chat history for a specific session.
| Parameter | Type | Description |
|---|---|---|
| session_id | string | The ID of the session to retrieve history for |
{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"history": [
{
"timestamp": "2023-10-15T14:30:30.123456",
"question": "What services does DLC offer?",
"answer": "DLC offers consultancy services in artificial intelligence and machine learning..."
},
{
"timestamp": "2023-10-15T14:31:15.987654",
"question": "When was DLC founded?",
"answer": "DLC was founded in 2020 by a team of AI researchers..."
}
]
}
// Send a question to the chatbot
async function askQuestion(question, sessionId = null) {
const response = await fetch('/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
question: question,
session_id: sessionId
})
});
return await response.json();
}
// Example usage
askQuestion('What services does DLC offer?')
.then(data => {
console.log('Answer:', data.answer);
console.log('Session ID:', data.session_id);
})
.catch(error => console.error('Error:', error));
import requests
def ask_question(question, session_id=None):
"""Send a question to the chatbot API"""
payload = {
"question": question
}
if session_id:
payload["session_id"] = session_id
response = requests.post(
"http://localhost:8000/api/chat",
json=payload
)
return response.json()
# Example usage
result = ask_question("What services does DLC offer?")
print("Answer:", result["answer"])
print("Session ID:", result["session_id"])