我在Lex中创建了一个机器人,然后在同一个机器人中创建了两个意图 - intent1
和intent2
分别带有话语get me a taxi now
和I wan a taxi to {Location} on {TravelDate} at {TaxiTime}
({{1}中的第一个在intent1
)中的第二个。两个意图调用不同的lambda函数和lambda函数内部我访问RDS以添加出租车的预订信息。当我从Lex控制台测试两个话语中的任何一个时,lambda函数完全执行,因为我可以看到更新的数据库记录,但在Lex bot测试控制台上,我看到intent2
。在我的代码中,我有这一行:
Reached second execution of fulfillment lambda on same utterance Lex error
我的猜测是上面代码中的def delegate(session_attributes, slots):
return {
'sessionAttributes': session_attributes,
'dialogAction': {
'type': 'Delegate',
'slots': slots
}
}
def book_taxi(intent_request):
confirmation_status = intent_request['currentIntent']['confirmationStatus']
#bunch of other processing code
logger.debug('Confirmation = {}'.format(confirmation_status))
if confirmation_status == 'Confirmed':
try_ex(lambda: session_attributes.pop('confirmationContext'))
logger.debug('confirmation_context = {}'.format(confirmation_context))
if confirmation_context == 'AutoPopulate':
return elicit_slot(
session_attributes,
intent_request['currentIntent']['name'],
intent_request['currentIntent']['slots']
)
return delegate(session_attributes, intent_request['currentIntent']['slots'])
logger.debug('Booked Taxi at={}'.format(reservation))
调用引起了问题,因为在我的日志文件中,我可以看到前两个调试日志为已确认和无值,但最后一个logger.debug()不在日志文件,这意味着delegate()被调用,这就是Lex控制台上的错误。
此错误可能出现的问题是什么?
答案 0 :(得分:-1)
您的话语可能包含调用多个意图的文本。 这就是问题产生的原因。 你可以在两个意图中查出两个相似类型的话语中的一个。