Check 2 values in aiml file - aiml

How can I check 2 values in condition or with other tags?
I want check if the user's name is equal with Unknown user value but I don't know how can I do this.

Assume you have the user name stored in a global property (predicate) called user, using <set name="user">George</set> You can check the user's name with an AIML category like this:
<category>
<pattern>WHAT IS MY NAME</pattern>
<template>
<condition>
<li name="user" value="unknown">You haven't told me your name</li>
<li name="user" value="">You haven't told me your name</li>
<li>Hello <get name="user"/>!</li>
</condition>
</template>
<category>
This works as follows:
You set up a category that responds to user input "What is my name"
The <li> elements in the <condition> test the name property for unknown and blank. In this case the AI replies the user hasn't told us their name.
The final <li> element is triggered if we have a name, and it replies with 'Hello' followed by the user name.
I haven't tested this with program O but it's standard AIML and should work fine. I have successfully coded similar categories in my own AI.

Related

Django: How to make this GET request with a hyperlink?

So if I want a user's name to link to it's profile, I want the link to contain the user's first name and last name in GET form...Do I just hard-code this into the link, or is there a more elegant way of coding this? Here is hard-coded:
<p>
<li role="presentation" class="active">{{ user.fname }}
</li>
</p>
Yes, the more elegant way would be to set up a route that takes, for example, the user's ID (pk) and use either a DetailView set up for the User model or a function view that accepts the ID and retrieves the relevant user. Passing in the first and last name directly means you need to query on both of them (after pulling them out of the querystring) rather than simply querying on the ID as it's passed to you (after the framework politely checks its type, provided you've set up the route correctly).
So your route would look something like url(r'^profile/(?P<pk>\d+)/$', ProfileView.as_view(), name='profile') and your template tag would look something like {% url 'profile' user.id %}.

How come the get tag won't display any text in pyAIML?

I am working on a chat bot, just to see how it goes. I am using the PyAIML module. I currently am trying to get the user's name, and be able to use it when asked to. however, when I run the program, it doesn't show the name, only the text surrounding it. pardon my poor explanation of my problem. let me show you some code.
<category>
<pattern>MY NAME IS *</pattern>
<template>ok <star/>, I will do my best to remember that <star/> is your name.</template>
<think><set name = "name"><star/></set></think>
</category>
<category>
<pattern>WHAT IS MY NAME</pattern>
<template>I like to call you <get name = "name"/>. should I change it?
</template>
</category>
when run, the output does not include the name. all it says is:
<--I like to call you . Should I change it?
Am I doing something wrong?
Ps.(please be graceful, I just started AIML today :))
I'm not sure what the "think" tag is for, but I think that the main problem is that you have placed the "set" tag outside of the "template" tag.
Try something like this:
<template>ok <set name = "name"><star/></set>, I will do my best to remember that <get name = "name"/> is your name.</template>

DocuSign API: Pre-filling radio group tabs for template

I have radio groups setup in my DocuSign template, and am trying to fill it up while creating an envelope using the template. Here's the XML structure that I've made:
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
<accountId>******</accountId>
<status>sent</status>
<templateId>******</templateId>
<templateRoles>
<templateRole>
<email>******#test.com</email>
<name>****** ******</name>
<roleName>General</roleName>
<clientUserId>UserId</clientUserId>
<tabs>
<textTabs>
<text>
<tabLabel>Name</tabLabel>
<value>Test User</value>
</text>
<text>
<tabLabel>Address 1</tabLabel>
<value>123 Main Street</value>
</text>
<text>
<tabLabel>Address 2</tabLabel>
<value>Venice, CA 12345</value>
</text>
</textTabs>
<radioGroupTabs>
<radioGroup>
<groupName>Radio Group 1</groupName>
<radios>
<radio>
<selected>True</selected>
<value>Radio 1</value>
</radio>
<radio>
<selected>False</selected>
<value>Radio 2</value>
</radio>
</radios>
</radioGroup>
</radioGroupTabs>
</tabs>
</templateRole>
</templateRoles>
</envelopeDefinition>
Is this XML request correct? The 'Name' and 'Address *' tabs are correctly filled, but the radio group tabs are not filled at all.
Your XML looks correct to me; in fact, I was able to copy/paste (including the radioGroupTabs portion) from your code sample into my own request and it works as desired -- i.e., the radio button specified as selected in the request is indeed selected when the recipient opens the envelope.
I'd suggest you verify that the values of groupName and value (for each Radio) in the Request XML match exactly with the corresponding values specified for the Radio Button Tag Properties, as shown here in the DocuSign UI -- and keep in mind that values are case-sensitive:

