alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.12k stars 736 forks source link

SSML tags are not resolved in skill response #674

Closed laurenschneider closed 3 years ago

laurenschneider commented 3 years ago

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release) [X ] Bug report
[ ] Performance issue [ ] Feature request [ ] Documentation issue or request [ ] Other... Please describe: ResponseBuilder.speak() does not process SSML tags.

Expected Behavior

When returning a response that includes SSML tags, the spoken output applies those tags.

return handlerInput.responseBuilder .speak(Alexa.escapeXmlCharacters('Hello \ fellow Alexa developers')) .getResponse();

Hello fellow Alexa developers

Current Behavior

The SSML tags are spoken as part of the response string

return handlerInput.responseBuilder .speak(Alexa.escapeXmlCharacters('Hello \ fellow Alexa developers')) .getResponse();

The response spoken by Alexa says the tags out loud as though they were part of the response. Hello <break time='1s'/> fellow Alexa developers

Your Environment

ASK SDK for Node.js used: 2.9.0 ASK SDK CORE: 2.9.0 ASK SDK MODEL: 1.34.1

ShenChen93 commented 3 years ago

Hi @laurenschneider Thanks for using our SDK ! The util function escapeXmlCharacters is used to escapse XML Characters. For normal SSML string, you could directly pass it to the speak function as it will automatically determine if it's a plainText or SSML string. Thus you could fix your code by follwing change:

return handlerInput.responseBuilder
.speak(`Hello <break time='1s'/> fellow Alexa developers`)
.getResponse();

Let me know if it fix your issue :)

Thanks, Shen