Plug Sample: Fetch ticket status from Zoho Desk on Codeless bot builder | Zoho SalesIQ
Hi everyone, Good to see you.
Are you using the Codeless bot platform for building your bot? Did you know that plugs are exclusively made for performing customized actions on Codeless bot?
Here is a simple plug for fetching the status of the ticket from Zoho Desk. This plug can get the ticket number from the visitor and update them with the status of their ticket. You can do slight customization to the script and use it. Let's know how to create and use this plug in real time.
How to Create this Plugs?
- In your SalesIQ Dashboard, navigate to Settings>Developers>Plugs> Click on Add .
- Provide your Plug a name, description, select the Platform as SalesIQ Scripts , and click on Create Plug .
- Click on Parameters, provide the following.
Input Parameters :
- Name: ticketnumber | Data Type: String
Output Parameters :
- Name: priority | Data Type: String
- Name: subject | Data Type: String
- Name: description | Data Type: String
- Name: days | Data Type: String
- Name: CreatedTime | Data Type: String
- Copy, paste the below code and change your Zoho Desk Organisation ID and Connection name.
Scope for this Plug code:
- Desk.tickets.ALL
- Desk.search.READ
- //Change your Zoho Desk organization ID
- orgId = "1234";
- //Get ticket number from the parameters
- if(session.containsKey("ticketnumber"))
- {
- ticket_number = session.get("ticketnumber").get("value");
- }
- searchQuery = Map();
- searchQuery.put("ticketNumber",ticket_number);
- //zohodesk - Connection name
- get_ticket = zoho.desk.searchRecords(orgId,"tickets",searchQuery,0,1,"zohodesk");
- info get_ticket;
- //get ticket details from "get_ticket"
- modified_time = get_ticket.get("data").getJSON("modifiedTime").toDate();
- created_time = get_ticket.get("data").getJSON("createdTime").toDate();
- ticket_number = get_ticket.get("data").getJSON("ticketNumber");
- priority = get_ticket.get("data").getJSON("priority");
- status = get_ticket.get("data").getJSON("statusType");
- raw_description = get_ticket.get("data").getJSON("description");
- raw_subject = get_ticket.get("data").getJSON("subject");
- subject = raw_subject + "- (" + status + ")";
- description = raw_description.replaceAll("<[^>]*>","");
- description = description.replaceAll(" "," ");
- time_now = today;
- numberOfDays = daysBetween(modified_time,time_now);
- if(numberOfDays == 0)
- {
- time_interval = "Today";
- }
- else if(numberOfDays == 1)
- {
- time_interval = "1 day ago";
- }
- else
- {
- time_interval = numberOfDays.toString() + " days ago";
- }
- info time_interval;
- info description;
- info priority;
- info created_time;
- response = Map();
- response.put("CreatedTime",created_time);
- response.put("days",time_interval);
- response.put("description",description);
- response.put("priority",priority);
- response.put("subject",subject);
- return response;
- Then, click Save, preview the plug and Publish it.
- Navigate to Settings>Bot>Add and give the necessary informations and select Codeless Bot as bot platform or open an existing bot.
- Select the Plugs card under Action Cards and select the required Plug (Only published plugs will be listed here)
- Provide the Plug inputs (values to be obtained from the visitors) and outputs (value to be given for the visitors).
- In the plug input, the ticket_number is the bot context variable that stores ticket number obtained from the visitors fields card.
Note:
- Create a visitors fields to get ticket number from the visitor and save the values in context variable for plugs input.
Related Links: