微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从lambda收到关于意图实现的空响应

如何解决从lambda收到关于意图实现的空响应

嗨,我正在研究lex,想在所有插槽都装满并使用相同的lambda方法进行验证和实现时实现意图,但是在实现时会出错。

An error has occurred: Invalid Lambda Response: Received null response from Lambda

我也正在使用Invocationsource进行相应的处理,但是我不知道自己在做什么错。我在这里附加代码,请帮忙。

代码是python语言。

import json


def flightDecision(source,Departure_city,Arrival_city,ReturnDate,Departing,Date,Flight_schedule):
    if source == 'DialogCodeHook':
        if Departing == "roundtrip" and Date == None:
            return{
                "dialogAction": {
                    "type": "ElicitSlot","slottoElicit": "Date","intentName": 'Bookaflight',"slots": {
                        "Departure_city": Departure_city,"Arrival_city": Arrival_city,"Departing": Departing,"Date": Date,},}
            if Departing == 'roundtrip' and Date != None and ReturnDate == None:
                return{
                    "dialogAction": {
                        "type": "ElicitSlot","slottoElicit": "ReturnDate","slots": {
                            "Departure_city": Departure_city,"ReturnDate": ReturnDate,}
    if Departing == 'roundtrip' and ReturnDate != None and Flight_schedule == None:
        return{
            "dialogAction": {
                "type": "ElicitSlot","slottoElicit": "Flight_schedule","slots": {
                    "Departure_city": Departure_city,"Flight_schedule": Flight_schedule
                },}
    if Departing == "oneway" and Date == None:
        return{
            "dialogAction": {
                "type": "ElicitSlot",}
    if Departing == 'oneway' and Date != None and Flight_schedule == None:
        return{
            "dialogAction": {
                "type": "ElicitSlot","Flight_schedule": Flight_schedule,}
    if source == 'FulfillmentCodeHook':
        return{
            "dialogAction":{
                "type": "ConfirmIntent","intentName": "Bookaflight","slots":{
                    "Departure_city": Departure_city,"message":{
                         "contentType": "PlainText","content": "you want to book a ticket"
                     }
                }
            }


def delegate(currSlots,Arrival_city):
    return{
        'dialogAction': {
            'type': 'Delegate','slots': currSlots
        }
    }


def lambda_handler(event,context):
    source = event['invocationSource']
    currName = event['currentIntent']['name']
    currSlots = event['currentIntent']['slots']
    Departing = event['currentIntent']['slots']['Departing']
    ReturnDate = event['currentIntent']['slots']['ReturnDate']
    Arrival_city = event['currentIntent']['slots']['Arrival_city']
    Departure_city = event['currentIntent']['slots']['Departure_city']
    Date = event['currentIntent']['slots']['Date']
    Flight_schedule = event['currentIntent']['slots']['Flight_schedule']
    print("rohmamababafibabana",Flight_schedule)
    while not Departing:
        print("hello man")
        return delegate(currSlots,Arrival_city)
    else:
        print("hello boy")
        return flightDecision(source,Flight_schedule)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。