Skip to main content

A programatical alternative to the visual chatbot builder provided by https://botnoi.ai .

Project description

Botnoi Dev Platform

Botnoi Dev Platform is a programatical alternative to the visual chatbot builder provided by https://botnoi.ai . It can be used to build and train chatbots for various platforms such as Facebook Messenger and LINE.

This official library provides a Python implementation of Botnoi Dev Platform's API in order to simplify the process of building chatbots. It also provides various data types related to chatbots such as 'Intent', 'Object' and lots of helper functions to work with them.

This suits best for developers who want to build chatbots programmatically or to automate the process of chatbot training when an action is performed by the applications' users.

Installation

Run this command in the terminal

pip install BotnoiDevPlatform

then, import the package

from BotnoiDevPlatform.cores import BotnoiChatbotServer
from BotnoiDevPlatform.elements import Bot, Intent, Object, IntentKeyword, IntentReaction, ImageObject
from BotnoiDevPlatform.utils import ObjectType, Action

note: you have to have an API key to use this package. You can get one from https://botnoi.ai

Usage

Set up

First, setup a client with your API key

BotnoiChatbotServer.setup_client('your_api_key')

Then, you can create a BotnoiChatbotServer server instance

server = BotnoiChatbotServer()

Create a bot

Creating a bot is simple. You just have to create a bot instance and add it to the server

test_bot = Bot(
    botName="test",
    businessType="test",
    botAvatar="https://console.botnoi.ai/assets/botnoi-logo/botnoi.svg",
    sex="male",
    age=20,
)

server.create_bot(test_bot)

# reload the bot from the server. 
# This is required to get the bot's id from the server.
test_bot.reload() 

Or find an existing bot by name

test_bot = server.find_bot_with_name("test")

Create and train an intent

You can create an intent by creating a new Intent instance and add it to the bot

test_intent = Intent(name="test_intent")

test_bot.opt.create_intent(test_intent)

# reload the intent from the server. 
# This is required to get the intent's id from the server.
test_intent.reload() 

Or find an existing one by name

test_intent = test_bot.opt.find_intent_with_name("test_intent")

notice that the 'opt' property is used when you want to do something with the bot that is related to Botnoi Dev Platform (eg. create_intent, find_intents, etc.). This is the standard for all data types that can directly interact with the server (eg. Bot, Intent, Object, etc.).

You can train the intent by adding some keywords(inputs) and reactions(outputs) to it

test_intent.opt.train_keyword(IntentKeyword("hello"))

test_intent.opt.train_reaction(IntentReaction(["hello!", "it works!"]))

Or train the reaction with more complex actions like this

test_intent.opt.train_reaction(
    IntentReaction([
        Action.image("test_image"), # send an image with name "test_image"
        Action.createParameter(parameterName="test_param", parameterValue=Action.get_keyword()), # create a parameter to store the latest message from the user
        Action.text("test param is " + Action.parameter("test_param")), # get the parameter and use it in a text,
    ])
)

Create an object

Creating objects is similar to creating intents. First, create an Object instance with typed objects in its objects property (eg. ApiObject, ImageObject, ButtonObject etc.). Every typed object instances must be of the same type. Then, you can add the Object instance to the bot.

test_image_object = Object(
    objectName="test_image",
    objects=[
        ImageObject(
            original_url="https://console.botnoi.ai/assets/botnoi-logo/botnoi.svg",
            preview_image_url="https://console.botnoi.ai/assets/botnoi-logo/botnoi.svg",
        )
    ]
)

test_bot.opt.create_object(test_image_object)

Or find an existing one by name

test_image_object = test_bot.opt.find_object_with_name("test_image",type=ObjectType.image())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BotnoiDevPlatform-0.0.8.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BotnoiDevPlatform-0.0.8-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file BotnoiDevPlatform-0.0.8.tar.gz.

File metadata

  • Download URL: BotnoiDevPlatform-0.0.8.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for BotnoiDevPlatform-0.0.8.tar.gz
Algorithm Hash digest
SHA256 1e388d986af2c6ee8fd5bfbe430c52443020c8a7ad74063d26764b0d3bbeb7e3
MD5 0427ddac1b7837afb79bcfad046b4026
BLAKE2b-256 94605c869235b2c6153ab76e2c3ff00fcbb38e29aba3f8a8555ce71dd9b9ebeb

See more details on using hashes here.

File details

Details for the file BotnoiDevPlatform-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for BotnoiDevPlatform-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9e3c25ab855a10546761748b9dd32f39531922db93e8e5dec36257a91758fdec
MD5 13fcab109418e90f250e08a433d314f3
BLAKE2b-256 c881244e58720aceab7ff7715bb0d803b3928a03dc27833ef3a0fde65e400c37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page