API for REST framework

The Xparo API provides access to various functionalities of the Xparo platform, including initializing data, managing AIML content, scheduling actions, and more. This documentation describes the endpoints, methods, and data formats used in the API.

Base URL

All API requests are made to the following base URL: http://127.0.0.1:8003/chatbot_api/<secret_key>/<project_key>/

Replace <secret_key> and <project_key> with your specific keys.

API Endpoints Overview

Below is a summary of the available API endpoints:

  • GET /chatbot_api/: Retrieve initialization data

  • POST /chatbot_api/: - Initialize API - Get schedule - Sync configuration files - Save AIML content - Ask the bot - Control the robot’s schedule - Delete the robot’s schedule

Detailed API Endpoints

Retrieve Initialization Data

  • Endpoint: GET /chatbot_api/<secret_key>/<project_key>/

  • Method: GET

  • Description: Retrieves the initial configuration and AIML data.

Response Example:

{
  "status": true,
  "title": "hello",
  "disc": "hi",
  "goal": "Basic",
  "rules": "",
  "api_key": "",
  "aiml": "<category node_id=\"xparo_m0l3k1peb13suxsj7dr\"><pattern>HI</pattern><template></template></category>",
  "maps": "",
  "Sets": "",
  "properties": "",
  "System": ""
}

Initialize API

  • Endpoint: POST /chatbot_api/<secret_key>/<project_key>/

  • Method: POST

  • Request Body:

{
  "initialize_api": {}
}
  • Description: Initializes the API and returns the same initialization data as the GET request.

Response Example:

{
  "status": true,
  "title": "hello",
  "disc": "hi",
  "goal": "Basic",
  "rules": "",
  "api_key": "",
  "aiml": "<category node_id=\"xparo_m0l3k1peb13suxsj7dr\"><pattern>HI</pattern><template></template></category>",
  "maps": "",
  "Sets": "",
  "properties": "",
  "System": ""
}

Get Schedule

  • Request Body:

{
  "xparo_get_schedule": {}
}
  • Description: Retrieves the current schedule of actions.

Response Example:

{
  "schedule_control": {}
}

Sync Configuration Files

  • Request Body:

{
  "xparo_sync_config": {}
}
  • Description: Retrieves all configuration file paths.

Response Example:

{
  "change_config": {
    "xparo_name": "hello"
  }
}

Save AIML Content

  • Request Body:

{
  "save_aiml": "aiml content here"
}
  • Description: Saves the provided AIML content to the server.

Ask the Bot

  • Request Body:

{
  "ask_bot": "your question here"
}
  • Description: Sends a question to the bot and retrieves the response based on the saved AIML data.

Response Example:

{
  "message": {
    "bot_response": "let's check this thing on internet"
  }
}

Control Schedule

  • Request Body:

{
  "xparo_schedule_control": {}
}
  • Description: Modifies the robot’s schedule on the server.

Delete Schedule

  • Request Body:

{
  "xparo_delete_schedule_control": {}
}
  • Description: Deletes the robot’s schedule on the server.

Notes and Best Practices

  • Authentication: All requests must include valid <secret_key> and <project_key> to authenticate the API call.

  • Data Format: Ensure all JSON data is correctly formatted to avoid errors.

  • Error Handling: Check for valid responses and handle any errors as per your application’s requirements.

Conclusion

This documentation provides an overview of how to interact with the Xparo API for managing AIML content, scheduling actions, and retrieving configuration data. Utilize these endpoints effectively to build powerful integrations with the Xparo platform.