VoxaAI/voxa

Reply and Directive re-work

Closed this issue · 0 comments

In order to reduce the coupling between replies and directives, we'll re-work replies to be more specific to their platform, and directives to own their own mutation logic.

Things that aren't working on in the existing system

  • In Alexa, the directive sets the card object on the reply, but the reply has to know to pick that up for the output
  • Same for alexa say
  • Same for reprompt in Alexa
  • In Google Home, knowledge about how to add a suggestion is in the DialogFlowAdapter rather than the directive
  • All of this is an indication that directives and replies are over-coupled

Reply become as close as possible to their underlying platform representation

The first step in this change is to re-write replies. Instead of replies having a generic representation, then being serializable to their platform's representation, we'll have the reply actually hold their platform's representation in them. That means that the AlexaReply will look like a partially built Alexa response, and the DialogFlowReply will hold the RichResponse as a core member variable, rather than just in it's render step.

This means that well clear out the VoxaReply object of any common base-class implementation, since there will no longer be an intermediate representation between the reply and it's actual end representation to the platform. The purpose of this is to make it easier for directives to be able to write their effects into the reply. The VoxaReply base class will now become an interface. However, since speech is so general across all the platforms, the interface will have operations that allow generic access to speech, mostly for use by plugins.

Directive modifications

Directives need to do two things:

  1. Build themselves based on their paramters
  2. Write themselves to the underlying platform's reply

To do this, directives will be represented as a function, that returns an implementor of the IDirective interface. The implementors of the class will specify as a member variable the platform that this directive applies to. Directive rendering will ignore directives not intended for their platform. Again, "core" will apply to all platforms.

The IDirective will have a single method on it called writeToReply(voxaReply, transition) that will allow the directive to either modify the voxaReply, or add new directives to the transition if it is a meta-directive. This is where the DialogFlow.Suggestion directive would call voxaReply.richResponse.addSuggesion.