https://github.com/vkosuri/chatterbot-tricks
Most commonly used chatterbot tips and tricks
https://github.com/vkosuri/chatterbot-tricks
chatterbot tips-and-tricks
Last synced: 4 months ago
JSON representation
Most commonly used chatterbot tips and tricks
- Host: GitHub
- URL: https://github.com/vkosuri/chatterbot-tricks
- Owner: vkosuri
- License: mit
- Created: 2017-01-15T05:18:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-17T06:04:01.000Z (over 9 years ago)
- Last Synced: 2025-09-16T04:54:04.174Z (9 months ago)
- Topics: chatterbot, tips-and-tricks
- Homepage: https://vkosuri.github.io/chatterbot-tricks/
- Size: 20.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Chatterbot Tricks
Most commonly used [chatterbot](https://github.com/gunthercox/ChatterBot) tips and tricks, click here to print [](https://gitprint.com/vkosuri/chatterbot-tricks/blob/master/README.md)
# Table of Contents
1. [Chatterbot test into events](#chatbot-text-into-events)
2. [Combination of both voice and chat](#combination-of-both-voice-and-chat)
3. [Prioritizing some responses over others](#prioritizing-some-responses-over-others)
4. [Integrating Jinja2 templates into corpus](#integrating-jinja2-templates-into-corpus)
## Chatbot text into events
Ref: [#482](https://github.com/gunthercox/ChatterBot/issues/482)
Creating efficient scheduling operations can often be a challenging problem to solve. What about offloading the task to the user's calendar? Most calendar apps already display notifications when a scheduled event is coming up, and it would also make it possible synchronize the events across the user's devices if they were all connected to the same calendar.
https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations
https://developers.google.com/google-apps/calendar/v3/reference/
## Combination of both voice and chat
Ref: [#416](https://github.com/gunthercox/ChatterBot/issues/416)
I think it's definitely possible, but because it's a web app the audio will have to be processed on the client's side. This might make things easier because there is likely several javascript libraries available that handle speech recognition and speech synthesis. It looks like Google Chrome has built in support for both speech recognition and speech synthesis: https://developers.google.com/web/updates/2014/01/Web-apps-that-talk-Introduction-to-the-Speech-Synthesis-API
To implement this, you would have to add some javascript to listen to the user's speech, then it could send that to the Django ChatterBot
## Prioritizing some responses over others
Ref : [#518](https://github.com/gunthercox/ChatterBot/issues/518)
If you have a way to train your bot with the desired responses you could use
the [get_most_frequent_response](http://chatterbot.readthedocs.io/en/latest/logic/response_selection.html#chatterbot.response_selection.get_most_frequent_response) response selection method. Training multiple
times with the desired data would increment occurrence counts for those responses and it would ensure that they get selected. Using [training](http://chatterbot.readthedocs.io/en/latest/training.html#training-via-list-data) to increment the occurrence counts is probably the most efficient way to do this.
## Integrating jinja2 templates into corpus
Ref : [#518](https://github.com/gunthercox/ChatterBot/issues/518)
With reference [#469](https://github.com/gunthercox/ChatterBot/issues/469) I felt introducing jinja2 template into corpus, A more useful to users and developers.
```Json
{
"conversations": [
[
"What's you name",
"{{bot.name}}"
],
[
"How many years",
"{{bot.years}}"
]
]
}
```
```Python
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from jinja2 import Environment, FileSystemLoader
import json
import os
# Jinja2 corpus template
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
env = Environment(loader=FileSystemLoader(THIS_DIR), trim_blocks=True)
properties = {"name":"Chatterbot" , "years":2}
corpus_template = env.get_template('example.corpus.json').render(bot=properties)
print(corpus_template)
corpus_data = json.loads(corpus_template)
# Train chatterbot
chatterbot = ChatBot("Template Training Example")
chatterbot.set_trainer(ListTrainer)
for pair in corpus_data['conversations']:
chatterbot.train(pair)
```
## Tricks are most welcome, submit a pull request!!