Exemple #1
0
def get_bot_response():
    print(request.json)
    msg = request.json.get('msg')
    print(f'QUESTION: {msg}')
    answer = chatbot_response(msg)
    print(f'ANSWER: {answer}')

    return jsonify({'msg': msg, 'answer': answer})
Exemple #2
0
def get_bot_response():
    print(request.json)
    question = request.json.get('question')
    print(f'QUESTION: {question}')
    answer = chatbot_response(question)
    print(f'ANSWER: {answer}')

    return jsonify({'question': question, 'answer': answer})
Exemple #3
0
    def post(self):
        message = {"id": str(uuid.uuid4()), "body": self.get_argument("body")}
        # render_string() returns a byte string, which is not supported
        # in json, so we must convert it to a character string.

        retmsg = {"id": str(uuid.uuid4()), "body": self.get_argument("body")}
        retmsg["body"] = bot.chatbot_response(message["body"])
        retmsg["html"] = tornado.escape.to_unicode(
            self.render_string("message.html", message=retmsg))

        message["html"] = tornado.escape.to_unicode(
            self.render_string("message.html", message=message))
        if self.get_argument("next", None):
            self.redirect(self.get_argument("next"))
        else:
            self.write(message)
        global_message_buffer.add_message(message)
        global_message_buffer.add_message(retmsg)
Exemple #4
0
def get():
    msg = request.args.get("msg")
    answer = chatbot_response(msg)
    return answer