Sofi server actions
The fields and types of Sofi server actions, the shipped actions and example scripts for the 1.11 conversation stack.
Sofi server actions are scripts that the Sofi conversation stack in 1.11 calls during a conversation, for example to look up a user or log a ticket. This page lists their fields, types and shipped records, for administrators who maintain existing server actions.
Server actions are under Intelligent automation → Virtual agent → Server actions. You need the administrator role.
Fields
| Field | Type | Required | Behaviour | Purpose |
|---|---|---|---|---|
| Name | String | No | The name the conversation calls. | Identifies the server action. |
| Type | Choice | No | Choice list, Lookup, Log ticket or Custom. | How the conversation uses the result. |
| Description | String | No | None. | Says what the action does. |
| Script | Code | No | Receives action and context and assigns the result to answer. |
The work the action does. |
| Active | Boolean | No | Defaults to true. | Turns the action on or off. |
Client actions, under Intelligent automation → Virtual agent → Client actions, have a Name, a Script and Active. None are shipped.
Types
| Type | What the script returns |
|---|---|
| Choice list | Runs in two phases. In the list phase it returns the records and columns to show. In the action phase it receives the chosen record and stores it in the context. |
| Lookup | A value that picks the branch the conversation follows. |
| Log ticket | The details of the ticket it created, to show the user. |
| Custom | Whatever the conversation step expects. |
Shipped server actions
| Name | Type | Description |
|---|---|---|
| dialogManager.logTicket | Log ticket | Logs a ticket from the conversation. |
| dialogManager.zeroContactResolution | Log ticket | Logs a ticket with the requester’s mobile, location and email from their user record. |
| dialogManager.userLookup | Choice list | The default user lookup. |
| dialogManager.setVariable | Lookup | Sets a variable from the user’s last input. |
| servicely.getValidDate | Lookup | No description. |
| demo.checkAutomatedAction | Lookup | Demonstration. Checks the result of an automated action. |
| demo.actionHelpedResult | Lookup | Demonstration. Updates closure notes when an action helped. |
| demo.actionDidNotHelp | Lookup | Demonstration. Runs when an action did not help. |
| demo.getTargetRecord | Lookup | Demonstration. Gets the target record of an interaction. |
| demo.getRelatedArticle | Lookup | Demonstration. Gets an article related to a business service. |
| demo.fallbackAutoResolution | Lookup | Demonstration. Looks for a resolution item for the user’s text. |
| demo.whoIsItFor | Lookup | Demonstration. No description. |
| demo.getRequestedForDetails | Lookup | Demonstration. No description. |
| demo.moreDetails | Lookup | Demonstration. No description. |
| demo.getBusinessService | Choice list | Demonstration. No description. |
| demo.userLookup | Choice list | Demonstration. A user lookup. |
| demo.SSO_Account_Check | Custom | Demonstration. No description. |
| demo.SSO_Unlock_Account | Custom | Demonstration. No description. |
| demo.SSO_answer_security_question | Custom | Demonstration. No description. |
| demo.SSO_security_question_process | Custom | Demonstration. No description. |
| test_action | Lookup | Test. No description. |
Examples
Choice list: dialogManager.userLookup
The shipped user lookup searches active users by first name, last name or email.
switch (action.phase) {
case "list":
let s = action.search_text + "%";
answer = {
records: getUserList(s),
columns: [
{ name: "user_name", label: "Username", display: true },
{ name: "name", label: "First name", display: false, returnValue: true },
{ name: "email", label: "Email", display: true }
]
};
break;
case "action":
var variableName = SofiUtil.isBlankOrEmpty(action.variable_name) ? "selected_user" : action.variable_name;
context[variableName] = action.data;
answer = "ok";
break;
}
function getUserList(searchText) {
return Table("User")
.OR(LIKE("FirstName", searchText), LIKE("LastName", searchText), LIKE("Email", searchText))
.EQUAL("Active", true)
.maxResults(15)
.map(it => ({ user_name: it.UserName(), name: it.FirstName() + " " + it.LastName(), email: it.Email() }));
}
Log ticket: dialogManager.logTicket
The shipped log ticket action creates the record and sets the requester to the user in the conversation.
let SofiDialog = require("SofiDialog");
var rec = SofiDialog.createRecordForLogTicketAction(action);
if (rec.hasField("Requestor") && rec.Requestor.hasValue() == false) {
rec.Requestor(user.getRecord());
}
answer = SofiDialog.updateRecordAndReturnValues(rec, action);