Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null response from dialogAction(Python)

I am getting null response while my code is successfully working. I am not able to get response from dialogAction, i am

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'
        }
    )
like image 999
Pulkit Avatar asked Nov 30 '25 07:11

Pulkit


1 Answers

From what I understand, your code should be:

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)

Let us know if you are getting any error.

like image 148
sid8491 Avatar answered Dec 01 '25 21:12

sid8491