我已经建立了一个简单的意图
{
"interactionModel": {
"languageModel": {
"invocationName": "viva bank",
"intents": [
...builtin intents...{
"name": "ask",
"slots": [{
"name": "question",
"type": "AMAZON.SearchQuery"
}],
"samples": [
"when {question}",
"how to {question}",
"what {question}"
]
}
],
"types": []
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我问一个问题时,它会给我一个通用的错误响应,如下所示:
我:Alexa问Viva银行什么时候收取滞纳金
Alexa:对不起,我不知道。
这是我的lambda代码,但我认为它还没到那么远。
'use strict';
const Alexa = require('ask-sdk-core');
var https = require('https');
var querystring = require('querystring');
const APP_ID = 'amzn1.ask.skill.1234';
const AskIntentHandler = {
canHandle(handlerInput) {
return !!handlerInput.requestEnvelope.request.intent.slots['question'].value;
},
handle(handlerInput) {
var question = handlerInput.requestEnvelope.request.intent.slots['question'].value;
console.log('mydata:', question);
var responseString …
Run Code Online (Sandbox Code Playgroud)在我的交互模型中,我定义了一个名为的插槽city
,该插槽是可选的,不是必需的,以实现意图。
我正在使用 python ask sdk,所以我的处理程序是这样的:
class IntentHandler(RequestHandler):
"""
Intent handler
"""
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
return is_request_type("IntentRequest")(handler_input) and \
is_intent_name("ExampleIntent")(handler_input)
def handle(self, handler_input):
# type: (HandlerInput) -> Response
access_token = handler_input.request_envelope.context.system.user.access_token
if access_token is None:
raise Exception("no access_token provided")
speech = RESPONSE_MESSAGE_DEFAULT
handler_input.response_builder.speak(speech)
return handler_input.response_builder.response
Run Code Online (Sandbox Code Playgroud)
如何检查插槽是否已被用户填充以及如何获取其值?
我正在创建 Alexa 技能,我编写了几个自定义和默认意图,并且它们运行良好。
现在我想写一个后备意图,其中我想获得询问/发送给 Alexa 技能的确切语句,有没有一种方法可以让我们获得已向 Alexa 技能询问的整个问题字符串/文本。我知道我们可以获取槽值和意图信息,但我需要将整个文本语句发送给技能。
谢谢
我需要为Alexa Skills Kit制作一个自定义技能,它应该是每个房间的一个回音设备.我需要为每个echo设备获取device_id.我听说这是不可能的,但也许它改变了,或者如果没有,还有其他办法.
alexa alexa-skill alexa-skills-kit alexa-voice-service alexa-slot
在使用Alexa技能套件测试我的交互模型时,我发现了一些奇怪的东西.
我定义了一个自定义插槽类型,如下所示:
CAR_MAKERS Mercedes | BMW | Volkswagen
Run Code Online (Sandbox Code Playgroud)
我的意图计划是这样的:
{
"intents": [
{
"intent": "CountCarsIntent",
"slots": [
{
"name": "CarMaker",
"type": "CAR_MAKERS"
},
...
Run Code Online (Sandbox Code Playgroud)
样本话语如:
CountCarsIntent Add {Amount} cars to {CarMaker}
Run Code Online (Sandbox Code Playgroud)
现在,在开发人员控制台中进行测试时,我注意到我可以编写如下内容:
"Add three cars to Ford"
Run Code Online (Sandbox Code Playgroud)
它实际上会解析这个!即使在交互模型中从未提及"福特"!lambda请求是:
"request": {
"type": "IntentRequest",
...
"intent": {
"name": "CountCarsIntent",
"slots": {
"CarMaker": {
"name": "ExpenseCategory",
"value": "whatever"
},
...
Run Code Online (Sandbox Code Playgroud)
这真的让我感到惊讶,因为有关自定义插槽类型的文档非常清楚,插槽只能采用交互模型中列出的值.
现在,似乎值也是动态解析的!这是一个新功能,还是我错过了什么?
我正在尝试建立一个alexa自定义技能.我正面临一个问题,即我试图从用户那里得到是/否回答该技能要求用户提出的问题.
Alexa: Would you like to know the rules of the game?
User: <Can respond either Yes or No>
Run Code Online (Sandbox Code Playgroud)
根据用户响应,我想执行一个特定的操作.
这是我的意图架构:
{
"intents": [
{
"intent": "AMAZON.StopIntent"
},
{
"intent": "AMAZON.CancelIntent"
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "StartGame"
},
{
"intent": "GetRules"
}
]
}
Run Code Online (Sandbox Code Playgroud)
以下是我的示例话语:
StartGame Begin the game
StartGame Start the game
GetRules What are the rules
GetRules Get the rules
GetRules Tell me the rules
GetRules Tell me the rules again
Run Code Online (Sandbox Code Playgroud)
技能问用户的问题如下:
Welcome to the game. …
Run Code Online (Sandbox Code Playgroud) 我试图正确理解插槽如何以编程方式工作。在编写任何代码之前,我会通过查看适用于python的alexa sdk 的示例来尝试很好地理解它。
具体来说,我试图理解ColorPicker示例中插槽中的基础知识(我正确理解了hello_world,并通过自己添加一些东西进行了一些编码。工作正常)。
我很难理解如何访问这些插槽值(因为我看到它是通过两种不同的方式完成的)。
def whats_my_color_handler(handler_input):
"""Check if a favorite color has already been recorded in
session attributes. If yes, provide the color to the user.
If not, ask for favorite color.
"""
# type: (HandlerInput) -> Response
if color_slot_key in handler_input.attributes_manager.session_attributes:
fav_color = handler_input.attributes_manager.session_attributes[
color_slot_key]
speech = "Your favorite color is {}. Goodbye!!".format(fav_color)
handler_input.response_builder.set_should_end_session(True)
else:
speech = "I don't think I know your favorite color. " + help_text
handler_input.response_builder.ask(help_text)
handler_input.response_builder.speak(speech) …
Run Code Online (Sandbox Code Playgroud) 如何为Alexa技能创建通用插槽?因此,我可以创建自己的Todo应用程序,它将识别自由格式文本.
我正在尝试开发Alexa技能,我需要获得相对时间,例如:" 5分钟前 ".
我为我的技能定义了一个时间段,接受时间5 minutes
,6.30 am
或者4 in the morning
.但是我无法接受这样的时间5 minutes ago
.我是Alexa的新手,可以帮助我解决这个问题
{
"slots": [
{
"name": "time",
"type": "AMAZON.TIME"
}
],
"intent": "ReportTime"
}
Run Code Online (Sandbox Code Playgroud) 我想用Alexa Skill模型创建一个简单的多转对话框.我的意图包括3个插槽,每个插槽都需要满足意图.我提示每个插槽并定义所有需要的话语.
现在我想用Lambda函数处理请求.这是我对这个特定Intent的函数:
function getData(intentRequest, session, callback) {
if (intentRequest.dialogState != "COMPLETED"){
// return a Dialog.Delegate directive with no updatedIntent property.
} else {
// do my thing
}
}
Run Code Online (Sandbox Code Playgroud)
那么我将如何继续使用该Dialog.Delegate
指令构建我的响应,如Alexa文档中所述?
https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#scenario-delegate
先感谢您.
alexa-slot ×10
alexa ×8
alexa-skill ×7
aws-lambda ×2
python ×2
alexa-app ×1
amazon-echo ×1
javascript ×1
node.js ×1