Package: chatbotAI
ChatBotAIPython 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.InstallationInstall from PyPI:pipinstallchatbotAIinstall from github:gitclonehttps://github.com/ahmadfaizalbh/Chatbot.gitcdChatbot
pythonsetup.pyinstallDemo>>>fromchatbotimportdemo
>>>demo()Hi,howareyou?
>i'mfine
Nicetoknowthatyouarefine>quit
Thankyoufortalkingwithme.
>>>Sample Code (with wikipedia search API integration)fromchatbotimportChat,register_callimportwikipedia@register_call("whoIs")defwho_is(session,query):try:returnwikipedia.summary(query)exceptException:fornew_queryinwikipedia.search(query):try:returnwikipedia.summary(new_query)exceptException:passreturn"I don't know about "+queryfirst_question="Hi, how are you?"Chat("examples/Example.template").converse(first_question)For Detail on how to build Facebook messenger bot checkoutFacebook Integration.ipynbFor Jupyter notebook Chatbot checkoutInfobot built using NLTK-ChatbotSample AppsA sample facebook messenger bot built usingmessengerbot,DjangoandNLTK-Chatbotis available hereFacebook messenger botA sample microsoft bot built usingMicrosoft Bot Connector Rest API - v3.0,DjangoandNLTK-Chatbotis available hereMicosoft ChatbotList of feature supported in bot templateMemoryGet matched groupRecursionConditionChange TopicInteract with python functionREST API integrationTopic based groupLearnTo upper caseTo lower caseCapitalizePreviousMemorySet Memory{ variable : value }In think mode{! variable : value }Get Memory{ variable }Get matched groupfor grouping in regex referPython regular expression docsGet Nthmatched group of client pattern%NExample to get first matched%1Get matching named group of client pattern%Client_pattern_group_nameExample to get matching named groupperson%personGet Nthmatched group of bots message pattern%!NExample to get first matched%!1Get matching named group of bots message pattern%!Bot_pattern_group_nameExample to get matching named groupregion%!regionRecursionGet response as if client said this new statement{% chat statement %}It will do a pattern match for statementCondition{% if condition %} do this first {% elif condition %} do this next {% else %} do otherwise {% endif %}Change Topic{% topic TopicName %}Interact with python functionIn python@register_call("functionName")deffunction_name(session,query):return"response string"In template{% call functionName: value %}REST API integrationIn 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 thenauthmethod is needed.Thedataandparamsdefined in pi.json file acts as defult values and all key value pair defined in template file overrides the default value.value_getterconsistes 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 onmethod, ifmethodisPOSTthen it overrides data and if method isGETthen it overridesparams.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 %}