Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created August 21, 2020 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/ede71826a1d23a170e54afd0ad264043 to your computer and use it in GitHub Desktop.
Save amankharwal/ede71826a1d23a170e54afd0ad264043 to your computer and use it in GitHub Desktop.
#imports
from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
app = Flask(__name__)
#create chatbot
englishBot = ChatBot("Chatterbot", storage_adapter="chatterbot.storage.SQLStorageAdapter")
trainer = ChatterBotCorpusTrainer(englishBot)
trainer.train("chatterbot.corpus.english") #train the chatter bot for english
#define app routes
@app.route("/")
def index():
return render_template("index.html")
@app.route("/get")
#function for the bot response
def get_bot_response():
userText = request.args.get('msg')
return str(englishBot.get_response(userText))
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment