我的代码成功运行时,我的响应为空。我无法从dialogAction获得响应,我是
import json
import requests
def getdata(intent_name, fulfillment_state, message):
response = {
'dialogAction': {
'type': 'Close',
'intentName': intent_name,
'fulfillmentState': fulfillment_state,
'message': message
}
}
return response
def lambda_handler(event,context):
payload = {'userId':4,'type':'PARENT'}
r = requests.post("http://ec2-54-226-57-153.compute-1.amazonaws.com:8080/Tracking/rest/api", data=json.dumps(payload), headers = {'Content-Type': 'application/json','Accept': 'application/json'})
print(r.content)
getdata(
'currentIntent',
'Fulfilled',
{
'contentType': 'PlainText',
'content': 'message'
}
)
答案 0 :(得分:1)
根据我的理解,您的代码应该是:
import json
import requests
def getdata(message):
return {
'dialogAction':{
'type':'Close',
'fulfillmentState':'Fulfilled',
'message':{
'contentType':'PlainText',
'content':message
}
}
}
def lambda_handler(event, context):
payload = {'userId':4,'type':'PARENT'}
r = requests.post("http://ec2-54-226-57-153.compute-1.amazonaws.com:8080/Tracking/rest/api", data=json.dumps(payload), headers = {'Content-Type': 'application/json','Accept': 'application/json'})
print(r.content)
return getdata(r.content)
如果您收到任何错误,请告诉我们。