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 in side of your bot 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.7.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.7-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: BotnoiDevPlatform-0.0.7.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.7.tar.gz
Algorithm Hash digest
SHA256 6c6b989fc2560f483a8172a616a7d68789676d328d88e3871b8c42d0a3bdda09
MD5 474d8e162f79fb740d883e52abcd2d59
BLAKE2b-256 edba893d3196d7ca963a62080984b472e3364044be52f9ee3eb28b1e312a37b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for BotnoiDevPlatform-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 54da2e064dcc610268e7f7117f753fbcfaecd92988c5442ff8db065207d8a298
MD5 dc3ee676dbf69d33ada24748cbad5b54
BLAKE2b-256 213c691712d080fb84f72bf5a6417e6ca0c4cb7c2e001d5fe6e77824942c3ad7

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