@sefinek/cleverbot-free
v2.1.5
Published
Simple and unofficial NPM module for interacting with the same API used by the Cleverbot website. Available for free!
Downloads
7
Maintainers
Readme
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.
⚠️ 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 cleverbot-free
yarn add cleverbot-free
🔧 » 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 forthe API call if it fails initially. | |retryBaseCooldown
|3000
(3 seconds) | Determines the base cooldown period in millisecondsbefore retrying an API call after a failure. | |cookieExpirationTime
|15768000
(4.38 hours) | Sets the time in milliseconds after which the cookieshould be refreshed. |
CleverBot.getData()
Retrieves the current session data and other relevant information.
- Returns: See types.
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 cleverbot-free
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('@sefinek/cleverbot-free');
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 cleverbot-free!
🔖 Credits
It is inspired by the IntriguingTiles/cleverbot-free project.
📝 MIT License
Copyright 2023-2024 © by Sefinek. All Rights Reserved.