AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Need help using successor code…..Need to stop looping and give each response only ONCE to a user, not loop
 
 

Hi guys,

I need help with the code below….I need to know how to only deliver the responses only ONCE to a user, and to not loop…..?? Is there a way of doing that ? It’s kinda causing havoc with things !  ...... Also, I need to know if it is possible to delay each response and add a sleep command to each response ? If there is such a thing ......

<aiml version=“1.0”>


<category>
*</pattern>
<template>

<think>
<set name=“state”>
<srai>SUCCESSOR <get name=“state”></srai>
</set>
</think>
<srai>say response <get name=“state”></srai>

</template>
</category>

<category>SUCCESSOR</pattern>
<template>I</template>
</category>
<category>SUCCESSOR *</pattern>
<template>I</template>
</category>
<category>SUCCESSOR I</pattern>
<template>II</template>
</category>
<category>SUCCESSOR II</pattern>
<template>III</template>
</category>
<category>SUCCESSOR III</pattern>
<template>IV</template>
</category>
<category>SUCCESSOR IV</pattern>
<template>I</template>
</category>

<category>
SAY RESPONSE I</pattern>
<template>Response One.</template>
</category>

<category>
SAY RESPONSE II</pattern>
<template>Response Two.</template>
</category>

<category>
SAY RESPONSE III</pattern>
<template>Response Three.</template>
</category>

<category>
SAY RESPONSE IV</pattern>
<template>Response Four.</template>
</category>

<category>
SAY RESPONSE *</pattern>
<template>Undefined.</template>
</category>

</aiml>

 

 
  [ # 1 ]

What do you want the category to do once it reaches the end of its response list if it doesn’t loop? Just use the last response all the time?

I don’t know what you mean by a sleep command. Are you wanting the bot not to reply as fast to each user input?

 

 
  [ # 2 ]

Hi Steve, thanks for replying smile  I want each user to only receive each response one time and not loop on them, is that possible? ...... And yes I want to delay response time to each user basically…...I saw this thread after googling…

http://www.iniy.org/?p=68

they talk of implementing delay ,but using Python or Pyaiml. This bot is Skype based linking to Pandorabots via the Clownfish plugin…...Is there a way to use Pyaiml and still link to Pandorabots! ??

 

 
  [ # 3 ]

To stop it looping just change:

<category>SUCCESSOR IV</pattern>
<
template>I</template>
</
category

to

<category>SUCCESSOR IV</pattern>
<
template>IV</template>
</
category

Then it won’t reset back to I.

However, your code is very messy and a lot longer than it needs to be. I would suggest using this single category to achieve the same result instead of the eleven categories you propose above:

<category>
    <
pattern>SEQUENTIAL RESPONSES</pattern>
    <
template>
        <
condition name="seqno">
            <
li value="1"><think><set name="seqno">2</set></think>Response 2</li>
            <
li value="2"><think><set name="seqno">3</set></think>Response 3</li>
            <
li value="3"><think><set name="seqno">4</set></think>Response 4</li>
            <
li value="4">Response 5</li>
            <
li><think><set name="seqno">1</set></think>Response 1</li>
        </
condition>
    </
template>
</
category

This will display:

Response 1
Response 2
Response 3
Response 4
Response 5
Response 5
Response 5
...
...
...

There is no way in native AIML to cause a delay in the response time and you will have to do this client side. Sorry, I don’t know about Clownfish or Pyaiml

 

 
  [ # 4 ]

Wow that is just what I needed thanks Steve smile  So that code snippet can replace the whole lot then? That looks way more efficient I gotta say . I guess the delay thing isnt essential , I will see what I can work out….

 

 
  [ # 5 ]

Yes you can just use the one category I wrote above. It can be expanded to use as many responses as you need. As an exercise, if you want the responses to loop, you just need a couple of tweaks:

<category>
    <
pattern>SEQUENTIAL RESPONSES</pattern>
    <
template>
        <
condition name="seqno">
            <
li value="1"><think><set name="seqno">2</set></think>Response 2</li>
            <
li value="2"><think><set name="seqno">3</set></think>Response 3</li>
            <
li value="3"><think><set name="seqno">4</set></think>Response 4</li>
            <
li value="4"><think><set name="seqno">0</set></think>Response 5</li>
            <
li value="0"><think><set name="seqno">1</set></think>Response 1</li>
            <
li><think><set name="seqno">1</set></think>Response 1</li>
        </
condition>
    </
template>
</
category
 

 
  [ # 6 ]

Ok, I just tried it out, but now the last response gets repeated…..:/  Is it poss to finish the sequence, and then go silent no matter what the user sends…....

 

 
  [ # 7 ]

Sure. Try changing:

<li value="4">Response 5</li

to:

<li value="4"><think>blank response</think></li

 

 

 
  [ # 8 ]

Ok, and for the record what would it be to change the OLD code to that at the end….

 

 
  [ # 9 ]

Actually could you give me the complete new code because I can’t quite work out where you mean to put the new line !

 

 
  [ # 10 ]

Here you go:

<category>
    <
pattern>SEQUENTIAL RESPONSES</pattern>
    <
template>
        <
condition name="seqno">
            <
li value="1"><think><set name="seqno">2</set></think>Response 2</li>
            <
li value="2"><think><set name="seqno">3</set></think>Response 3</li>
            <
li value="3"><think><set name="seqno">4</set></think>Response 4</li>
             <
li value="4"><think>blank response</think></li>  
            <
li><think><set name="seqno">1</set></think>Response 1</li>
        </
condition>
    </
template>
</
category

To change your old code to do the same, you would need to replace 2 categories with these amended ones:

<category>SUCCESSOR IV</pattern>
<
template>IV</template>
</
category>

<
category>
SAY RESPONSE IV</pattern>
<
template><think>blank response</think></template>
</
category
 

 
  [ # 11 ]

Arrrghh i’m getting so confused lol…..What is the new code with the code for the wildcard * expected? Because that needs to be in there, to respond and start the sequence no matter what the user says…....Currently I just get I have no answer for that each response…..

 

 
  [ # 12 ]

If you want the responses to be said no matter what the user says, change:

<pattern>SEQUENTIAL RESPONSES</pattern

to

<pattern>_</pattern
 

 
  [ # 13 ]

That’s it ! Finalized and working ! smile Thanks so much . I owe you a drink or two Steve haha . You’ve made my day :D

 

 
  [ # 14 ]

No problem! Always happy to help.

Just bear in mind that if you have ANY other categories apart from this one, they will not be called as we used the underscore wildcard which overrides everything else. You could try changing it to * if you have more categories than this.

 

 
  [ # 15 ]

No it’s ok , I will leave it exactly as it is now and wont go screwing with it any more lol smile

 

 1 2 3 > 
1 of 3
 
  login or register to react