Alexa-skills-kit-sdk-for-nodejs: Ampersand (&) in Response Causes Error

Created on 13 Oct 2016  路  5Comments  路  Source: alexa/alexa-skills-kit-sdk-for-nodejs

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.

Most helpful comment

For anyone facing this challenge, I recommend looking at ssml-builder on npm

All 5 comments

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dillonharlessNHRMC picture dillonharlessNHRMC  路  6Comments

captnCC picture captnCC  路  6Comments

oprog picture oprog  路  6Comments

z4o4z picture z4o4z  路  3Comments

lostvicking picture lostvicking  路  4Comments