API Integration Documentation

This documentation provides comprehensive information about the available API endpoints for integrating with the CRM AI Simulation system. All endpoints support cross-origin requests and are designed for seamless integration with external applications.

Base URL: https://chat.nusatec.id

Content-Type: application/json

Authentication: No authentication required for public endpoints

Chat & Messaging API

POST
https://chat.nusatec.id/chatbot/api/send-message/

Send Message to AI Assistant

Send a message to the AI assistant and receive a response based on the knowledge base.

Request Parameters

Parameter Type Required Description
message string Yes The user's message to send to the AI assistant
conversation_id integer No ID of existing conversation for context continuity
language string No Language preference: "id" (Indonesian) or "en" (English). Default: "id"

Example Request

curl -X POST https://chat.nusatec.id/chatbot/api/send-message/ \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Apa itu layanan CRM AI?",
    "language": "id"
  }'

Success Response

200 OK
{
  "success": true,
  "response": "CRM AI adalah sistem manajemen hubungan pelanggan...",
  "conversation_id": 123,
  "context_sources": ["Knowledge Base Document 1"],
  "guest_mode": true
}

Error Response

400 Bad Request
{
  "error": "Message cannot be empty"
}

Knowledge Base API

POST
https://chat.nusatec.id/chatbot/knowledge-base/add-qa/

Add Q&A Entry

Add a new question and answer entry to the knowledge base.

Form Parameters

Parameter Type Required Description
question string Yes The question to add to the knowledge base
answer string Yes The corresponding answer for the question
csrfmiddlewaretoken string Yes CSRF token (obtain from form page)

Example Request

curl -X POST https://chat.nusatec.id/chatbot/knowledge-base/add-qa/ \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Referer: https://chat.nusatec.id/chatbot/knowledge-base/add-qa/" \
  -d "csrfmiddlewaretoken=TOKEN&question=What%20is%20CRM&answer=Customer%20Relationship%20Management"

Helpdesk Management API

POST
https://chat.nusatec.id/chatbot/api/update-ticket-status/

Update Ticket Status

Update the status of a helpdesk ticket in the kanban board.

Request Parameters

Parameter Type Required Description
ticket_id string Yes The unique ticket ID (e.g., "TK-12345678")
status string Yes New status: "new", "in_progress", "waiting_customer", "resolved", "closed"

Example Request

curl -X POST https://chat.nusatec.id/chatbot/api/update-ticket-status/ \
  -H "Content-Type: application/json" \
  -d '{
    "ticket_id": "TK-12345678",
    "status": "in_progress"
  }'

Success Response

200 OK
{
  "success": true,
  "message": "Ticket TK-12345678 status updated to in_progress"
}

Rate Limits & Best Practices

Rate Limiting

Currently, there are no strict rate limits imposed, but we recommend:

  • Maximum 60 requests per minute per IP address
  • Implement proper error handling and retry logic
  • Use conversation IDs to maintain context efficiently

Error Handling

Always check the HTTP status code and handle errors appropriately:

  • 200: Success
  • 400: Bad Request - Check your parameters
  • 401: Unauthorized - Authentication required
  • 404: Not Found - Resource doesn't exist
  • 500: Server Error - Try again later

Best Practices

  • Always include proper headers (Content-Type, Referer for CSRF)
  • Validate input data before sending requests
  • Implement timeout handling for network requests
  • Store conversation IDs to maintain chat context
  • Use appropriate HTTP methods (POST for data modification)