Search code examples
pythonchatterbot

Chatterbot start a command intead of output string


I see some example code on documentation website of Chatterbot

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named Charlie
chatbot = ChatBot('Charlie')

trainer = ListTrainer(chatbot)

trainer.train([
    "Hi, can I help you?",
    "Sure, I'd like to book a flight to Iceland.",
    "Your flight has been booked."
])

# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')

print(response)

Is there any possibility to tell the bot to start a command from terminal and not post a string answer?


Solution

  • Use input if you have python3 or raw_input if python2

    while True:
        question = input("")
        response = chatbot.get_response(question)
        print(response)