Search code examples
ibm-cloudibm-watson

What is the proper way to integrate server-side code with IBM's dialog api?


I want to integrate my web application with IBM's dialog api. Basically, I want to sometimes send the pure text result from the IBM dialog API, as I set it up in the XML, and other times, such as when the user wants a dynamic response, which might involve me querying a database to find an account balance, for example. My current thought is to include some sort of syntax in my dialog XML which I can parse to know if the response from the conversation requires me to change it. I was thinking of something like:

<input>
    <grammar>
        <item>What is my account balance?</item>
    </grammar>
    <output>
        <prompt selectionType="RANDOM">
        <item>{ACTION_GETBALANCE}</item>
        </prompt>
    </output>
</input>

So if I got a response like {ACTION_***} I would take my own action. Is this an appropriate way of doing this? Is there another way which might be better?


Solution

  • This is indeed the recommended method

    see for example line 1358 on the movie application demo dialog file provided on WDC git repo

    <prompt selectionType="RANDOM">
      <item>"{Search_Now:"{Search_Now}", Recency:"{Recency_Preference}", Rating:"{Certification_Preference}", Genre:"{Genre_Preference}", Index:"{Current_Index}", Page:"{Page}"}"</item>
    </prompt>