0

In my python webhook, I am returning JSON response as-

   {
     "speech":"Speak this",
     "ssml": <speak><audio src="[link to a mp3 file]"></audio></speak>,
     "displayText": "Expected text",
     "contextOut": [],
     "source": ""
   }

However, what I get in DialogFlow from "Show JSON" is-

  "fulfillment": {
      "speech": "Speak this",
      "source": "",
      "displayText": "Expected text",
      "messages": [
        {
          "type": 0,
          "speech": "Speak this"
        }
      ]
    }

Here, the response got no SSML key. Also, if I remove the "speech" key from my program, I get this error in Google assistant test app, MalformedResponse expected_inputs[0].input_prompt.rich_initial_prompt.items[0].simple_response: 'text_to_speech' or 'ssml' must be set.

Please help!

ANSWER

"speech":'<speak><audio src="[link to a mp3 file]"></audio></speak>'

Did the trick

Prisoner
  • 49,922
  • 7
  • 53
  • 105
S4rt-H4K
  • 109
  • 6

1 Answers1

0

As I think you might have realized in your answer, there are two issues

  1. The field name is "speech", not "ssml".
  2. You weren't providing a JSON string in your reply.

Real JSON requires that the string be a double-quote, not a single quote (although it seems Dialogflow's parser is being lenient), so it should have been:

   {
     "speech": "<speak><audio src='[link to a mp3 file]'></audio></speak>",
     "displayText": "Expected text",
     "contextOut": [],
     "source": ""
   }
Prisoner
  • 49,922
  • 7
  • 53
  • 105