stackjohnny
stackjohnny

Reputation: 795

ssml in Dialogflow webhook

This is not a duplicate question, I didn't get the exact response so raised a new question here..

Getting an issue while writing ssml tags in the webhook response.

Earlier my webhook response:

{fulfillmentText: 'Amount for Invoice : TEST is $300'} - it is working fine with all the interfaces i.e. Web, Google Assistant

now I want to use ssml, so I tried updating the response in webhook to

{"speech":"<speak>Amount for Invoice : TEST is $300<speak>","displayText":"Listen Voice.."}

This is erroring out in the Dialogflow side as I think it is not able to read the response. Any help?

Note: I am using Google Cloud Function to send the response back to Dialogflow engine:

res.send(JSON.stringify({ 'fulfillmentText': output }));

Upvotes: 0

Views: 946

Answers (1)

Filip Kwiatkowski
Filip Kwiatkowski

Reputation: 665

You should change speech key in json to ssml. See example below (source):

{  
   "payload":{  
      "google":{  
         "expectUserResponse":true,
         "richResponse":{  
            "items":[  
               {  
                  "simpleResponse":{  
                     "ssml":"<speak>Here are <say-as interpret-as=\"characters\">SSML</say-as> samples. I can pause <break time=\"3\" />. I can play a sound <audio src=\"https://actions.google.com/sounds/v1/alarms/winding_alarm_clock.ogg\">your wave file</audio>. I can speak in cardinals. Your position is <say-as interpret-as=\"cardinal\">10</say-as> in line. Or I can speak in ordinals. You are <say-as interpret-as=\"ordinal\">10</say-as> in line. Or I can even speak in digits. Your position in line is <say-as interpret-as=\"digits\">10</say-as>. I can also substitute phrases, like the <sub alias=\"World Wide Web Consortium\">W3C</sub>. Finally, I can speak a paragraph with two sentences. <p><s>This is sentence one.</s><s>This is sentence two.</s></p></speak>",
                     "displayText":"This is a SSML sample. Make sure your sound is enabled to hear the demo"
                  }
               }
            ]
         }
      }
   }
}

Upvotes: 1

Related Questions