0

I am attempting to implement the Built-In YesIntent and NoIntent...

HelpIntent works, and I've copied the Function I call for the HelpIntent and just customizing it i.e:

HelpIntent function (NOTE - this works) :

def get_help_response():

session_attributes = {}
card_title = "Help"
speech_output = "<speak>You can say something like ... </speak>"

caption = None
sm_img = None
lg_img = None
reprompt_text = "You can say something like ...."
should_end_session = False
return build_response(session_attributes, build_speechlet_response(
    card_title, speech_output, caption, sm_img, lg_img, reprompt_text, should_end_session))

I do the same exact thing for YesIntent and NoIntent function but customize the answer a bit:

def get_yes_response():

session_attributes = {}
card_title = "Yes"
speech_output = "<speak> Yes response speech output</speak>"

caption = None
sm_img = None
lg_img = None
reprompt_text = "Yes response speech output."
should_end_session = False
return build_response(session_attributes, build_speechlet_response(
    card_title, speech_output, caption, sm_img, lg_img, reprompt_text, should_end_session))

Whenever I test "Yes" or "No" - I can see that the Intent is correctly identified and Lambda attempts to come back with a response but I get the following error:

An error occurred during JSON serialization of response: <function get_yes_response at 0x7f4743de0848> is not JSON serializable 

Traceback (most recent call last): File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps sort_keys=sort_keys, **kw).encode(obj) 

File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode return _iterencode(o, 0) 

File "/var/runtime/awslambda/bootstrap.py", line 41, in decimal_serializer raise TypeError(repr(o) + " is not JSON serializable") 

TypeError: <function get_yes_response at 0x7f4743de0848> is not JSON serializable

I dont see why there would be a problem with the JSON. Any idea what's going on here?

SamYoungNY
  • 6,444
  • 6
  • 26
  • 43
  • 2
    It looks like you returned or tried to JSON encode `get_yes_response` instead of `get_yes_response()`. Is there more code we can see? – Alex Hall May 20 '16 at 18:56
  • you were right - i forgot to add the `()` where I called the functions. thanks! If you'd like to write this as an answer I'll "check" it as correct. – SamYoungNY May 23 '16 at 17:13
  • We just started a project [bstpy](https://github.com/bespoken/bstpy) to expose a Python lambda as an http service. You may find it useful for testing. You can throw json payloads at it with curl or postman. If you try it with other [Bespoken Tools](https://github.com/bespoken/bst) you can a have very nice development environment. – Bela Vizy Sep 30 '16 at 18:01

0 Answers0