Plug Sample #3: Part 2 - Fetch the operators' available slots in Zoho Bookings.

Plug Sample #3: Part 2 - Fetch the operators' available slots in Zoho Bookings.

In earlier post we covered how to design a Codeless bot to schedule an appointment/meeting on Zoho Booking using Plugs. In this post we will learn how to create a plug to fetch the operator's available timings on the visitor's preferred date in Zoho Bookings. Therefore, when scheduling a meeting, the bot initially asks for a preferred date from the visitor and then displays the operator's available slots during that particular day. This helps your organization to manage your operator's schedules and eliminates the clash of bookings/meetings.

What can this plug do?    
  • Gets the visitor's preferred date.
  • Display the agent's available slots (Zoho Bookings) on the preferred date.
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
             1. Input Parameter 1 : date | Data Type  : Date
             2. Output Parameters : slots | Data Type : Number list


Create a connection with Zoho bookings. 
  • Click on Connection at the left bottom. You will be redirected to the connection page.
  • Click on Create connection at the top right corner. Under Default connection , select Zoho OAuth

  • Then, give your connection a name, connection link name and choose required scopes.


  • Click on Create And Connect. Upon successful authentication, Zoho Bookings will be connected. Note: The Connection Link Name will be used in scripts to invoke URL tasks.
  • Copy, paste the below code and make the required changes. 
  1. response = Map();
  2. date = "";
  3. date = session.get("date").get("value");
  4. unixDate = date.toDate();
  5. slots = List();
  6. //Zoho Booking "Available Deluge task"
  7. //Ref -  https://www.zoho.com/deluge/help/bookings/get-available-slots.html
  8. //Replace your staff ID and service ID
  9. available_slots = zoho.bookings.getAvailableSlots(4302354000000026055,4302354000000026017,date,"zohobookings");
  10. slots_collect = available_slots.get("response").get("returnvalue").get("data");
  11. for each  slot in slots_collect
  12. {
  13.      unixSlot = unixDate + " " + slot + ":00";
  14.      slots.add(unixSlot.unixEpoch("Asia/Calcutta"));
  15.      response.put("slots",slots);
  16.      info slots;
  17. }
  18. return response;
  • Then, click Save , preview the plug and Publish it.
  • Navigate to Settings > Bot > Add , provide the necessary information and select Codeless Bot as bot platform or open an existing bot.
  • Select the Plugs under Action Block and choose the required Plug (Only published plugs will be listed here)
  • Provide the Plug inputs and outputs .
  • In this case, the preferred date from the visitor is collected from the calendar block and stored in bot context (date.option) - Plug input. 
  • Once the plug is executed, it will return the available slots as output which is stored in bot context (slot.option).

  • Then use Slots block to display the available slots to the visitors. Provide the bot context as slots (plug output). 

Related Links:
To know more about the features of Zobot, kindly visit our Resources Section. 

Regards,
Sasidar Thandapani