I am using VoiceXmlDialogueFactory to create some Dialogue's. I wonder how I can check which is the class name configured in the Dialog (in web.xml) so I don't have to create a DialogueFactory class for every Dialog and I can just if/then in the create method. I've checked that method:
public VoiceXmlDialogue create(DialogueInitializationInfo<VoiceXmlInputTurn, VoiceXmlOutputTurn, VoiceXmlDialogueContext> initializationInfo) throws DialogueFactoryException {
But didn't find where to get the com.nuecho.rivr.voicexml.dialogue.class parameter. A specific parameter I can read some other way may do the trick too.
thanks for any advice.
If I understand correctly, you want a single
DialogueFactory
class that can creates different dialogues (of differentVoiceXmlDialogue
classes) based on some external data. That's the purpose of theDialogueFactory
, really.The most straightforward way to do that is to use something in the initial HTTP request (like the parameter or the path) to determine what dialogue is to be built. You can get the HttpServletRequest by casting the
initializationInfo
parameter of theDialgueFactory.create()
into aWebDialogueInitializationInfo
. In this object, you will find additional properties that you can use to perform the required logic. You can even access the servlet context.So, using a query parameter, you can create the right kind of dialog. http://server.exemple.com/application/dialogue?type=abc
You can also use the path info: http://server.exemple.com/application/dialogue/abc
See this cookbook entry for something similar.