Skip to main content

A chatbot AI engine is a chatbot builder platform that provids both bot intelligence and chat handler with minimal codding

Project description

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

Sample Code (with wikipedia search API integration)

from chatbot import Chat, register_call
import wikipedia

@register_call("whoIs")
def who_is(query,session_id="general"):
    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

  1. A sample facebook messenger bot built using messengerbot, Django and NLTK-Chatbot is available here Facebook messenger bot

  2. 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

  1. Memory

  2. Get matched group

  3. Recursion

  4. Condition

  5. Change Topic

  6. Interact with python function

  7. REST API integration

  8. Topic based group

  9. Learn

  10. To upper case

  11. To lower case

  12. Capitalize

  13. Previous


Memory

Set Memory

{ variable : value }

In think mode

{! variable : value }

Get Memory

{ variable }

Get matched group

Get Nth matched group of client pattern

%N

Example to get first matched

%1

Get Nth matched group of bots pattern

%!N

Example to get first matched

%!1

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(query, session_id="general"):
    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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

chatbotAI-0.2.1.01-py3.6.egg (3.9 MB view details)

Uploaded Egg

chatbotAI-0.2.1.01-py2.py3-none-any.whl (3.9 MB view details)

Uploaded Python 2Python 3

File details

Details for the file chatbotAI-0.2.1.01-py3.6.egg.

File metadata

  • Download URL: chatbotAI-0.2.1.01-py3.6.egg
  • Upload date:
  • Size: 3.9 MB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

File hashes

Hashes for chatbotAI-0.2.1.01-py3.6.egg
Algorithm Hash digest
SHA256 ec2ddef8feba906018904f38e4424b9e9cbd43290d2fe97547c88ae070faa961
MD5 aa43971bb3beb44f16aecb4ff574a79d
BLAKE2b-256 5519f8f603f0430bd8041bc4e20dc92f69f611b03d569920e5cda03a4dbdbde7

See more details on using hashes here.

File details

Details for the file chatbotAI-0.2.1.01-py2.py3-none-any.whl.

File metadata

  • Download URL: chatbotAI-0.2.1.01-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

File hashes

Hashes for chatbotAI-0.2.1.01-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 272fa2d424c95017a523e86cebb86f0b5d067e62be7c975e1c1f0de72aa6a91e
MD5 3474c53484b019af39cdc78e9c1a34dc
BLAKE2b-256 d038dac7b1394c2b04212fce5b89d4d2b7d95fa2f70c1081f463cc8d86ff6a2a

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