问题描述
嗨,我正在研究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 (将#修改为@)