
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
This SDK is a client library designed to facilitate the usage of Mindbehind company's message components. It provides an easy-to-use interface for creating modules and sending messages, enabling seamless integration with the Mindbehind platform. With this SDK, our collaborators can leverage the power of Mindbehind's messaging features to enhance their applications and streamline communication with their users.
To use the SDK, ensure that Node.js and npm are installed. Follow the steps below to include the SDK in your project:
npm install mb-sdk
or
yarn add mb-sdk
import { Client, PlatformGeneric } from "mb-sdk";
// Create new ChatBot Client
const client = new Client.ChatBotClient(
{
baseURL: "", // mindbehind base url
},
{
channelId: "", // channel id from management token on channel tabs
managementToken: "", // management token from management token on channel tabs
}
);
// Create new Message module
const message = new PlatformGeneric.TextMessage({ content: "Hello" });
// Send message module with client send function
await client.send(message);
import { PlatformIntegration } from "mb-sdk";
// Create new Message module
const message = new PlatformIntegration.TextMessage({ payloads: ["Hello"] });
// Build response model
const responseData = new PlatformIntegration.IntegrationResponse({
modules: [message],
params: { name: "Henlo" },
}).buildStringfy();
return {
statusCode: 200,
body: responseData,
};
The BaseModule
class is an abstract class that serves as the foundation for creating different modules in a system. It provides common functionality and fields that can be extended and customized by specific module implementations. All other modules are derived from the BaseModule. They share the same fields, but the types of these fields may vary depending on the module. This inheritance ensures a consistent structure across modules while allowing flexibility in defining specific field types.
params
(BaseModuleConstructorParams
): An object containing the configuration parameters for the module.type
(TModuleType
): The type of the module. Every module must have a type, which determines the behavior and available fields of the module.delay
(number
, optional): The delay duration of the module in milliseconds. Defaults to undefined
.payloads
(Array<any>
, optional): An array where the module payloads are located. This field allows the configuration of the output structure. Defaults to undefined
.connections
(Array<TConnectionType>
, optional): An array used to manage and direct node connections. Defaults to undefined
.fallback
(number
, optional): The target node ID to go to when there is an error on the module. Defaults to undefined
.fallbackCount
(number
, optional): The number of accepted wrong answers. The default value is 0
.errorMessage
(string
, optional): The message to be sent when a wrong answer is received. Defaults to undefined
.inputParam
(string
, optional): The parameter name to which the input will be recorded. Defaults to undefined
.valid()
: Performs validation checks on the module's properties. Throws an InvalidPayloadError
if any validation fails.The BaseModule
class enforces the following validation rules on its properties:
payloads
: Must be an array if defined.fallback
: Must be a valid positive number if defined.fallbackCount
: Must be a positive number between 0 and 9 if defined.delay
: Must be a valid positive number between 0 and 84600 (number of seconds in a day) if defined.connections
: Must be an array if defined.inputParam
: Must be a non-empty string if defined.These validation rules ensure that the module's properties are set correctly and conform to the expected data types and constraints.
Below is a list of modules used in Mindbehind along with their descriptions:
The Text Message module allows sending text-based messages to users. It is commonly used to deliver textual information or engage in conversational interactions with users.
import { PlatformIntegration } from "mb-sdk";
const exampleTextMessage = new PlatformIntegration.TextMessage({
payloads: ["test"],
delay: 1000,
});
The Audio Message module enables sending audio files or voice recordings as messages to users. It is useful for sharing audio content or providing voice-based interactions.
import { PlatformIntegration } from "mb-sdk";
const exampleAudioMessage = new PlatformIntegration.AudioMessage({
payloads: ["www.unkowndomain.com/example.mp3"],
delay: 1000,
});
The File Message module allows sending various types of files, such as documents, PDFs, or spreadsheets, to users. It provides a convenient way to share files within the conversation.
import { PlatformIntegration } from "mb-sdk";
const exampleFileMessage = new PlatformIntegration.FileMessage({
payloads: ["www.unkowndomain.com/example.pdf"],
delay: 1000,
});
The Image Message module enables sending image files or visual content to users. It is commonly used to share pictures, graphics, or any other visual media within the conversation.
import { PlatformIntegration } from "mb-sdk";
const exampleImageMessage = new PlatformIntegration.ImageMessage({
payloads: ["www.unkowndomain.com/example.png"],
delay: 1000,
});
The Video Message module allows sending video files or multimedia content to users. It provides a means to share videos or engage in video-based interactions within the conversation.
import { PlatformIntegration } from "mb-sdk";
const exampleVideoMessage = new PlatformIntegration.VideoMessage({
payloads: ["www.unkowndomain.com/example.mp4"],
delay: 1000,
});
Selection modules enable interactive communication by prompting users with choices and waiting for their actions. If you wish to ask multiple-choice questions or provide selectable options, these modules are the perfect choice. With their help, you can effortlessly engage users in decision-making processes and capture their selections, enhancing the overall user experience.
Card Message is a versatile message format that allows you to send visually appealing content to users. It includes images, buttons, text, and titles to prompt user interaction and decision-making
import { PlatformIntegration } from "mb-sdk";
const carButton = new PlatformIntegration.TextButton({ text: "Car", action: "Car", value: 20 });
const bikeButton = new PlatformIntegration.TextButton({ text: "Bike", action: "Bike", value: 21 });
const otherButton = new PlatformIntegration.TextButton({ text: "Other", action: "Other", value: 22 });
const card = new PlatformIntegration.ChatBotCard({
title: "Question 1",
text: "What mode of transportation would you like to use?",
image: "www.blabla.com/example.jpg",
buttons: [carButton, bikeButton, otherButton],
});
const cardMessage = new PlatformIntegration.CardMessage({
delay: 250,
payloads: [card],
fallback: 20,
fallbackCount: 3,
inputParam: "transportationAnswer",
errorMessage: "Please check your answer.",
});
Quick Reply Message refers to a type of interactive message that allows users to choose from a predefined set of options as a response. It typically appears as a list of buttons or selectable options, enabling users to quickly select their desired response instead of typing it out. Quick Reply Messages provide a more streamlined and user-friendly way of engaging with a conversation or interactive system, making it easier for users to provide input or navigate through available choices.
import { PlatformIntegration } from "mb-sdk";
const carButton = new PlatformIntegration.TextButton({ text: "Car", action: "Car", value: 20 });
const bikeButton = new PlatformIntegration.TextButton({ text: "Bike", action: "Bike", value: 21 });
const otherButton = new PlatformIntegration.TextButton({ text: "Other", action: "Other", value: 22 });
const qrMessage = new PlatformIntegration.QuickReplyMessage({
delay: 250,
payloads: [carButton, bikeButton, otherButton],
prompt: "Prompt",
fallback: 20,
fallbackCount: 3,
inputParam: "transportationAnswer",
errorMessage: "Please check your answer.",
});
List Message is a message format that presents information in a structured list format. It includes sections and rows, allowing you to organize and display content in a categorized manner.
import { PlatformIntegration } from "mb-sdk";
const mbListCardRow1 = new PlatformIntegration.MBListCardRow("1", "example title", "example description", 10);
const mbListCardRow2 = new PlatformIntegration.MBListCardRow("2", "example title", "example description", 11);
const listSection1 = new PlatformIntegration.ListSection("Example section", [mbListCardRow1, mbListCardRow2]);
const listPayload = new PlatformIntegration.List({
messageBoxBody: "Body example",
messageBoxOptionsButtonText: "Options",
listHeader: "Example Header",
listSections: [listSection1],
});
Template Message is a feature provided by WhatsApp that enables the sending of pre-defined and structured messages. These messages are created and approved by WhatsApp, allowing businesses to send standardized templates for various purposes such as order confirmations, appointment reminders, and customer support interactions.
import { PlatformIntegration } from "mb-sdk";
const recipients = [new PlatformIntegration.MBTemplateRecipient("+1234567890"), new PlatformIntegration.MBTemplateRecipient("+9876543210")];
const templateData = {
languageLocaleCode: "tr",
name: "Template Name",
companyId: "y5ad8d93-x4x4-x4x4-x4x4-0001122a8aar",
companyPriority: 10,
whatsappAccountId: "908500000000",
createdBy: "Mindbehind",
startNow: true,
whatsappTemplateId: "222333444555666",
whatsappTemplateName: "emergency_template",
whatsappTemplateNamespace: "template-namespace",
recipients: recipients,
};
const template = new PlatformIntegration.MBTemplate(templateData);
The AI module utilizes a threshold to find similar texts.
The AI input module awaits the user's input. It examines the proximity of the entered input using a predetermined threshold and facilitates its progression towards the specified connection.
import { PlatformIntegration } from "mb-sdk";
const inputAi = new PlatformIntegration.InputAI({
threshold: 0.5,
aiType: "test_id",
connections: [
{ id: 7, intent: "bye" },
{ id: 8, intent: "help" },
],
fallback: 210,
fallbackCount: 0,
inputParam: "userInputData",
});
The AI Message module considers the user's most recent message. By evaluating the proximity of this message using a threshold, it allows the message to advance towards the designated connection.
import { PlatformIntegration } from "mb-sdk";
const messageAi = new PlatformIntegration.MessageAI({
threshold: 0.6,
aiType: "test_id",
connections: [
{ id: 7, intent: "bye" },
{ id: 8, intent: "help" },
],
fallback: 210,
fallbackCount: 0,
});
MBSDK is a Software Development Kit (SDK) designed to simplify database operations and reduce the workload for developers by providing predefined methods to query data. The SDK comes with four core methods:
find
: Queries documents matching the specified criteria.findOneAndUpdate
: Updates the first document that matches the specified criteria.deleteOne
: Deletes the first document that matches the specified criteria.insertOne
: Adds a new document to the database.To query data using MBSDK, you first need to create an instance of the DatabaseSDK class.
import { DatabaseSDK } from "mb-sdk";
const createInst = new DatabaseSDK(<token>, <env>, <companyId>, <schemaId>);
token
(String, Required
): The token value obtained from the DataStation page after user login.env
(String, Required
): The target environment. Possible values are TR, DEV, UAT, EU, or specific clusters.companyId
(String, Required
): The unique identifier of the company.schemaId
(String, Required
): The schema ID obtained from the DataStation page after user login.Queries documents that match the specified criteria.
filter
(Object, Required
): Query filter.sort
(Object, Required
): Sorting criteria.limit
(Number, Optional
): The number of documents to return.import { DatabaseSDK } from "mb-sdk";
const createInst = new DatabaseSDK(<token>, <env>, <companyId>, <schemaId>);
const result = await createInst.find({ name: 'Omer' }, { age: -1 }, 30);
Updates the first document that matches the specified criteria.
filter
(Object, Required
): Query filter.upsert
(Object, Required
): Values to update.sort
(Object, Required
): Sorting criteria.limit
(Number, Optional
): The number of documents to return.import { DatabaseSDK } from "mb-sdk";
const createInst = new DatabaseSDK(<token>, <env>, <companyId>, <schemaId>);
const result = await createInst.findOneAndUpdate({ name: 'Omer' }, { age: 30 });
Deletes the first document that matches the specified criteria.
filter
(Object, Required
): Query filter.import { DatabaseSDK } from "mb-sdk";
const createInst = new DatabaseSDK(<token>, <env>, <companyId>, <schemaId>);
const result = await createInst.deleteOne({ name: 'Omer' });
Adds a new document to the database.
filter
(Object, Required
): Data of the document to be inserted.import { DatabaseSDK } from "mb-sdk";
const createInst = new DatabaseSDK(<token>, <env>, <companyId>, <schemaId>);
const result = await createInst.insertOne({ name: 'Omer', age: 29 });
The following error types may be returned by the MBSDK(DatabaseSDK) methods:
{
"TOKEN_NOT_FOUND": "TOKEN_NOT_FOUND",
"BASE_URL_NOT_FOUND": "BASE_URL_NOT_FOUND",
"INVALID_URL": "INVALID_URL",
"REQUEST_TIMED_OUT": "REQUEST_TIMED_OUT",
"SCHEMA_ID_NOT_FOUND": "SCHEMA_ID_NOT_FOUND",
"INVALID_SCHEMA_ID": "INVALID_SCHEMA_ID",
"COMPANY_ID_NOT_FOUND": "COMPANY_ID_NOT_FOUND",
"INVALID_COMPANY_ID": "INVALID_COMPANY_ID",
"PARAMETER_MUST_BE_OBJECT": "PARAMETER_MUST_BE_OBJECT",
"OBJECT_KEYS_LIMIT_EXCEEDED": "OBJECT_CAN_HAVE_MAXIMUM_OF_10_KEYS",
"OBJECT_SIZE_LIMIT_EXCEEDED": "OBJECT_CAN_HAVE_MAXIMUM_SIZE_20_KEYS"
}
Please note that the provided descriptions and usage examples are placeholders. They should be replaced with accurate and meaningful descriptions and usage instructions based on the actual implementation and functionality of each module.
Licensed under the MIT License.
FAQs
Mindbehind SDK
The npm package mb-sdk receives a total of 50 weekly downloads. As such, mb-sdk popularity was classified as not popular.
We found that mb-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.