Last active
February 15, 2022 17:41
-
-
Save rmtuckerphx/b1cd71edfe652041cec34fc1701c0d22 to your computer and use it in GitHub Desktop.
Jovo v4 RepeatIntent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More information in the Jovo Docs: https://www.jovo.tech/docs/data#example--repeat