यह एक आसान हो सकता है लेकिन मैं इसे दिनों में नहीं समझ पाया।एलेक्सा (अमेज़ॅन इको) वार्तालाप कौशल - सत्र गुणों का उपयोग (जावास्क्रिप्ट - एडब्ल्यूएस लैम्ब्डा)
मैं एलेक्सा को वार्तालाप करना चाहता हूं, जैसे;
>> एलेक्सा, testSkill शुरू करें।
ए: टेस्ट कौशल शुरू हुआ। मुझे एक नंबर बताओ।
>> एक।
ए: ठीक है, अब मुझे एक रंग बताओ।
>> नीला।
ए: और अंत में, मुझे एक पशु नाम बताएं।
>> चिकन।
उत्तर: आप मुझे एक, नीले और चिकन कहा था।
मुझे पता चला कि मुझे कौशल के सत्र गुणों को संभालना है, जो एक JSON है और इरादों के बीच जानकारी स्थानांतरित करता है।
मैं इस तरह के कार्यों का उपयोग करता हूं;
function testConversation(intent, session, callback) {
var cardTitle = intent.name;
var repromptText = "";
var sessionAttributes = { // I don't know how to handle this
nameOfPairOne: "",
nameOfPairTwo: "",
};
var shouldEndSession = false;
var speechOutput = "";
var color= convertToASCII(intent.slots.color.value);
sessionAttributes.nameOfPairOne = color;
speechOutput = "You said "+sessionAttributes.nameOfPairOne+". Please say another thing. ";
callback(sessionAttributes, buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
}
function testConversation2(intent, session, callback) {
var cardTitle = intent.name;
var repromptText = "";
var sessionAttributes = session.attributes;
var shouldEndSession = false;
var speechOutput = "";
var number = convertToASCII(intent.slots.number.value);
sessionAttributes.nameOfPairTwo = number;
speechOutput = "You first said "+sessionAttributes.nameOfPairOne+", and now said "+sessionAttributes.nameOfPairTwo;
callback(sessionAttributes, buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
}
//------Helpers that build all of the responses ---------//
function buildSpeechletResponse(title, output, repromptText, shouldEndSession) {
return {
outputSpeech: {type: "PlainText", text: output},
card: {type: "Simple", title: "SessionSpeechlet - " + title, content: "SessionSpeechlet - " + output},
reprompt: {outputSpeech: {type: "PlainText", text: repromptText}},
shouldEndSession: shouldEndSession
};
}
function buildResponse(sessionAttributes, speechletResponse) {
return {version: "1.0", sessionAttributes: sessionAttributes, response: speechletResponse};
}
ऑनेंटेंट() फ़ंक्शन से कोड का एक टुकड़ा जहां मैं उपर्युक्त कार्यों को कॉल करता हूं। (मुझे पता है कि यह गलत है लेकिन सही तरीके से पता नहीं लगा सका)
else if ("getColorNum" == intentName) {
if (session.attributes.nameOfPairOne === "") {
testConversation(intent, session, callback);
} else {
testConversation2(intent, session, callback);
}
}
और इरादा स्कीमा JSON ऐसा ही है;
"intents": [
{
"intent": "getColorNum",
"slots": [
{
"name": "Color",
"type": "ColorSlot"
},
{
"name": "Number",
"type": "NumberSlot"
}
]
}
] }
तो, मैं चीजों की सब गलत कर रहा हूँ? गलती कहां है? और, मैंने एक वार्तालाप कैसे बनाया जैसे मैंने उल्लेख किया? अब से धन्यवाद
Sooo इच्छा है कि कोई इसका उत्तर देगा। इस बीच, एक समान प्रश्न में मेरे शोध ने इसे बदल दिया, जो कुछ मदद की हो सकती है: http://lovemyecho.com/wp-content/uploads/2015/07/SessionAttributesInJavascript.pdf – brianfit