AIML Chatbot response differs at different times? - date

A separate question for the AIML bot in my previous post... How do you create a bot that responds at different times of the day? I feel like it will make him seem more "real."
I can't make heads or tails about how the date and time display actually works. I assume you'd have to fiddle with that alongside the set/get functions... but that's all I know for sure.
I would like my bot to do something like this.
TIME: Noon
USER: Hi, bot.
BOT: Good afternoon, USER! It's about lunchtime for me.
Where do I start? Thanks.

You need to check the hour and then use condition to give an appropriate response. Here's a category where the bot will respond sensibly even if someone says "Good morning" in the middle of the night
<category>
<pattern>GOOD MORNING</pattern>
<template>
<think><set name="hour"><date format="%H"/></set></think>
<condition name="hour">
<li value="00">Hello, it's more like the middle of the night than morning. How are you this morning?</li>
<li value="01">Hello, it's only just morning. How are you this morning?</li>
<li value="02">Hello and how are you this morning?</li>
<li value="03">Hello and how are you this morning?</li>
<li value="04">Hello and how are you this morning?</li>
<li value="05">Hello and how are you this morning?</li>
<li value="06">Hello and how are you this morning?</li>
<li value="07">Hello and how are you this morning?</li>
<li value="08">Hello and how are you this morning?</li>
<li value="09">Hello and how are you this morning?</li>
<li value="10">Hello and how are you this morning?</li>
<li value="11">Hello and how are you this morning?</li>
<li value="12">You're a bit late. It's lunchtime here.</li>
<li value="13">Morning?! It's the afternoon here.</li>
<li value="14">Morning?! It's the afternoon here.</li>
<li value="15">Morning?! It's the afternoon here.</li>
<li value="16">Morning?! It's the afternoon here.</li>
<li value="17">Morning?! It's nearly evening.</li>
<li value="18">Morning?! It's evening here.</li>
<li value="19">Morning?! It's evening here.</li>
<li value="20">Morning?! It's evening here.</li>
<li value="21">Morning?! It's night time here.</li>
<li value="22">Morning?! It's night time here.</li>
<li value="23">Morning?! It's night time here.</li>
</condition>
</template>

Related

Inserting temporary content within snippets in "Visual Studio Code"

Within Visual Studio Code 1.7.2, I am able to generate a quick list of HTML data with the following snippet, followed by pressing TAB...
ul>li*5>h3+div
That will generate this list...
<ul>
<li>
<h3></h3>
<div></div>
</li>
<li>
<h3></h3>
<div></div>
</li>
<li>
<h3></h3>
<div></div>
</li>
<li>
<h3></h3>
<div></div>
</li>
<li>
<h3></h3>
<div></div>
</li>
</ul>
But how can I prepopulate every <h3></h3> to say <h3>tite</h3>, and every <div></div> to say <div>content</div>?
VScode uses emmet for this, so the input text would be:
ul>li*5>h3{title}+div{content}
which will expand to:
<ul>
<li>
<h3>title</h3>
<div>content</div>
</li>
<li>
<h3>title</h3>
<div>content</div>
</li>
<li>
<h3>title</h3>
<div>content</div>
</li>
<li>
<h3>title</h3>
<div>content</div>
</li>
<li>
<h3>title</h3>
<div>content</div>
</li>
</ul>
Here's additional documentation of the Emmet abbreviation syntax

Breadcrumbs with structured data not displaying properly

I've looked at a lot of documentation but I can't figure out if the structured data should be placed on all pages? For example, I have this code on my main home page:
<ol vocab="http://schema.org/" typeof="BreadcrumbList">
<li property="itemListElement" typeof="ListItem">
Home
<span property="position" content="1"></span>
<span property="name" content="Home"></span>
</li>
<li property="itemListElement" typeof="ListItem">
About
<span property="position" content="2"></span>
<span property="name" content="About"></span>
</li>
<li property="itemListElement" typeof="ListItem">
Services
<span property="position" content="2"></span>
<span property="name" content="Services"></span>
</li>
<li property="itemListElement" typeof="ListItem">
Contact
<span property="position" content="2"></span>
<span property="name" content="Contact"></span>
</li>
</ol>
Although Google now shows all the breadcrumbs like this:
Is it a problem with my relative URLs? Should I not include the meta data for other pages that the user isn't on?

WWW::Selenium 'cant find element'

