Alexa-skills-kit-sdk-for-nodejs: Filtering/escaping characters?

Created on 25 Feb 2018  路  6Comments  路  Source: alexa/alexa-skills-kit-sdk-for-nodejs

Ho to correctly filter/escape characters for Alexa? I am having some problems with an equal sign:

Fatal error occurred when processing SSML content. This usually happens when the SSML is not well formed. Error: Unexpected character '=' (code 61); expected a semi-colon after the reference for entity 'referrerSource'

Most helpful comment

@nikhilym Thank you for pointing me to that PR. It looks like that does solve my problem! Note that in v2.5.1 the behavior of that PR was removed from being default, so as a developer we have to call that utility method ourselves:

return handlerInput.responseBuilder
      .speak(Alexa.escapeXmlCharacters(speakOutput))
      .getResponse();

All 6 comments

Hi @dealancer ,

Have you tried using a library for building a SSML response, instead of building them by hand? So that you could avoid chracter escaping problems. Otherwise, just see the escaping rules in XML documents.

Since there is no response here, I'm closing this issue for now. Please feel free to reopen it if you encounter further issues.

@benedekh, @TianTXie, sorry for late reply.

I have not used SSML library for building a response. I am building it by hand and sometimes I want Alexa to read text that I do not control (e.g. RSS feeds).

I think either Alexa SDK should take care of escaping characters, or it should be clearly stated in the documentation that all responses should be escaped.

I am getting this error too - would be nice if escaping automatically were an option. ssml-builder library does not appear to be maintained.

(PS - related/duplicate of #25 and https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues/472#issuecomment-459779174 ?)

Hey @gavinr , @dealancer , #522 added support for auto-escaping XML characters feature in the SDK. Does this align with the use-case you were trying? If not, please feel free to open a new issue on the repo so that we can investigate into it further.

@nikhilym Thank you for pointing me to that PR. It looks like that does solve my problem! Note that in v2.5.1 the behavior of that PR was removed from being default, so as a developer we have to call that utility method ourselves:

return handlerInput.responseBuilder
      .speak(Alexa.escapeXmlCharacters(speakOutput))
      .getResponse();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

z4o4z picture z4o4z  路  3Comments

developer170883 picture developer170883  路  4Comments

talkingnews picture talkingnews  路  5Comments

seanfisher picture seanfisher  路  5Comments

mehtanilay10 picture mehtanilay10  路  6Comments