In AIML how to make bot recognize user's birthday by looking at the calender date? i am trying to build an function in aiml which will store variable of user's birthday and on the birth date the bot should wish happy birthday to user by checking date by using "date" tag.
This is my code looks like
<category>
<pattern>MY BIRTHDAY IS ON <set>day</set> <set>month</set></pattern>
<template>Ok!
<think>
<set name="day"><star index="1" /></set>
<set name="getday"><date format="%d"/></set>
<set name="month"><star index="2" /></set>
<set name="getmonth"><date format="%B"/></set>
<set name="checkbirthday"><get name="getday"/><get name="getmonth"/></set>
</think>
</template>
</category>
<category>
<pattern>BIRTHDAYCHECK</pattern>
<template>
<think>
<set name="checkbday"><date format="%d %B"/></set>
<set name="checkbday">checkbirthday</set>
</think>
<condition name="checkbday">
<li value="checkbirthday">Happy birthday</li>
<li>No its not your birthday today</li>
</condition>
</template>
</category>
if i told my bot on 7th nov that my bday is on 7 nov then it just works okay
HUMAN: My birthday is on 7 november
ROBOT: Okay!
HUMAN: BIRTHDAYCHECK
ROBOT: Happy birthday
But if i told my bot on 7th nov that my bday is on 5 nov then it outputs same message
HUMAN: My birthday is on 5 november
ROBOT: Okay!
HUMAN: BIRTHDAYCHECK
ROBOT: Happy birthday
I was expecting this output
(on 7th nov)
HUMAN: My birthday is on 5 november
ROBOT: Okay!
HUMAN: BIRTHDAYCHECK
ROBOT: No its not your birthday today
How would the bot check date and wishes happy birthday on birth date? I am so confused at this moment!
Your code will always say Happy birthday, as you are setting a predicate called checkbday
with a value of checkbirthday
and then seeing if it equals checkbirthday
, which of course it always will do.
Try this instead. You may need to modify it to work with your sets.
<category>
<pattern>MY BIRTHDAY IS ON * *</pattern>
<template>
Ok!
<think>
<set name="birthday"><star/> <star index="2"/></set>
</think>
</template>
</category>
<category>
<pattern>BIRTHDAYCHECK</pattern>
<template>
<think>
<set name="checkbday"><date format="%e %B"/></set>
</think>
<condition name="birthday">
<li><value><get name="checkbday"/></value>Happy birthday</li>
<li>No its not your birthday today</li>
</condition>
</template>
</category>