The Set Fields rule action uses a valid URL to return a KANA Message Markup Language (KMML) message. This action has been available when creating rules for incoming messages and recently was made available for outgoing messages.
The Set Fields rule action populates fields that are stored in the KANA Response database and can be viewed in the Customer Profile. The information used to populate the fields comes from a KMML message returned from a specified URL. Both standard and custom fields may be populated. If the Set Fields action encounters a field in the KMML message for which a custom field has not been created in the KANA Response database, a warning message appears in the log file.
The Set Fields action requires you to enter the same kind of URL you would enter to create an external merge field, although the information returned from the URL is different. For Set Fields, the URL must return an XML document that conforms to the KANA KMML (KANA Message Markup Language) standard. Here is an example of the KMML that the URL might return:
<XML>
<?xml version="1.0" encoding="ISO-8859-1"?>
<kanaRoot>
<kanaMessage>
<kanaAttribute name="Customer ID">3452</kanaAttribute>
<kanaAttribute name="Status">Active</kanaAttribute>
</kanaMessage>
</kanaRoot>
</XML>
This provides the following information to the KANA Response system:
Customer ID = 3452
Status = Active
The kanaAttribute tags specified in the KMML returned by the web server must be valid KANA custom fields in order to be processed by the rule engine. The <XML> tag is not required if the only data returned is XML, but you must use the tag if you wish to return other information in addition to the XML.
KANA Response will ignore any information outside the <XML></XML> tag pair—if no XML tags are found, then all of the data is examined.
To use Set Fields for Incoming and Outgoing messages, follow the steps in Creating New Rules. Read the next section about using set fields in outgoing rules.
The Set Fields rule action was recently introduced in Outgoing Rules to enable setting custom fields or applying business rules for a message on the way out.
In this example, Set Fields are set in a rule that routes a randomly chosen number of email messages to a QA queue for review before routing to the customer.
An Agent downloads messages from an inbox and creates a response to the customer. When the Agent clicks Send, the following actions take place:
a. The message goes to Outgoing Rules.
b. The Setfields action in the Rules reads the agent’s review percentage stored in the User custom fields and passes it to a jsp/asp file.
c. The Jsp/asp file determines whether the message based on the random number generated and based on the review percentage set to the user needs to be reviewed.
d. The Setfields action returns to Response with the Boolean value whether this message is to be reviewed or not reviewed.
e. A child rule is created to check the returned Boolean value and send it to the Review Queue accordingly.
A reviewer assigned to the Review Queue downloads the message and makes a decision whether to accept or reject and based on that, appropriate action is taken by Response.
To set up this rule or a similar one, follow these steps:
Create user custom fields on the Custom Fields page.
For this example, a custom field for Review Percentage with Integer data applied to Users is created, plus a custom field named to review with True/False data applied to Users is created.
Set a value for the review percentage in the User edit page.
Copy the following file in a folder named review.asp and enable Web sharing for use with IIS:
<%@ Language=JavaScript%>
<%
myKMMLHeader = "<kanaRoot><kanaMessage>";
myKMMLBody = "";
myKMMLFooter = "</kanaMessage></kanaRoot>";
var reviewPercentage = Request("ReviewPercentage");
var randomPercentage = (Math.random() * 100) + 1;;
//Response.write('review ' + reviewPercentage + ' random ' + randomPercentage);
if (reviewPercentage <= randomPercentage)
toReview = 'true';
else
toReview = 'false';
myKMMLBody = myKMMLBody + '<kanaAttribute name="toreview">'+ toReview + '</kanaAttribute>';
myKMMLBody = myKMMLBody + '<kanaAttribute name="email_supervisor">'+ shakila@kana.com + '</kanaAttribute>';
myKMMLString = myKMMLHeader + myKMMLBody + myKMMLFooter;
Response.write(myKMMLString);
%>
NOTE: A JSP file can also be created instead of ASP and can be used under Tomcat or any server that supports JSP.
3. Create rules on the Rules page to process the review percentage:
Refer to the file name and the URL of the above file in the Set Fields action field.
4. Assign reviewers to review Queue.
Where else can I learn about Set Fields?
Are there any tips on using rules?
How does Response execute rules?
Is there an example of a rule I can look at?
How do I use a regular expression in a rule?
How do I reorder a rule in the hierarchy?