AIML - Wild Card Tags - aiml

I am writing the below AIML code.
<aiml>
<category>
<pattern>test</pattern>
<template>This is a test to try the third possible input. Yes / No ? </br>
</template>
</category>
<category>
<pattern>Yes</pattern>
<that>This is a test to try the third possible *</that>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>No</pattern>
<that>This is a test to try the third possible *</that>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<that>This is a test to try the third possible *</that>
<template>BINGO!!!!</template>
</category>
</aiml>
I would like to see "Bingo!!!" as a response when a user enters anything apart from Yes or No.
<pattern>*</pattern>
works fine when I use it separately, but not here. Where am I doing the mistake?

Some AIML libraries require the pattern value to be uppercase (this is good practice even for implementations which not force it). So for me the following code works as expected (tested under PyAIML):
<aiml>
<category>
<pattern>TEST</pattern>
<template>This is a test to try the third possible input. Yes / No ? <br /></template>
</category>
<category>
<pattern>YES</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>NO</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>BINGO!!!!</template>
</category>
</aiml>
Output:
> test
This is a test to try the third possible input. Yes / No ?
> yes
Hey!. You have typed YES!
> test
This is a test to try the third possible input. Yes / No ?
> no
Hey!. You have typed No!
> test
This is a test to try the third possible input. Yes / No ?
> Foo
BINGO!!!!
>
Instead of <that> tags you can also try to use <topic>, e.g.:
<aiml>
<category>
<pattern>TEST</pattern>
<template>
This is a test to try the third possible input. Yes / No ? <br />
<think><set name="topic">THREE OPTIONS</set></think>
</template>
</category>
<topic name="THREE OPTIONS">
<category>
<pattern>YES</pattern>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>NO</pattern>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<template>BINGO!!!!</template>
</category>
</topic>
</aiml>

Related

Callapi and openweathermap

I have problem with I think format when I get temperature value. When I call for this parameter I always got it with "d0" f.e. "-0,39d0". How can I fix it? My code:
<category>
<pattern>PADANIE</pattern>
<template>
<think>
<set name="weather_t">
<callapi>
<url>http://api.openweathermap.org/data/2.5/weather</url>
<method>GET</method>
<query name="appid"><secret name="openweathermap_secret_appid"/></query>
<query name="q">zyrardow</query>
<query name="units">metric</query>
<query name="lang">pl</query>
<filter type="jsonpath">$.main.temp</filter>
</callapi>
</set>
</think>
<get name="weather_t"/>.
</template>
</category>
If I use jsonpath instead filter the result is the same.
<category>
<pattern>PADANIE</pattern>
<template>
<think>
<set var="weather_t">
<callapi>
<url>http://api.openweathermap.org/data/2.5/weather</url>
<method>GET</method>
<query name="appid"><secret name="openweathermap_secret_appid"/></query>
<query name="q">zyrardow</query>
<query name="units">metric</query>
<query name="lang">pl</query>
</callapi>
</set>
</think>
<jsonpath><path>$.main.temp</path><get var="weather_t"/></jsonpath>
</template>
</category>
bot answer example
This is how the openweathermap API presents the results. The easiest way to get rid of the d0 part is to denormalize the output.
Add this to your denormal substitution file:
["0d0", "0"],
["1d0", "1"],
["2d0", "2"],
["3d0", "3"],
["4d0", "4"],
["5d0", "5"],
["6d0", "6"],
["7d0", "7"],
["8d0", "8"],
["9d0", "9"],
In your first category, replace:
<get name="weather_t"/>
with
<denormalize><get name="weather_t"/></denormalize>
It should now work

Can I get some examples with this issue?

I'm seeming to have a little trouble with the <srai> tag. Can I have some other examples of to use it better please?
First of all, you need to create your main category. In this case, the bot will respond to "I know"
<category>
<pattern>I KNOW</pattern>
<template>Great. Glad you understand it.</template>
</category>
Now you can create other ways of saying "I know", like "ik" or "I kno" and use <srai> to activate your main category
<category>
<pattern>IK</pattern>
<template><srai>I know</srai></template>
</category>
<category>
<pattern>I KNO</pattern>
<template><srai>I know</srai></template>
</category>
This will allow the following conversation:
Human: ik
Bot: Great. Glad you understand it.

How can I trigger a response on a particular day in a month with condition tag?

I am having problems making my aiml chatbot respond on a particular day of the month.
I make chatbots on botlibre.
I tried this code in my aiml chatbot but it did not work.
<pattern>date</pattern>
<template>
<think><set name="day of the month"><date format="%B %d"/></set></think>
<condition name="day of the month">
<li value="December 29">it's the twenty ninth.</li>
<li value="November 06">it's the sixth. How are you?</li>
</condition>
The expected result is the twenty ninth.
In actuality the aiml chatbot does not respond.
This is valid AIML and should work. It works fine on Pandorabots.com
Amend your category (as below) so it displays your predicate and you can see what "day of the month" is set to. My advice is to miss out the spaces in the predicate name and set it to "dayofthemonth" or even just "day", as it's possible Botlibre doesn't like predicates with spaces.
<category>
<pattern>date</pattern>
<template>
<set name="day of the month"><date format="%B %d"/></set>
<condition name="day of the month">
<li value="December 29">it's the twenty ninth.</li>
<li value="November 07">it's the seventh. How are you?</li>
<li>day of the month = <get name="day of the month"/></li>
</condition>
</template>
</category>
An AIML tip I would advise you do with <condition> is to always include a catchall <li> as I've done above. That way, your bot will at least respond with something if nothing matches rather than leaving the user hanging.

How to update AIML version from 1.0.1 to AIML 2.0

Current application is using AIML version 1.0.1 and I want to update it to 2.0 . The xml files are having the code like -
<aiml version = "1.0.1" encoding = "UTF-8">
<aiml>
<category>
<name>URL</name>
<pattern>Example link*</pattern>
<template>Here is the Link !
<hyperlink href="https://example.com"target="_blank">Click Here</hyperlink>
<id>URL1</id>
</template>
</category>
</aiml>
Which bot are you using?
AIML 2.0 is fully compatible with 1.0
Documentation about AIML (including AIML 2) is available here: https://pandorabots.com/docs/aiml-reference/
Your example category can now be simplified to this, using the <link> tag
<category>
<pattern>Example link</pattern>
<template>Here is the Link !
<link>
<text>Click here</text>
<url>https://example.com</url>
</link>
</template>
</category>

Fhir Path Regex for valueDate

We recently started to use fhir path to validate a QuestionnaireResponse.
The QuestionnaireResponse is the following
<QuestionnaireResponse xmlns="http://hl7.org/fhir">
<questionnaire>
<reference value="..." />
</questionnaire>
<status value="completed" />
<authored value="2016-02-19T05:13:42.600Z" />
<group>
<question>
<linkId value="8d0db198-f341-43f8-9dd3-9151ace66375" />
<text value="date" />
<answer>
<valueDate value="2016-02-12" />
</answer>
</question>
</group>
</QuestionnaireResponse>
I have tried the following:
QuestionnaireResponse.group.question.answer.valueDate
and the answer was:
2016-02-12
However trying the following to validate the date with a regex throws exception
QuestionnaireResponse.group.question.answer.valueDate.matches("^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$")
it would be great if you may give me some idea of what is the best way to evaluate a date in fhir path
This turned out to be a bug in the .NET FluentPath evaluator that is in development still (regex section).
The FHIR server should also have rejected the value as not conforming without the fhirpath expression also.