JSF listeners in selectOneMenu

I have a selectOneMenu item with some products. Some of them are unavailable so after you click on it the button "Add" should be disabled and some message should appear that "Sorry the product you chose is currently unavailable". I have no idea how to achieve that. Tried listeners, ajax and still nothing.
This is one of many versions of my JSF Page:
<h:form>
<h:selectOneMenu value="#{productBean.productName}">
<f:selectItems id ="other" value="#{productBean.other}" var="other" itemValue="#{ordersBean.productName}" itemLabel="#{other.name}" />
<f:ajax listener="#{productBean.valueChanged}" />
</h:selectOneMenu>
<h:commandButton value ="Dodaj do zamówienia" rendered="#{productBean.available}"/>
<h:outputLabel id="orderSummary"/>
</h:form>
Beans are rather standard. I just need a clue how to do that and probably I will be able to do it myself.
Thanks in advance.
Here's one of the ways:
In your AJAX listener you could check if a product is available and set up bean field accordingly, or add a message for a component.
Introduce a component in your view that'll hold the message to the user, for example with the #{bean.available ? '' : 'Sorry, out of stock'} value, or enclose it within a <h:panelGroup> and let that component have a rendered attribute, or attach <h:message>/<h:messages> somewhere in your view.
Specify id of the message holder to be rendered within render attribute of <f:ajax> tag.

Create custom ItemStyle template for SharePoint

I've created a custom ItemStyle_ContactDetails.xsl for a SharePoint 2010 content query web part, which points to this custom file via the ItemXslLink property. The web part will be filtered to display only one record for that department's contact info. The list it's reading has these columns:
#Title -- built-in SharePoint column
/dsQueryResponse/Rows/Row/#WorkAddress -- built-in SharePoint column
/dsQueryResponse/Rows/Row/#PrimaryNumber -- built-in SharePoint column
#EMail -- built-in SharePoint column
#Opening_x0020_Hours -- custom multi-line rich text column
The above names are what they're called in the Data View Web Part from another site. I had the following in that DVWP that worked for a local site:
<td colspan="2" class="ms-vb" style="text-align:center">
<b><xsl:value-of select="#Title"/></b><br></br>
<div style="margin-top:10px;"><xsl:value-of
select="/dsQueryResponse/Rows/Row/#WorkAddress"/>
(MAP)
</div>
Tel: <xsl:value-of select="/dsQueryResponse/Rows/Row/#PrimaryNumber"/><br></br>
<xsl:value-of select="#EMail"/>
<p><b>Opening Hours:</b></p>
<div style="position:relative; top:0; margin:0">
<xsl:value-of select="#Opening_x0020_Hours"
disable-output-escaping="yes"/>
</div>
</td>
How do I translate this to the custom ItemStyle_ContactDetails.xsl template? The user needs to see the info without having to click a link to get to it -- it's always going to be just one record for that department. Thanks.
Some serious trial-and-error yielded the result, along with this great article: http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx
Maybe others trying this same thing can find this useful: You can edit the custom XSL file on the server via SPDesigner, but you can't do the same with the web part and hope to have the changes immediately reflected. You must export the content query web part, then edit the file in Notepad, etc., to make your changes to the following 3 items:
Change the ItemXslLink to point to your custom XSL file:
<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/ItemStyle_ContactDetails.xsl</property>
Change the ItemStyle item in the web part to reference your template name; the template name in the XSL file is ContactDetails:
<xsl:template name="ContactDetails" match="Row[#Style='ContactDetails']" mode="itemstyle">
So in your web part, you'd have this:
<property name="ItemStyle" type="string">ContactDetails</property>
Update the CommonViewFields to list your custom columns and their types:
<property name="CommonViewFields" type="string">WorkAddress, Text; EMail,Text; Contact_x0020_Department,Choice; Map,URL; Opening_x0020_Hours,Text; PrimaryNumber, Text</property>
Save the web part file and import (upload) it via the browser to your web part gallery. Each time you make changes to the web part, you'll want to do this; the XSL file can be edited and saved in SPDesigner and the changes reflect immediately in the browser.
Hope this helps someone who gets stuck like I was :)
Whenever I edit "CommonViewFields" in the Webpart, I cannot edit the Properties after inserting the Webpart because of Correlation Error.
I am using SP 2013 onprem. Do I really need to modify the Webpart ? Isn't it enough to create a custom itemstyle.xls ?
I am playing around now for days. Each days more I have to say - Sharepoint is a mess.