Created
July 20, 2017 16:32
-
-
Save osule/fefaedf830e23207391d6e5ae7e6ae7c to your computer and use it in GitHub Desktop.
Play with api.ai (an answer to stackoverflow)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, current_app, jsonify | |
from flask_assistant import Assistant, ask, tell, event, context_manager, request | |
from flask_assistant import ApiAi | |
app = Flask(__name__) | |
assist = Assistant(app, '/') | |
@assist.action('fallback', is_fallback=True) | |
def say_response(): | |
""" Setting the fallback to act as a looper """ | |
speech = request['result']['resolvedQuery'] | |
return ask(speech) | |
@assist.action('help') | |
def help(): | |
speech = "I just parrot things back!" | |
return ask(speech) | |
@assist.action('quit') | |
def quit(): | |
speech = "Leaving program" | |
return tell(speech) | |
if __name__ == '__main__': | |
app.run(debug=False, use_reloader=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment