How to make chatbot do some tasks when asked a question(chatterbot)
See original GitHub issueI used chatterbot Api to create a chatbot. I was able to fetch data from a excel sheet and display it. But how to display an output (excel values and calculations done using excel values) when a question is asked? Normally we feed the question and answers. I need to get the results from excel file as an answer to a question to chatbot.
import xlrd #import excel reader
from chatterbot import ChatBot
chatbot = ChatBot(
'Charlie',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
"import_path": "chatterbot.logic.BestMatch"
},
{
'import_path': 'chatterbot.logic.SpecificResponseAdapter',
'input_text': 'Help me!',
'output_text': 'Ok, here is a link: http://chatterbot.rtfd.org'
},
{
'import_path': 'chatterbot.logic.LowConfidenceAdapter',
'threshold': 0.65,
'default_response': 'I am sorry, but I do not understand.'
}
],
trainer='chatterbot.trainers.ListTrainer'
)
#opening Excel
workbook = xlrd.open_workbook('D:\\chatbot\\Book1.xlsx')
#opening sheet
worksheet = workbook.sheet_by_name('Sheet2')
#for-loop for iteration
for row_idx in range(0, worksheet.nrows):
#print ('-'*40)
#print ('Row: %s' % row_idx)
#for col_idx in range(0, worksheet.ncols):
# cell_obj = worksheet.cell(row_idx, col_idx).value
# print ('Column: [%s] cell_obj: [%s]' %(col_idx, cell_obj))
ques=worksheet.cell(row_idx, 0).value
ans=worksheet.cell(row_idx, 1).value
chatbot.train([ques,ans])
response = chatbot.get_response('I would like to book a flight.')
print(response)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
How To Make A Chatbot In Python - Edureka
In this article, we will learn how to make a chatbot in python using the ChatterBot library which implements various machine learning ...
Read more >How to Create a Chatbot Using Chatterbot Python - YouTube
Click here to subscribe: https://goo.gl/G4Ppnf ******Hi guys! Welcome to another video, in this video I'm gonna show you guys this Python ...
Read more >ChatterBot 1.1.0a7 documentation - Read the Docs
The main class ChatBot is a connecting point between each of ChatterBot's adapters. In this class, an input statement is processed and stored...
Read more >How to Make a Chatbot From Scratch
Then, choose Retry after filled so that your bot will keep trying until it gets the proper answer. When you're ready, click save...
Read more >Beginner's guide to creating a powerful chatbot | by Louis Teo
Thanks to the ChatterBot library in Python, creating a chatbot is no longer a daunting machine learning task that it used to be....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jithinolickal I think you have to write you own logic adapter based on your question. More information about how to write a new logic adapter is documented here https://chatterbot.readthedocs.io/en/stable/logic/create-a-logic-adapter.html
Thanks for the reply. I’m able to read and write data. But my question is, how to output values from an excel file as an answer when a question is asked to chatbot? For example, assume I have a column called “cost” which contains several values. Of I ask chatbot ‘what is the total cost?’ it should give answer as the total cost. It’s not about reading and writing, but it’s about displaying values from a chatbot. Regards.