free-cleverbot
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

❎ 💸 Free CleverBOT NPM Module 🤖 💻

Simple and unofficial NPM module for interacting with the same API that the Cleverbot website uses.
Available for free! ✔️

Number of downloads Issues Last commit Commit activity Code size

This module allows developers to interact with the Cleverbot API without needing an official API key, providing a convenient and cost-effective way to integrate Cleverbot chatbot features into their projects.

🔒 Security

The module selects a User Agent randomly from an array and uses it to send requests to cleverbot.com. Each restart of the application results in the selection of a different user agent at random.

⚠️ Warning

Using this module could potentially lead to a permanent IP ban on cleverbot.com, although this is unlikely.

This module provides free access to Cleverbot's API, but it is crucial to use it responsibly, keeping in mind that Cleverbot.com may act against IP addresses that misuse their service. Therefore, consider the following guidelines:

  • Use Responsibly: Avoid excessive requests to Cleverbot in a short period. Adhere to their terms of service.
  • Testing and Development: Ideal for testing and development purposes. Not recommended for high-traffic or production applications to prevent IP bans.
  • Use at Your Own Risk: Users assume responsibility for any potential consequences, including IP bans or other actions by Cleverbot.com.
  • Consider Official API Key: For extensive and commercial use, consider obtaining an official API key from Cleverbot for reliable and uninterrupted access.

📥 Installation

Install this module using npm 🟥 or yarn 🐈:

npm install free-cleverbot
yarn add free-cleverbot

🔧 » Documentation

CleverBot.interact(message, context[], language)

A function for interacting with the Cleverbot API. It processes the provided message, context, and language, then returns a response from Cleverbot.

  • message (string, required): The message that the user wants to send to Cleverbot. This is the primary text to which Cleverbot will respond.
  • context[] (array, required): An array containing the history of previous messages in the conversation. Used to maintain the context of the conversation. Each element of the array represents one line of dialogue.
  • language (string, optional, default: en): The language in which the conversation is to be conducted.

CleverBot.config(configurationObject)

Configures the settings of the Cleverbot module. This function allows you to set various options that affect how the module interacts with the Cleverbot API.

  • configurationObject (object, required): An object containing configuration settings.

    Property Default value Description
    debug false Enables or disables debug mode. When enabled,
    the module provides detailed debug information.
    selectedLanguage en Sets the default language for the Cleverbot conversations.
    maxRetryAttempts 3 Specifies the maximum number of retry attempts for
    the API call if it fails initially.
    retryBaseCooldown 3000
    (3 seconds)
    Determines the base cooldown period in milliseconds
    before retrying an API call after a failure.
    cookieExpirationTime 15768000
    (4.38 hours)
    Sets the time in milliseconds after which the cookie
    should be refreshed.

CleverBot.getData()

Retrieves the current session data and other relevant information.

CleverBot.newSession()

Allows for the deletion of the current session and the initiation of a new one. The conversation context should also be removed.

  • Returns: Nothing.

CleverBot.version

A property that represents the current version number of the free-cleverbot module, conforming to the Semantic Versioning (SemVer) standard.

  • Returns: A string that specifies the current version of the module.

💬 Example (see also example.js)

const CleverBot = require('free-cleverbot');

CleverBot.config({
    debug: false,
    defaultLanguage: 'en',
    maxRetryAttempts: 5,
    retryBaseCooldown: 4000,
    cookieExpirationTime: 15768000
});

const message = 'Do you like cats? >w<';
const context = [];

(async () => {
    const response = await CleverBot.interact(message, context); // `Input`, `conversation context`, `language` is not required if you are using `CleverBot.config` with `defaultLanguage`

    /*
     * Add the user's message first to the context followed by Cleverbot's
     * response to maintain the correct conversational order.
     */
    context.push(message); // User's message 
    context.push(response); // Cleverbot's response

    console.log(response);
})();

🤔 What can this module be used for?

  • Your Discord Bot
  • Do you have additional ideas for utilizing this module? Create a Pull Request and contribute them here!

💙 Thanks

If you require any assistance or have questions regarding this module, don't hesitate to open a new GitHub Issue. Your feedback and contributions are highly appreciated. If you find this module valuable and useful for your projects, we kindly invite you to show your support by giving it ⭐ a star on GitHub. Thank you for using free-cleverbot!

🔖 Credits

It is inspired by the IntriguingTiles/cleverbot-free project.

📝 MIT License

Copyright 2023-2024 © by Sefinek. All Rights Reserved.

Package Sidebar

Install

npm i free-cleverbot

Weekly Downloads

4

Version

2.1.2

License

MIT

Unpacked Size

32.3 kB

Total Files

16

Last publish

Collaborators

  • sefinek