Communicating Between Workflow and VXML

April 01, 2010

When working with the VoiceXML Interpreter Activity the simple act of passing data between your Workflow and your VXML applications can be tricky to figure out. Hopefully this post will save someone the time I spent scratching my head the first time around. Passing Data In Lets say I want to pass “The dog is brown” to my VXML application so that is can in turn relay this very vital information to the caller. Prior to VXML activity I’ll drop a Code activity with the following in its ExecuteCode method:


VXML.ApplicationData.Add("PassedInVar", "The dog is brown");

To access this data from within my VXML application I’ll need to reference both my variable name and the ApplicationData collection itself. For example:


<block>
  <prompt>
    <value expr="ApplicationData['PassedInVar']" />                
  </prompt>            
</block>

Passing Data Out

VoiceXML has a standard method of passing data out of an application using the <exit> tag (<exit namelist=”SomeVar”/>).  Variables passed back via the “namelist” are stored as a Dictionary object in the ApplicationData collection.

Inside my VoiceXML application I’ll declare a Var and return it in my <exit> tag.


<block> 
    <prompt> 
        <value expr="ApplicationData['PassedInVar']" />                
    </prompt> 
    <var name="ReturnedVar" expr="'The cat is black'" />        
    <exit namelist="ReturnedVar"/> 
</block>

Once back in the Workflow I’ll extract the data from the ApplicationData collection’s $exit element. I’ll drop a Code activity after the VXML activity with following in its ExecuteCode method: