Custom Zia Actions

Technicians can define [Zia] actions specific to their organizations in the developer console of Zia. Technicians can define all three types of actions supported by Zia including direct questions, data-fetching questions, and operations.

Configuring Custom Actions

All ServiceDesk Plus Cloud technicians can configure actions in the developer console of Zia. However, technicians can modify or delete only the actions that they created. Only the admin has complete control over all the actions.

Technicians can configure any number of actions, there is no limit to it.

Once preconfigured, the actions will be available under the Hamburger icon inside Ask Zia in ServiceDesk Plus Cloud. 

Below are the common and initial steps to configure any type of action:

Click the link displayed on the Zia integration page to open the developer console of Zia.

Click Add Action and choose Write your Own.
 

 

Configuring Direct Questions

Let's say you want to define an action to provide the sysadmin's extension number.

In the new action form, provide a name to your action. (The name is for reference inside the developer console only.)

Select Answer a Question and then choose Give a Direct Answer.

Phrase how this action must be displayed for users inside Ask Zia. Give the action a short but meaningful name.
 

 

Provide the answer to the question and click Next.
 

 

Enter all possible questions or sentences to call the same action inside Ask Zia. These questions will be recommended for users to select from.

Sequence the questions to display inside Ask Zia. Use the pointer displayed at the right side of each question to reposition the question.

Click Save.
 

 

Choose whether you want only Zoho users or all users on the web to access the action.

Click Save.
 

 

You can define the sequential action by clicking ADD FOLLOWUP ACTION.


 

Choose from the available questions and click UPDATE.
 

 

Then, click ServiceDesk Plus Cloud displayed on the left pane, and click UPDATE on the upper-half of the page.

Only after you publish, the action will be available to use within ServiceDesk Plus Cloud.

Configuring Data-Fetching Questions

Let's say, you want to define an action to search requests by subject.

In the new action form, provide a name to your action. (The name is for reference inside the developer console only.)

Select Answer a Question and then choose Construct Answer by Fetching Data.

Phrase how this action must be displayed for users inside Ask Zia. Give the action a short but meaningful name. 

Use the Add icon and enter all possible questions or sentences to call the same action inside Ask Zia. These questions will appear as recommendations for the user to select from.

Sequence the questions to display inside Ask Zia. Use the pointer displayed at the right side of each question to reposition the question. The first question will be listed under the Hamburger menu inside Ask Zia.

 

 

Then you must provide the params. Please refer here for a detailed explanation of the each param type.

Click Add Param and fill out the fields.

 

 

Use the Add icon and enter all necessary params for the action.

Organize the params to display them sequentially inside Ask Zia when the action is invoked. Use the pointer displayed at the left side of each param to reposition the param.

Choose whether only Zoho users or all users on the web can access this action and click Done.

 

 

Click EDIT EXECUTION FUNCTION on the displayed page.

