Using an ampersand in a response causes an error:
this.emit(':tell', "Some amount of text with an & character");
Gives the following error when invoked via Lambda:
Invalid SSML Output Speech for requestId amzn1.echo-api.request.8ad916fa-2f18-44db-95df-25569d049500. Error: Fatal error occured when processing SSML content. This usually happens when the SSML is not well formed. Error: Unexpected character \' \' (code 32) (missing name?)\n at [row,col {unknown-source}]: [1,94]
Although the error message says it is a code 32 character (a space) that is the problem, the error disappears after replacing the & with and.
This is because this SDK is using SSML, and "&" character is not supposed in SSML. It is expecting a tag.
@KrishFuriaAmazon Thanks for the info. Does the SDK provide any utilities to escape text into an SSML-compatible string?
No, currently there is no utilities available in SDK to escape character. You will have to manually replace before emitting with that string.
For anyone facing this challenge, I recommend looking at ssml-builder on npm
As of 2019, if you're not using ssml-builder, you can use the ssmlUtils.escapeXmlCharacters() utility method. (more info)
Most helpful comment
For anyone facing this challenge, I recommend looking at ssml-builder on npm