question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make chatbot do some tasks when asked a question(chatterbot)

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
pylobotcommented, Mar 4, 2018

@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

1reaction
jithinolickalcommented, Feb 25, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found