Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A sample code for docomo sebastien CGS (https://developers.sebastien.ai)
#!/usr/bin/env python
import flask
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.route('/test', methods=["POST"])
def test():
bot_id = request.json["bot_id"]
user_id = request.json["user_id"]
intent = request.json["args"]["intent"]
print(request.json["args"]["utterance"])
if intent == "test":
text = request.json["args"]["utterance"] + "。いえーい!"
talkend_flag = False
elif intent == "noun":
noun = request.json["args"]["noun"]
text = noun + "、ってなんじゃ?"
talkend_flag = False
elif intent == "goodbye":
text = ""
talkend_flag = True
responce = {"error_code": "success",
"status": "true",
"bot_id": bot_id,
"user_id": user_id,
"params": {
"status": "true",
"talkend": talkend_flag,
"message": text,
"option": {"balloon": {
"type": "text"
}
}
}
}
return jsonify(responce)
def main():
app.run(host='0.0.0.0', port=8080)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.