A chatbot AI engine is a chatbot builder platform that provides both bot intelligence and chat handler with minimal codding
Project description
ChatBotAI
Python chatbot AI that helps in creating a python based chatbot with minimal coding. This provides both bots AI and chat handler and also allows easy integration of REST API's and python function calls which makes it unique and more powerful in functionality. This AI provides numerous features like learn, memory, conditional switch, topic-based conversation handling, etc.
Installation
Install from PyPI:
pip install chatbotAI
install from github:
git clone https://github.com/ahmadfaizalbh/Chatbot.git
cd Chatbot
python setup.py install
Demo
>>> from chatbot import demo
>>> demo()
Hi, how are you?
> i'm fine
Nice to know that you are fine
> quit
Thank you for talking with me.
>>>
Sample Code (with wikipedia search API integration)
from chatbot import Chat, register_call
import wikipedia
@register_call("whoIs")
def who_is(session, query):
try:
return wikipedia.summary(query)
except Exception:
for new_query in wikipedia.search(query):
try:
return wikipedia.summary(new_query)
except Exception:
pass
return "I don't know about "+query
first_question="Hi, how are you?"
Chat("examples/Example.template").converse(first_question)
For Detail on how to build Facebook messenger bot checkout Facebook Integration.ipynb
For Jupyter notebook Chatbot checkout Infobot built using NLTK-Chatbot
Sample Apps
- A sample facebook messenger bot built using messengerbot, Django and NLTK-Chatbot is available here Facebook messenger bot
- A sample microsoft bot built using Microsoft Bot Connector Rest API - v3.0, Django and NLTK-Chatbot is available here Micosoft Chatbot
List of feature supported in bot template
- Memory
- Get matched group
- Recursion
- Condition
- Change Topic
- Interact with python function
- REST API integration
- Topic based group
- Learn
- To upper case
- To lower case
- Capitalize
- Previous
Memory
Set Memory
{ variable : value }
In think mode
{! variable : value }
Get Memory
{ variable }
Get matched group
for grouping in regex refer Python regular expression docs
Get Nth matched group of client pattern
%N
Example to get first matched
%1
Get matching named group of client pattern
%Client_pattern_group_name
Example to get matching named group person
%person
Get Nth matched group of bots message pattern
%!N
Example to get first matched
%!1
Get matching named group of bots message pattern
%!Bot_pattern_group_name
Example to get matching named group region
%!region
Recursion
Get response as if client said this new statement
{% chat statement %}
It will do a pattern match for statement
Condition
{% if condition %} do this first {% elif condition %} do this next {% else %} do otherwise {% endif %}
Change Topic
{% topic TopicName %}
Interact with python function
In python
@register_call("functionName")
def function_name(session, query):
return "response string"
In template
{% call functionName: value %}
REST API integration
In API.json file
{
"APIName":{
"auth" : {
"url":"https://your_rest_api_url/login.json",
"method":"POST",
"data":{
"user":"Your_Username",
"password":"Your_Password"
}
},
"MethodName" : {
"url":"https://your_rest_api_url/GET_method_Example.json",
"method":"GET",
"params":{
"key1":"value1",
"key2":"value2",
...
},
"value_getter":[order in which data has to be picked from json response]
},
"MethodName1" : {
"url":"https://your_rest_api_url/GET_method_Example.json",
"method":"POST",
"data":{
"key1":"value1",
"key2":"value2",
...
},
"value_getter":[order in which data has to be picked from json response]
},
"MethodName2" : {
...
},
...
},
"APIName2":{
...
},
...
}
If authentication is required only then auth
method is needed.The data
and params
defined in pi.json file acts as defult values and all key value pair defined in template file overrides the default value.value_getter
consistes of list of keys in order using which info from json will be collected.
In Template file
[ APIName:MethodName,Key1:value1 (,Key*:value*) ]
you can have any number of key value pair and all key value pair will override data or params depending on method
, if method
is POST
then it overrides data and if method is GET
then it overrides params
.
Topic based group
{% group topicName %}
{% block %}
{% client %}client says {% endclient %}
{% response %}response text{% endresponse %}
{% endblock %}
...
{% endgroup %}
Learn
{% learn %}
{% group topicName %}
{% block %}
{% client %}client says {% endclient %}
{% response %}response text{% endresponse %}
{% endblock %}
...
{% endgroup %}
...
{% endlearn %}
To upper case
{% up string %}
To lower case
{% low string %}
Capitalize
{% cap string %}
Previous
{% block %}
{% client %}client's statement pattern{% endclient %}
{% prev %}previous bot's statement pattern{% endprev %}
{% response %}response string{% endresponse %}
{% endblock %}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file chatbotAI-0.3.1.3.tar.gz
.
File metadata
- Download URL: chatbotAI-0.3.1.3.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 566115d8dfc6a1afdc48c1a98feb6f882c680840b313ad7414f22c6d3b629207 |
|
MD5 | c025f2f3080c52ee27e662fa674f2b57 |
|
BLAKE2b-256 | d440f32720944b7bfad2a31a98cb9f90932347c5b2c562cecd5438980ab44f5c |
File details
Details for the file chatbotAI-0.3.1.3-py2.py3-none-any.whl
.
File metadata
- Download URL: chatbotAI-0.3.1.3-py2.py3-none-any.whl
- Upload date:
- Size: 9.9 MB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92f85ecac30b00596de316dcfb4da710d929a8ae026d8c2172e7e0eb8e8ae53b |
|
MD5 | 9c0ba69b62c762acea95f0d85c0f446f |
|
BLAKE2b-256 | b02f2a9f21dfe3dcf522f750f08c3dbb7fbef7f09305c215b656c9ad8574b0fa |