Speechbuilder - pre-configured elements - Type Error - Not a function

google-assistant

#1

Here is use case

  • In Launch, add Welcome prompt to pre configured speech builder element - this.$speech
  • redirect to HelloWorldIntent
  • Try adding text to speech in this intent - this.$speech.addText

Throws an error. Tried doing this.$speech.addText in the LAUNCH itself - same error

Seems like the pre configured speech builder element is not initialised completely.

Blockquote

app.setHandler({
LAUNCH() {
this.$speech = “hello”;

this.$speech.addText('Welcome again');

return this.toIntent('HelloWorldIntent');

},

HelloWorldIntent() {
this.ask(this.$speech);

},

});

Even this has same issue

app.setHandler({
LAUNCH() {
this.$speech = “hello”;
return this.toIntent(‘HelloWorldIntent’);
},

HelloWorldIntent() {
this.$speech.addText(‘Welcome again’);
this.ask(this.$speech);

},

});

Blockquote

indent preformatted text by 4 spaces

Error -----------------------------------------------------------------

Message:
this.$speech.addText is not a function

Stack:
TypeError: this.$speech.addText is not a function
at GoogleAction.LAUNCH (/dev/voiceapps/src/app.js:40:18)
at Function.applyHandle (/dev/voiceapps/node_modules/jovo-core/src/plugins/Handler.ts:179:35)
at handle (/dev/voiceapps/node_modules/jovo-core/src/plugins/Handler.ts:241:19)
at Middleware.run (/dev/voiceapps/node_modules/jovo-core/src/core/Middleware.ts:85:11)
at App.handle (/dev/voiceapps/node_modules/jovo-core/src/core/BaseApp.ts:274:7)
at App.handle (/dev/voiceapps/node_modules/jovo-framework/src/App.ts:333:5)
at /dev/voiceapps/src/index.js:20:5


#2

Found the issue

I had been doing

this.$speech = “hello”;

followed by

this.$speech.addText(‘Welcome again’);

One should be adding text only via this.$speech.addText and not assign directly this.$speech

Using this.$speech.addText to add text works