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

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.

Related

how can I deeplink an app from Google Assistant?

I'm creating a dialogflow agent integrated with Google Assistant.
What I'd like to do is to open an app (my app) when a proper intent is matched. I've seen that actions like Youtube, Spotify etc. are able to do that, for example I can tell the Youtube action "search for cats video" and the Youtube app will open with a list of cats videos.
I tried to use the DeepLink class but I then noticed it's deprecated.
DeepLink class
Is there any way you can suggest me to do this?
Thanks in advance
I think you are looking for App Actions. Here are the steps you need to follow:
Find the right built-in intent. actions.intent.OPEN_APP_FEATURE should be the right one for you.
Create and update actions.xml. It should look like
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a sample actions.xml -->
<actions>
<action intentName="actions.intent.OPEN_APP_FEATURE">
<!-- Use url from inventory match for deep link fulfillment -->
<fulfillment urlTemplate="{#url}" />
<!-- Define parameters with inventories here -->
<parameter name="feature">
<entity-set-reference entitySetId="featureParamEntitySet" />
</parameter>
</action>
<entity-set entitySetId="featureParamEntitySet">
<!-- Provide a URL per entity -->
<entity url="myapp://deeplink/one" name="featureParam_one" alternateName="#array/featureParam_one_synonyms" />
<entity url="myapp://deeplink/two" name="featureParam_two" alternateName="#array/featureParam_two_synonyms" />
</entity-set>
</actions>

How to set variables with default values in AIML?

I want to set some variables to default values, so if the user never supplies, say, their username, my responses won't have odd empty spaces in them.
Sample of what I tried but didn't work:
<set name="name">user</set>
<category>
<pattern>HELLO</pattern>
<template>
Hello, <get name="name"/>.
</template>
</category>
The description of <get /> leads to the .pdefaults file.
Instead of
<set name="name">user</set>
in the UDC, the following single line in .pdefaults gets the result you want
[["name", "user"]]

AIML - Wild Card Tags

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>

How do you force WeBlog to reorder blog posts into new folder structure?

The base WeBlog config contains these nodes:
<event name="item:saved">
<handler type="Sitecore.Sharedsource.Tasks.NewsMover, Sitecore.Sharedsource.NewsMover" method="OnItemSaved">
<database>master</database>
<templates hint="raw:AddTemplateConfiguration">
<template id="Modules/WeBlog/BlogEntry" sort="Descending">
<DateField>Entry Date</DateField>
<YearTemplate formatString="yyyy">Common/Folder</YearTemplate>
<MonthTemplate formatString="MMMM">Common/Folder</MonthTemplate>
<!-- Uncomment the following line if you have too many posts per month (more than 100) -->
<!--<DayTemplate formatString="dd">Common/Folder</DayTemplate>-->
</template>
</templates>
</handler>
<!-- Keep the post and comment handlers seperate to ensure comments are structured below posts and not within the same folder structure as posts -->
<handler type="Sitecore.Sharedsource.Tasks.NewsMover, Sitecore.Sharedsource.NewsMover" method="OnItemSaved" use="comments">
<database>master</database>
<templates hint="raw:AddTemplateConfiguration">
<template id="Modules/WeBlog/BlogComment" sort="Descending">
<DateField>__created</DateField>
<YearTemplate formatString="yyyy">Common/Folder</YearTemplate>
<MonthTemplate formatString="MMMM">Common/Folder</MonthTemplate>
<!-- Uncomment the following line if you have too many posts per month (more than 100) -->
<!--<DayTemplate formatString="dd">Common/Folder</DayTemplate>-->
</template>
</templates>
</handler>
<handler type="Sitecore.Modules.WeBlog.Globalization.ItemAndPublishEventHandler, Sitecore.Modules.WeBlog" method="OnItemSaved"/>
</event>
If the line below is uncommented for BlogEntries, how do you force WeBlog to reorder the existing blog posts into the correct folders (now containing a day folder)?
<DayTemplate formatString="dd">Common/Folder</DayTemplate>
Currently using Sitecore 7.1 and WeBlog 5.3.

Adding new view to Dexterity type causes "page not found" viewing items

I'm working through the recent Professional Plone 4 Development book, on a Plone 4.1.2 install.
I have successfully defined the content types via Dexterity and am now trying to create a custom view for one of the types. The schema & view are defined as such:
from zope import schema
from plone.directives import form
from five import grok
from ctcc.contenttypes import CTCCTypesMessageFactory as _
class ITrial(form.Schema):
"""A clinical trial."""
title = schema.TextLine(
title = _(u'label_title', default=u'Title'),
required = True,
)
description = schema.Text(
title=_(u'label_description', default=u'Description'),
description = _(u'help_description', default=u'A short summary of the content'),
required = False,
missing_value = u'',
)
class View(grok.View):
grok.context(ITrial)
grok.require('zope2.View')
grok.name('view')
Here is the relevant section from the type's FTI:
view
False
<alias from="(Default)" to="(selected layout)"/>
<alias from="edit" to="##edit"/>
<alias from="sharing" to="##sharing"/>
<alias from="view" to="##view"/>
<action title="View" action_id="view" category="object" condition_expr=""
url_expr="string:${folder_url}/" visible="True">
<permission value="View"/>
</action>
And the template itself, located in ctcc.contenttypes/trial_templates/view.pt, which should simply display the title & description:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="ctcc.contenttypes">
<body>
<metal:content-core fill-slot="content-core">
<metal:content-core define-macro="content-core">
<div tal:replace="structure context/text/output" />
</metal:content-core>
</metal:content-core>
</body>
</html>
Accessing any instances of the type with all this in place causes a "page not found" error. Something doesn't seem to be tying up the new view to the expected path, but as this is my first week with Plone I've no idea where to begin to track this down. I'm seeing no errors running the site in foreground mode either.
Any help whatsoever would be greatly appreciated.
did you included the dependency in setup.py?
install_requires=[
'setuptools',
'plone.app.dexterity',
...
],
did you initialized Grok in your configure.zcml?
<configure
xmlns="http://namespaces.zope.org/zope"
...
xmlns:grok="http://namespaces.zope.org/grok">
<includeDependencies package="." />
<grok:grok package="." />
...
</configure>
did you included Dexterity's GenericSetup profile in your metadata.xml?
<metadata>
<version>1</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
</dependencies>
</metadata>
The problem was with this line in the template:
<div tal:replace="structure context/text/output" />
I had stripped back an example template to what I thought was the bare minimum. Thanks to David Glick's suggestion, I removed NotFound from the ignored exceptions list in error_log and saw the following:
Module Products.PageTemplates.Expressions, line 225, in evaluateText
Module zope.tales.tales, line 696, in evaluate
- URL: /opt/plone41/zeocluster/src/ctcc.contenttypes/ctcc/contenttypes/trial_templates/view.pt
- Line 13, Column 8
- Expression: <PathExpr standard:u'context/text/output'>
[...]
Module OFS.Traversable, line 299, in unrestrictedTraverse
- __traceback_info__: ([], 'text')
NotFound: text
Now that I can see what's causing the problem and have started reading deeper into TALs, I can see why it's failing: ignorance on my behalf, as suspected.
Thanks, everyone!