Search code examples
chatchatbotaimlpandorabots

How to handle multiple questions within one utterance?


Sample:

User: How old are you and where do you live ?
Alice: I'm 7 months old. I live on earth.

My try:

<category>
    <pattern>WHERE DO YOU LIVE</pattern>
    <template>I live on earth.</template>
</category>

<category>
    <pattern>HOW OLD ARE YOU</pattern>
    <template>I'm 7 months old.</template>
</category>

The above AIML code can only reply if I ask the two questions separately.


Solution

  • By digging into AIML syntax, I finally found a solution with the <srai> tag:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE inline_dtd[
    <!ENTITY nbsp "&#160;">
    ]>
    <aiml version="2.0">
        <category>
            <pattern>WHERE DO YOU LIVE</pattern>
            <template>I live on earth.</template>
        </category>
    
        <category>
            <pattern>HOW OLD ARE YOU</pattern>
            <template>I'm 7 months old.</template>
        </category>
    
        <category>
            <pattern>HOW OLD ARE YOU AND WHERE DO YOU LIVE</pattern>
            <template>
                <srai>HOW OLD ARE YOU</srai>
                &nbsp;
                <srai>WHERE DO YOU LIVE</srai>
            </template>
        </category>
    </aiml>