Skip to content

Instantly share code, notes, and snippets.

@rmtuckerphx
Last active February 15, 2022 17:41
Show Gist options
  • Save rmtuckerphx/b1cd71edfe652041cec34fc1701c0d22 to your computer and use it in GitHub Desktop.
Save rmtuckerphx/b1cd71edfe652041cec34fc1701c0d22 to your computer and use it in GitHub Desktop.
Jovo v4 RepeatIntent
import { app } from './app';
import { FileDb } from '@jovotech/db-filedb';
import { JovoDebugger } from '@jovotech/plugin-debugger';
app.configure({
plugins: [
new FileDb({
pathToFile: '../db/db.json',
storedElements: {
history: {
enabled: true,
size: 1, // Size of the this.$history array
output: true, // Store this.$output in history
},
},
}),
new JovoDebugger(),
],
});
export * from './server.express';
import { AlexaPlatform } from '@jovotech/platform-alexa';
import { App } from '@jovotech/framework';
import { GlobalComponent } from './components/GlobalComponent';
const app = new App({
components: [GlobalComponent, LoveHatePizzaComponent],
plugins: [
new AlexaPlatform({
intentMap: {
'AMAZON.StopIntent': 'END',
'AMAZON.CancelIntent': 'END',
'AMAZON.RepeatIntent': 'RepeatIntent',
}
}),
],
logging: true,
});
export { app };
import { Component, BaseComponent, Global, Handle } from '@jovotech/framework';
@Global()
@Component()
export class GlobalComponent extends BaseComponent {
@Handle({ intents: ['RepeatIntent'], prioritizedOverUnhandled: true })
RepeatPreviousMessage() {
if (this.$history.prev?.output) {
return this.$send(this.$history.prev.output);
} else {
return this.$send('Unfortunately, there is nothing to repeat.');
}
}
}
@jankoenig
Copy link

More information in the Jovo Docs: https://www.jovo.tech/docs/data#example--repeat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment