Field Code Examples
This section presents examples of the use of field codes.
Using a Custom Variable
Purpose: This is a simple example of the use of a custom variable in a standard response.
Prerequisites This example assumes a category tree that includes categories called Cookbooks, Mysteries, and Reference.
- In eServices Manager:
- Create a custom variable called QueryTopic (see See Creating field codes).
- Create a field code called Query_Topic that consists of the variable QueryTopic.
- Create a standard response of type Autoresponse called AUTO that includes the sentence Thank you for your inquiry about <$ Query_Topic $>.
- Create the following screening rules:
- Cookbook: RegExFind("cook") || RegExFind("recipe") || RegExFind("food") || RegExFind("cuisine")
- Mystery: RegExFind("murder") || RegExFind("crime") || RegExFind("case of the") || RegExFind("detective")
- Reference: RegExFind("dictionar") || RegExFind("encyclopedia") || RegExFind("almanac")
- In Interaction Routing Designer, create a strategy that applies these screening rules one after the other, assigning a different value to the custom variable for each screening rule:
- Create a variable called var_screen.
- Create a strategy. Start the strategy with a Screen object. On the General tab of the Screen object, select the Cookbook rule.
- On the Result tab, click Assign values of the key-value pairs. Then under Output values select var_screen for Variable and enter ScreenRuleMatch for Key from output.
- Connect the Screen object to a Generic Segmentation object. Create two segments: var_screen = true and var_screen = false.
- Connect an Autoresponse object to the top green port (the one corresponding to true) of the Segmentation object. In the Autoresponse, select the Select standard response radio button and select AUTO in the associated drop-down list.
- Still in this Autoresponse, go to the General tab and in the Field Codes area (bottom of the tab) click the New icon, enter QueryTopic under Key, and enter cookbooks under Value. This will generate an email that includes the sentence Thank you for your inquiry about cookbooks.
- Return to the Generic Segmentation and connect a new Screen object to its second green port (the one corresponding to false).
- On the General tab of the new Screen object, select the Mystery rule. On the Result tab, click Assign values of the key-value pairs. Then under Output values select var_screen for Variable and enter ScreenRuleMatch for Key from output.
- Proceed as in Steps d–f: Connect this Screen object to a new Generic Segmentation, again with segments for var_screen = true and var_screen = false.
- As in Step e, connect a new Autoresponse object to the green port for true, select the AUTO standard response, and enter QueryTopic under Key. This time enter mysteries under Value.
- Return to the second Generic Segmentation’s green port for false and repeat Steps g–j, creating a third Screen object and Generic Segmentation. In the Screen object, select the Reference rule; in the Segmentation object, set the custom variable to reference.
The figure "Strategy Using Custom Variable" shows the strategy as described. The single standard response AUTO generates three emails, each with a different word filling the blank in Thank you for your inquiry about ___.
Using a Complex Field Code
The following is an example of a complex field code:
<$ If (Time() - Interaction.DateCreated > 14, “Please accept our apologies for not having replied sooner. ”, “”) $>
This field code inserts a tardiness apology if more than 14 days have elapsed since the interaction first entered the system. It uses the function If, which has these properties:
Its syntax is If (Boolean, TrueResult, FalseResult)
If Boolean evaluates to True, it returns the second argument.
If Boolean evaluates to False, it returns the third argument.
In this example, the three arguments of If are as follows:
Time() - Interaction.DateCreated > 14
A formula that returns True if the difference between the date created and the current system time is more than 14 days. (The result of a mathematical operation on dates is given in days.)
“Please accept our apologies for not having replied sooner. ” A text string apologizing for tardiness, inserted if the formula evaluates to True.
The null string: if the reply is not late (the formula evaluates to False), nothing is inserted in it.
Go on to create and manage Screening Rules.