def bot_process():
    language = request.args.get("language")  # needs no default,
    # index provides language
    # or default "en"
    return_to_func = request.args.get("return_to_func")

    msg = request.form.get("msg").lower().strip()
    msg = microsoft_translate(language, msg, "en")

    message_logger.add_msg("human", msg)

    reply = chatbot.answer(microsoft_translate(language, msg, "en"))
    message_logger.add_msg("bot", microsoft_translate("en", reply, language))

    message_logger.log_sql(msg, reply, language)
    return redirect(url_for(return_to_func, language=language))
Exemple #2
0
def translate():
	return jsonify({
		'text' : microsoft_translate(
			request.form['text'],
			request.form['sourceLang'],
			request.form['destLang'])
		})
def start_convo():
    """Initiate the conversation between the user and the chatbot.
    Still accessable if they just type the URL, but better then
    they're avioding the email submission page on purpose.
    """
    language = request.args.get("language", "en")
    message_logger.add_msg(
        "bot",
        microsoft_translate("en", "Hello, how may I help you today?",
                            language))
    return redirect(url_for("index", language=language))
Exemple #4
0
def translate():
    return jsonify(
        {"text": microsoft_translate(request.form["text"], request.form["sourceLang"], request.form["destLang"])}
    )
Exemple #5
0
def translate():
    return jsonify({
        'text':
        microsoft_translate(request.form['text'], request.form['sourceLang'],
                            request.form['destLang'])
    })