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.6.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.6-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: BotnoiDevPlatform-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 8a5175ee26ac3cfbe3a612f74fc027cc5f2ec6687508b54b68bd5ed8c3115a09
MD5 7f7f69899164318f147db405de88c434
BLAKE2b-256 7840941c98e7b2dd01cda3ab59632691fdb987d2df86f5282fc8436b386db15f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for BotnoiDevPlatform-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 79873f6c30356e501770d93ffd93c97bf4b0d273393a31fbda7df525e3c9203f
MD5 a66d9a714277039e037634b152a13151
BLAKE2b-256 d42fbcbb33980abb25b616574edbbf2dc33642f90ab6077a1318ef080fff6a20

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