Insert the script to the editor and click Save Script. (Here's a formatted script for the sample action.)

You can instantly test the script execution by interacting with Zia in the live console provided on the right side of the page as shown below:

 

 

Click Done.

Then, click ServiceDesk Plus Cloud displayed on the left pane and click PUBLISH on the upper-half of the page.

Only after you publish, the action will be available to use within ServiceDesk Plus Cloud.

 

Configuring Operations

Let's say you want to define an action to add a reminder.

In the new action form, provide a name to your action. (The name is for reference inside the developer console only.)

Select Perform an Operation.

Phrase how this action must be displayed for users inside Ask Zia. Give the action a short but a meaningful name. For example, Add Reminder can represent the task "Zia, can you add a reminder to a request?".

 

 

Use the Add icon and enter all possible questions or sentences to call the same action inside Ask Zia. These questions will be recommended to users to select from.

Sequence the questions to display inside Ask Zia. Use the pointer displayed at the right side of each question to reposition the question. The first question will be listed under the Hamburger menu inside Ask Zia.

 

 

Click Next and provide the params. Please refer here for a detailed explanation of the fields.

Click the Add Param button and fill out the details.

 

 

Use the Add icon and enter all the necessary params for the action. Organize the params to display them sequentially inside Ask Zia when the action is invoked. Use the pointer displayed at the left side of each param to reposition the param.

Choose whether only Zoho users or all users on the web can access this action and click Done.

 

 

Click Done.

Click Edit Execution Function on the displayed page.

Insert the script to the editor and click Save Script. (Here's a formatted script for the sample action.)

You can instantly test the script execution by interacting with Zia in the live console provided on the right side of the page as captured below:

 

 

Click Done.

Then, click ServiceDesk Plus Cloud displayed on the left pane and click UPDATE on the upper-half of the page.

Only after you update, the action will be available to use within ServiceDesk Plus Cloud.

 

 

View/Edit/Deactivate an Action

Under ServiceDesk Plus Cloud, choose a filter to view the corresponding actions.

 

Click the action that you want to modify or deactivate.

To modify, use the Edit icon displayed on the upper-right corner of the page. In data-fetching questions and operations, you can modify the script by clicking Edit Code under the Edit drop-down.

To deactivate, click the Vertical Ellipsis button and click Deactivate. Deactivated actions will be displayed under the Inactive [actions] filter.

 

The admin has control over all actions, whereas technicians can only modify or deactivate only their own actions.

Params 

Params are input data that must be received from the user to complete the action.

Param Details

You must fill out the following fields in each param:

 

Param Name - A valid param name should comply with the following points.

 

Param type - Choose an apt data type for your param. Zia supports the following data types:

Array type params - In case of array type params, you may have to enter the following additional information:

Prompt Message

As you interact with Zia from within ServiceDesk Plus Cloud, Zia will get input for the params configured inside an action by displaying prompts.

Sample Scripts

Action 1: Search Requests by Subject
 

result = Map();
/*
Criteria to search by subject
*/
criteria = Map();
criteria.put("condition","like");
criteria.put("field","subject");
criteria.put("value",searchsubject);
list_info_param = Map();
list_info_param.put("search_criteria",criteria);
paramMap = Map();
paramMap.put("list_info",list_info_param);
apiUrl = "/api/v3/requests";
client_data = sessionData.get("client_data");
if(client_data != null)
{
    appName = client_data.get("appname");
    if(appName != null)
    {
        apiUrl = "/app/" + appName + apiUrl;
    }
}
response = invokeurl
[
    url :"http://sdpondemand.manageengine.com"+apiUrl
    type :GET
    parameters:{"input_data":paramMap}
    connection:"sdpondemand3"
];
info response;
// Display the api result in table format
requestArr = response.get("requests");
card = list();
item = Map();
item.put("type","table");
item.put("heading","Requests");
columns = {"Request Id","Request Subject","Requester name","Assigned To ","Status","Due Date","Link"};
item.put("columns",columns);
rows = {};
for each  request in requestArr
{
    row = {};
    row.add(request.get("display_id"));
    row.add(request.get("subject"));
    requestername = request.get("requester").get("name");
    row.add(requestername);
    technician = request.get("technician");
    technicianName = "-";
    if(technician != null)
    {
        technicianName = technician.get("name");
    }
    row.add(technicianName);
    row.add(request.get("status").get("name"));
    dueByTime = request.get("due_by_time");
    if(dueByTime != null)
    {
        dueByTimeLabel = dueByTime.get("display_value");
    }
    if(dueByTimeLabel == null)
    {
        dueByTimeLabel = "-";
    }
    row.add("" + dueByTimeLabel);
    row.add("https://sdpondemand.manageengine.com/app/" + appName + "/WorkOrder.do?woMode=viewWO&woID=" + request.get("id"));
    rows.add(row);
}
item.put("rows",rows);
card.add(item);
//info "card data in this actions======>" + card;
if(requestArr.size() > 0)
{
    result.put("card",card);
}
else
{
    result.put("message","No results found.");
}
return result;

Action 2: Add Reminder

apiUrl = "/api/v3/reminders";
client_data = sessionData.get("client_data");
if(client_data != null)
{
    appName = client_data.get("appname");
    if(appName != null)
    {
        apiUrl = "/app/" + appName + apiUrl;
    }
}
reminder_base = Map();
if(summaryparam != null && reminderdateparam != null && remindertimeparam != null)
{
    reminder_base.put("summary",summaryparam);
    datemap = Map();
    reminderdateparam = reminderdateparam.toTime().addHour(remindertimeparam.toTime().getHour());
    reminderdateparam = reminderdateparam.toTime().addMinutes(remindertimeparam.toTime().getMinutes());
    datemap.put("value",reminderdateparam.toTime().toLong());
    reminder_base.put("date",datemap);
    paramMap = Map();
    paramMap.put("reminder",reminder_base);
    response = invokeurl
    [
        url :"http://sdpondemand.manageengine.com"+apiUrl
        type :POST
        parameters:{"input_data":paramMap}
        connection:"sdpondemand3"
    ];
    responseStatusObject = response.get("response_status");
    result = Map();
    if(responseStatusObject != null)
    {
        responseStatusMessage = responseStatusObject.get("status");
        resultString = "Error while adding reminder.";
        if(responseStatusMessage == "success")
        {
            resultString = "Reminder added successfully.";
        }
        else
        {
            responseMessages = responseStatusObject.get("messages").toJSONList().get(0);
            resultString = resultString + " Please repeat the process with a valid " + responseMessages.get("field") + ".";
        }
        result.put("message",resultString);
    }
}
return result;