前提・実現したいこと
「Alexaのダイアログモデルを使ったJSONファイルに対してのLamda関数の実装方法について」
で作成したjsonファイルを記載しています。こちらでは文字数制限により記載できなかったjsファイルを記載しています。
該当のソースコード
'use strict'; const Alexa = require('alexa-sdk'); const APP_ID = process.env.ALEXA_APP_ID; // スキルのアプリケーションIDと置き換えます exports.handler = function (event, context, callback) { const alexa = Alexa.handler(event, context, callback); alexa.appId = APP_ID; alexa.registerHandlers(handlers); alexa.execute(); }; const handlers = { 'LaunchRequest': function () { const speechOutput = 'ようこそ。お客様の御社名、お客様のお名前、お客様人数、呼び出したい弊社の担当者の名前を教えてください。'; const reprompt = 'お客様の御社名、お客様のお名前、お客様人数、呼び出したい弊社の担当者の名前を教えてください。'; this.emit(':ask', speechOutput, reprompt); }, 'acceptanceIntent': function () { var companyname = this.attributes['companyName']; var visitorname = this.attributes['visitorName']; var companynumber = this.attributes['companyNumber']; var picname = this.attributes['picname']; if (companyname == undefined) { companyname = this.event.request.intent.slots.companyName.value; } if (visitorname == undefined) { visitorname = this.event.request.intent.slots.visitorName.value; } if (companynumber == undefined) { companynumber = this.event.request.intent.slots.companyNumber.value; } if (picname == undefined) { picname = this.event.request.intent.slots.picname.value; } if (companyname == undefined) { this.emit(':ask', "御社名を教えていただけますか?", '御社名を教えていただけますか?'); } else if (visitorname == undefined) { this.attributes["companyName"] = companyname; this.emit(':ask', companyname + '株式会社ですね。', 'お客様のお名前を教えていただけますか?'); } else if (companynumber == undefined) { this.attributes["companyName"] = companyname; this.attributes["visitorName"] = visitorname; this.emit(':ask', companyname + "株式会社の" + visitorname + "様ですね。", "お客様人数を教えていただけますか?"); } else if (picname == undefined) { this.attributes["companyName"] = companyname; this.attributes["visitorName"] = visitorname; this.attributes["companyNumber"] = companyname; this.emit(':ask', companyname + "株式会社の" + visitorname + "様" + companynumber + "名のご来社ですね。", "呼び出したい弊社の担当者の名前を教えていただけますか?"); } else { this.attributes["companyName"] = companyname; this.attributes["visitorName"] = visitorname; this.attributes["companyNumber"] = companyname; this.attributes["picname"] = picname; this.emit(':ask', companyname + "株式会社の" + visitorname + "様" + companynumber + "名のご来社ですね。" + picname + "を呼び出し致します。", "お客様の御社名、お客様のお名前、お客様人数、呼び出したい弊社の担当者の名前にお間違えはありませんか?"); } }, 'companyNameAskIntent': function () { this.emit('acceptanceIntent'); }, 'visitorNameAskIntent': function () { this.emit('acceptanceIntent'); }, 'companyNumberAskIntent': function () { this.emit('acceptanceIntent'); }, 'picNameAskIntent': function () { this.emit('acceptanceIntent'); }, 'AMAZON.YesIntent': function () { var picname = this.attributes["picname"]; this.emit(':tell', picname + "を呼び出し致します。少々お待ちください。"); }, 'AMAZON.NoIntent': function () { this.emit(':tell', "恐れ入りますが受付の手続きをもう一度行っていただくもしくは、直接担当者にご確認ください。"); }, 'SessionEndedRequest': function () { }, 'AMAZON.HelpIntent': function () { const speechOutput = '受付を任されているアレクサです。お困りですか?'; const reprompt = 'お困りですか?'; this.emit(':ask', speechOutput, reprompt); }, 'AMAZON.CancelIntent': function () { this.emit('AMAZON.StopIntent'); }, 'AMAZON.StopIntent': function () { const speechOutput = '受付をご利用いただきありがとうございました。'; this.emit(':tell', speechOutput); }, Unhandled: function () { var message = "この文章が表示されるときは予期せぬ発話へのエラーハンドリングが発生している証拠です"; this.emit(':ask', message, message); } };
試したこと
ダイアログモデルを使用して一つのインテント内で会話が成立する方法
インテントを聞きたいスロット分用意して会話を成立させる方法
あなたの回答
tips
プレビュー