Skip to content

Instantly share code, notes, and snippets.

Created Sep 16, 2018
What would you like to do?
# coding: utf-8
from flask import Flask, request, jsonify
import cek
import logging
app = Flask(__name__)
# Create a separate logger for this application
logger = logging.getLogger('my_clova_extension')
clova = cek.Clova(
application_id="MY EXTENSION ID",
@app.route('/clova', methods=['POST'])
def my_service():
# Forward the request to the Clova Request Handler
# Just pass in the binary request body and the request header
# as a dictionary
body_dict = clova.route(, header=request.headers)
response = jsonify(body_dict)
# make sure we have correct Content-Type that CEK expects
response.headers['Content-Type'] = 'application/json;charset-UTF-8'
return response
def launch_request_handler(clova_request):
# You can answer in different languages within one response
welcome_japanese = cek.Message(message="調子どうだい?", language="ja")
response = clova.response([
return response
# WifeStatusIntentの発火箇所
def wife_status_handler(clova_request):
slot = clova_request.slot_value("status")
message_japanese = cek.Message(message="もう一回言って下さい", language="ja")
if u"気分" in slot:
message_japanese = cek.Message(message="奥さんの気分はいい感じです", language="ja")
elif u"欲しい物" in slot:
message_japanese = cek.Message(message="奥さんは旅行に行きたがっています", language="ja")
response = clova.response([message_japanese])
return response
def end_handler(clova_request):
# Session ended, this handler can be used to clean up"Session ended.")
# In case not all intents have been implemented
# the handler falls back to the default handler
def default_handler(request):
return clova.response("Sorry I don't understand! Could you please repeat?")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment