1

我在 Lex 中创建了一个机器人,然后在同一个机器人中创建了两个意图 -intent1并分别intent2使用话语get me a taxi nowI wan a taxi to {Location} on {TravelDate} at {TaxiTime}(第一个在 中intent1,第二个在 中intent2)。这两个意图都调用了不同的 lambda 函数和内部 lambda 函数,我访问 RDS 以添加出租车的预订信息。当我从 Lex 控制台通过说两个话语中的任何一个进行测试时,lambda 函数完全执行,因为我可以看到数据库记录已更新,但在 Lex 机器人测试控制台上我看到了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))

我的猜测是delegate()上面代码中的调用导致了问题,因为在我的日志文件中,我可以看到前两个调试日志为 Confirmed 和 None 值,但最后一个 logger.debug() 不在日志文件中,这意味着 delegate()被调用,这导致 Lex 控制台出错。

此错误可能是什么问题?

4

1 回答 1

1

您的话语可能包含调用多个意图的文本。这就是提出问题的原因。您在两个意图中都检查了 uttrance,并从两个相似类型的话语中删除了一个。

于 2017-07-11T09:21:41.427 回答