Hi everyone,
we had an interesting topic in the Jovo Developer Slack today and I wanted to continue the conversation here in the forum to prevent it from going down in a giant thread.
@Nic wants to create a plugin similar to the GoogleSheetsCMS integration, as some kind of rule engine (please correct me if I’m wrong @Nic ). His plugin implementation works so far, but he needed some help as to how to access the values like in the sheets integration with this.$cms.t()
.
Here is the conversation: https://jovodevs.slack.com/archives/C82DKJ7T5/p1554635124048800
So, @Nic, to continue our thread, as I mentioned, you need to dig deeper into the framework for this.
$cms
is an attribute registered on both Jovo.ts
and BaseApp.ts
in /jovo-core
. Jovo.ts
exports an abstract class Jovo
, which is extended by the various platform classes (like AlexaSkill.ts
). The $cms
object in Jovo
is also the object that you call with this.$cms
in your skill logic. In the GoogleSheetsCMS plugin you can see the values from parse()
(which essentially makes all sheet values accessible) being registered to handleRequest.app.$cms
, which means that the values are assigned to the $cms
object on BaseApp
, which then are copied to the Jovo.$cms
object. This happens in BaseCmsPlugin.ts
in copyCmsDataToContext()
.
So, depending on what you want to achieve with your plugin, you could register a new attribute to the Jovo
class, for example $cmsRules
, assign all the values to this object in your plugin and then try to access it in an example project with this.$cmsRules
. I hope that clarifies things a bit.
I’m looking forward to hearing your ideas and opinions!