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..

Sample AIML Code: School Events/News
 
 

Humado posted under “New to Chatbot Programming” that he is working on a bot for his school to discuss school events and news.  I am posting this sample beginning AIML script here under the AIML topic to provide him and others with a sample of how one might go about handling daily events and news in AIML without using a database and without having to maintain the AIML files daily.  The events and news can be entered ahead of time and be made “date aware” so the patterns are only matched on specific days.  To say it another way the bot will respond to the same questions with different answers depending on the date.

To use the following code create a new AIML file in pandorabots and call it “schoolnews” and cut and paste the following sample code.  You can test it under the “train” link to see it work.

Feel free to post any questions about how it works.

sample code:

<?xml version="1.0" encoding="UTF-8"?>
<aiml versi>
 
  
<
category>
<
pattern>what is today</pattern>
<
template><srai>xxsaydate</srai></template>
</
category>

<
category>
<
pattern>what is the date today</pattern>
<
template><srai>xxsaydate</srai></template>
</
category>

<
category>
<
pattern>xxsaydate</pattern>
<
template>Today is <srai>xxgetdate</srai> .</template>
</
category>

<
category>
<
pattern>xxgetdate</pattern>
<
template><date format="%m/%d/%Y "/></template>
</
category>

<
category>
<
pattern>xxget8digitdate</pattern>
<
template><date format="%m%d%Y "/></template>
</
category>

<
category>
<
pattern>what is happening today at school</pattern>
<
template><srai>xxsayschoolnews</srai></template>
</
category>

<
category>
<
pattern>what is happening at school today</pattern>
<
template><srai>xxsayschoolnews</srai></template>
</
category>

<
category>
<
pattern>what is happening at school</pattern>
<
template><srai>xxsayschoolnews</srai></template>
</
category>

<
category>
<
pattern>xxsayschoolnews</pattern>
<
template><srai>xxschoolnews <srai>xxget8digitdate</sraigeneral</srai></template>
</
category>

<
category>
<
pattern>xxschoolnews 03232017 general</pattern>
<
template>Today the school celebrates the 25th anniversary of its founding...</template>
</
category>

<
category>
<
pattern>xxschoolnews 03242017 general</pattern>
<
template>TGIF.  Today is the last day to sign up for the SAT test for April 10th.</template>
</
category>

<
category>
<
pattern>xxschoolnews 03252017 general</pattern>
<
template>It is SaturdayNothing is happening today at schoolStudents are probably sleeping in.</template>
</
category>

<
category>
<
pattern>xxschoolnews 03262017 general</pattern>
<
template>It is SundayThere are no events scheduled today.</template>
</
category>

<
category>
<
pattern>xxschoolnews 03272017 general</pattern>
<
template>Today is late start MondaySchool starts at 9am.</template>
</
category>

<
category>
<
pattern>xxschoolnews general</pattern>
<
template>I am not aware of any scheduled events today.</template>
</
category>

</
aiml
 

 
  login or register to react