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 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.2.tar.gz (16.6 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.2-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: BotnoiDevPlatform-0.0.2.tar.gz
  • Upload date:
  • Size: 16.6 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.2.tar.gz
Algorithm Hash digest
SHA256 22b20cf98c7598a1d7c9f3fdfdd7b5e3066e208e94d79fbb63c0be06774edd09
MD5 a367c5b3f69b6915164049d11f57fa52
BLAKE2b-256 2a6027d02cdc2c8b603a1dc576c3164abd05ce4f35d68f30f4f895126898ec97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for BotnoiDevPlatform-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 669220217efb6ae18d4d6fd41392c7b86418081a118e05cef2c52788082a0ef4
MD5 bd244dd82803524d5f825f6cc395c59b
BLAKE2b-256 64ede8d4b4b7e49db2cc945ba8a071f60e9d57101777f1fc26b4bab929d59803

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