Cleverbot API

Cleverbot API

Machine Learning

Chat with a bot about anything and everything - AI learns from people, in context, and imitates. The Cleverbot API is RESTful. You call a URL on our server and we return JSON.

Visit API

📚 Documentation & Examples

Everything you need to integrate with Cleverbot API

🚀 Quick Start Examples

Cleverbot API Javascript Examplejavascript
// Cleverbot API API Example
const response = await fetch('https://www.cleverbot.com/api/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Introduction to the Cleverbot API

The Cleverbot API is a public API that allows developers to integrate a conversational AI system into their projects. This API is capable of responding to messages in a natural language format and can hold stimulating conversations with users.

The API is based on a machine learning algorithm that learns from previous conversations with users. The more it interacts with users, the smarter it becomes, leading to even more engaging conversations.

In this article, we will demonstrate how to use the Cleverbot API, along with example code in JavaScript for some of the most commonly used API functions.

Getting Started

To use the Cleverbot API, you need to obtain an API key from their website. Once you have registered and received your API key, you are ready to start using the API.

Example API Calls

Sending a message to Cleverbot

To send a message to Cleverbot, you simply need to make a HTTP POST request with the text message as an input.

const axios = require('axios');

const API_URL = 'https://www.cleverbot.com/getreply';
const API_KEY = 'your_api_key_here';
const MESSAGE = 'Hello, how are you?';

axios.post(API_URL, {
    key: API_KEY,
    input: MESSAGE,
    cs: '',
    interaction_count: '1',
  })
  .then(function (response) {
    console.log(response.data.output);
  })
  .catch(function (error) {
    console.log(error);
  });

Setting User Parameters

You can also set various user parameters such as gender, favorite food, location, etc. to personalize the conversation with Cleverbot.

axios.post(API_URL, {
    key: API_KEY,
    input: MESSAGE,
    cs: '',
    interaction_count: '1',
    gender: 'female',
    favoritefood: 'pizza',
    location: 'New York',
  })
  .then(function (response) {
    console.log(response.data.output);
  })
  .catch(function (error) {
    console.log(error);
  });

Resetting Conversation State

Sometimes, you may want to reset the conversation state and start a fresh conversation with Cleverbot. You can do this by setting the cs parameter to an empty string.

axios.post(API_URL, {
    key: API_KEY,
    input: MESSAGE,
    cs: '',
    interaction_count: '1',
  })
  .then(function (response) {
    console.log(response.data.output);
  })
  .catch(function (error) {
    console.log(error);
  });

Checking API Status

You can also check the status of the Cleverbot API by making a GET request to their status API.

const STATUS_API_URL = 'https://www.cleverbot.com/getstatus';

axios.get(STATUS_API_URL)
  .then(function (response) {
    console.log(response.data.status);
    console.log(response.data.status_payload);
    console.log(response.data.status_owner);
  })
  .catch(function (error) {
    console.log(error);
  });

Conclusion

The Cleverbot API allows developers to easily integrate conversational AI into their projects, making them more engaging and interactive. With the help of the example JavaScript code provided in this article, you can easily start using this API and experiment with its various features.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jul 2Jul 4Jul 6Jul 8Jul 10Jul 12Jul 14Jul 16Jul 18Jul 20Jul 22Jul 24Jul 26Jul 28Jul 3104008001440Minutes
Online
Offline

Related APIs in Machine Learning