我创建了一个custom alexa skill
,其中我有intent
,名为intentone
,此意图有2 slots
- slotone
和{{1} }。调用此intent时,它会调用slottwo
python
。现在,从lambda function
python
我想lambda function
elicitSlot
的价值,用户提供回复,然后slotone
elcitSlot
。
我编写了这段代码,它只是在调用intent之后向用户发送静态响应,而我无法将slottwo
添加到此:
elicitSlot
我在python中查找了##############################
# Builders
##############################
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
def build_PlainSpeech(body):
speech = {}
speech['type'] = 'PlainText'
speech['text'] = body
return speech
def build_response(message, session_attributes={}):
response = {}
response['version'] = '1.0'
response['sessionAttributes'] = session_attributes
response['response'] = message
return response
##############################
# Responses
##############################
def conversation(title, body, session_attributes):
speechlet = {}
speechlet['outputSpeech'] = build_PlainSpeech(body)
speechlet['shouldEndSession'] = False
return build_response(speechlet, session_attributes=session_attributes)
def statement(title, body):
speechlet = {}
speechlet['outputSpeech'] = build_PlainSpeech(body)
speechlet['shouldEndSession'] = True
return build_response(speechlet)
##############################
# Custom Intents
##############################
def intentone(event, context):
session_attributes = {}
respnse = "Would you like to order a large or regular"
return conversation("order_size", respnse,session_attributes)
##############################
# Required Intents
##############################
def cancel_intent():
return statement("CancelIntent", "You want to cancel") #don't use CancelIntent as title it causes code reference error during certification
def help_intent():
return statement("CancelIntent", "You want help") #same here don't use CancelIntent
def stop_intent():
return statement("StopIntent", "You want to stop") #here also don't use StopIntent
##############################
# On Launch
##############################
def on_launch(event, context):
return statement("title", "body")
##############################
# Routing
##############################
def intent_router(event, context):
logger.debug("EVENT REQUEST RECEIVED = {}".format(event))
intent = event['request']['intent']['name']
# Custom Intents
if intent == "intentone":
return intentone(event, context)
# Required Intents
if intent == "AMAZON.CancelIntent":
return cancel_intent()
if intent == "AMAZON.HelpIntent":
return help_intent()
if intent == "AMAZON.StopIntent":
return stop_intent()
##############################
# Program Entry
##############################
def lambda_handler(event, context):
if event['request']['type'] == "LaunchRequest":
return on_launch(event, context)
elif event['request']['type'] == "IntentRequest":
return intent_router(event, context)
个例子,但找不到一个。大多数示例都显示了此link中elicitSlot
的{{1}}示例。
如何在python lambda函数中实现Node.js
。一个简单的例子有助于了解它
答案 0 :(得分:-2)
您好,您将不得不使用对话框功能。不幸的是我现在没有任何例子。请谷歌