Python chatbot
from chatbot import Chat,reflections,multiFunctionCall
import wikipedia
def whoIs(query,sessionID="general"):
try:
return wikipedia.summary(query)
except:
for newquery in wikipedia.search(query):
try:
return wikipedia.summary(newquery)
except:
pass
return "I don't know about "+query
call = multiFunctionCall({"whoIs":whoIs})
firstQuestion="Hi, how are you?"
Chat("examples/Example.template", reflections,call=call).converse(firstQuestion)
For Detail on how to build Facebook messenger bot checkout Facebook Integration.ipynb
For Jupyter notebook Chatbot checkout Infobot built using NLTK-Chatbot
- 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
- Memory
- Get matched group
- Recursion
- Condition
- Change Topic
- Interact with python function
- Execute shell script
- Topic based group
- Learn
- To upper case
- To lower case
- Capitalize
- Previous
{ variable : value }
In think mode
{! variable : value }
#### Get Memory
> ```
{ variable }
%N
Example to get first matched
> ```
%1
%!N
Example to get first matched
> ```
%!1
Get response as if client said this new statement
{% chat statement %}
It will do a pattern match for statement
{% if condition %} do this first {% elif condition %} do this next {% else %} do otherwise {% endif %}
## Change Topic
> ```
{% topic TopicName %}
{% call functionName: value %}
## Execute shell script
> ```
[ cmd ]
Execute command in think mode
[! cmd ]
## Topic based group
>```
{% group topicName %}
{% block %}
{% client %}client says {% endclient %}
{% response %}response test% endresponse %}
{% endblock %}
...
{% endgroup %}
{% learn %} {% group topicName %} {% block %} {% client %}client says {% endclient %} {% response %}response test% endresponse %} {% endblock %} ... {% endgroup %} ... {% endlearn %}
# To upper case
>```
{% up string %}
{% low string %}
# Capitalize
>```
{% cap string %}
{% block %} {% client %}client's statement pattern{% endclient %} {% prev %}previous bot's statement pattern{% endprev %} {% response %}response string{% endresponse %} {% endblock %}