I'm having trouble with WWW::Selenium finding an href.
Here is the HTML element I'm looking for.
Sell Products
Here is the Perl code I'm using.
$sel->click('//a[contains(#href, "/auctions?organization_id=2")]');
Here is the error that WWW::Selenium is outputting.
Error requesting http://localhost:4444/selenium-server/driver/:
ERROR: Element //a[contains(#href, "/auctions?organization_id=2")] not found
Any tips/help will be greatly appreciated.
EDIT
Adding the surrounding HTML to aid in the troubleshooting.
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children">
Sell Products
</li>
</ul>
<ul class="sub-menu">
<li class="menu-item menu-item-type-custom menu-item-object-custom">
Seller Dashboard
</li>
</ul>
Instead of using hard-coded sleep I would suggest using wait_for_element_present.
my $locator = q{//a[contains(#href, "/auctions?organization_id=2")]};
$sel->wait_for_element_present($locator, $timeout)
$sel->click($locator);

Why is my http://schema.org/BreadcrumbList not validating?

I'm using schema.org microdata on my web site but I'm struggling with the BreadcrumbList as Google's structured data testing tool will not validate it. It looks correct and I can't see what's wrong.
You can click the above link to see the errors, but to summarise, Google says that the itemtype attribute has an invalid value for each of the items and also complains that the mainEntityOfPage attribute is missing from the list. I did try adding mainEntityOfPage in a meta tag but it still complained about it.
What am I doing wrong?
<ul itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li class="home" itemscope="" itemprop="itemListElement" itemtype="http://schema.org/ListItem">
<span itemprop="name">Home</span>
<span>/ </span>
<meta itemprop="position" content="1">
</li>
<li class="category3" itemscope="" itemprop="itemListElement" itemtype="http://schema.org/ListItem">
<span itemprop="name">RC Cars</span>
<span>/ </span>
<meta itemprop="position" content="2">
</li>
<li class="category10" itemscope="" itemprop="itemListElement" itemtype="http://schema.org/ListItem">
<span itemprop="name">Car Kits</span>
<span>/ </span>
<meta itemprop="position" content="3">
</li>
<li class="product">
<strong>Tamiya Lunch Box. No ESC [58347]</strong>
</li>
</ul>
The breadcrumbs must use the breadcrumb property, and put this inside another itemscope (ideally http://schema.org/WebPage). You are also missing is itemprop="breadcrumb which must be right before your itemscope.
<div class="breadcrumbs" itemscope itemtype="http://schema.org/WebPage">
<ul itemprop="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li class="home" itemscope="" itemprop="itemListElement" itemtype="http://schema.org/ListItem">
<span itemprop="name">Home</span>
<span>/ </span>
<meta itemprop="position" content="1">
</li>
<li class="category3" itemscope="" itemprop="itemListElement" itemtype="http://schema.org/ListItem">
<span itemprop="name">RC Cars</span>
<span>/ </span>
<meta itemprop="position" content="2">
</li>
<li class="category10" itemscope="" itemprop="itemListElement" itemtype="http://schema.org/ListItem">
<span itemprop="name">Car Kits</span>
<span>/ </span>
<meta itemprop="position" content="3">
</li>
<li class="product">
<strong>Tamiya Lunch Box. No ESC [58347]</strong>
</li>
</ul>

Microdata format for showing an event with multiple date/time

With Microdata, what is the best way to represent an event page with multiple date/time booking options? There will be occasions when the event page only has one booking option, i.e one set date/time, no alternative, does this require a different method?
<section>
<h1>Tennis Lessons</h1>
<ol>
<li>Book Tickets for
<time datetime="2001-05-15 19:00">May 15</time>
</li>
<li>Book Tickets for
<time datetime="2001-05-16 19:00">May 16</time>
</li>
<li>Book Tickets for
<time datetime="2001-05-17 19:00">May 17</time>
</li>
</ol>
</section>
Or is this the wrong way to approach it and the events are children of a product?
<section itemscope itemtype="http://schema.org/Product">
<h1 itemprop="name">Tennis Lessons</h1>
<ol>
<li itemscope itemtype="http://schema.org/Event">Book Tickets for
<time datetime="2001-05-15 19:00">May 15</time>
</li>
<li itemscope itemtype="http://schema.org/Event">Book Tickets for
<time datetime="2001-05-16 19:00">May 16</time>
</li>
<li itemscope itemtype="http://schema.org/Event">Book Tickets for
<time datetime="2001-05-17 19:00">May 17</time>
</li>
</ol>
</section>
In this case, on a booking confirmation page, it would then be correct to wrap the whole section in event Microdata as it then only has one possible date/time option?
Schema.org defines that an Event happens "at a certain time". So each lesson should be represented by its own Event item.
If you can book a lesson on your page, you may want to use the offers property and provide an Offer for each Event.
The nesting in your second snippet (Event items inside the Product item) has no influence on the Microdata (example). You have to use a property (within the itemprop attribute) if you want to connect Microdata items.
While you could use Product to represent the fact that you provide the service of tennis lessons, it seems that the Product type is missing a suitable property to reference an Event item. The typical solution would be to use both types, but Microdata is rather limited in that regard (it works better with RDFa).
If you want to provide data that is the same for all events, you could make use of the itemref attribute (instead of repeating it for each event).
So a basic structure could be this:
<section>
<h1>Tennis Lessons</h1>
<p itemprop="description" id="event-desc">…</p>
<ol>
<li itemscope itemtype="http://schema.org/Event" itemref="event-desc">
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
</div>
</li>
<li itemscope itemtype="http://schema.org/Event" itemref="event-desc">
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
</div>
</li>
</ol>
</section>