Plug Sample #5 - Read and write values/data in a Google Sheet with Zobot

Plug Sample #5 - Read and write values/data in a Google Sheet with Zobot

We all know google sheets are one of the widely used spreadsheet software. It helps us to make data-driven decisions. When connecting the Zobot with sheets, the bot can display values/data from a spreadsheet, like the available stock details (Item price, quantity). Create a new record, such as feedback, comments or even update the existing fields based on your requirement. In this post, we will focus on using plugs to achieve the below google sheets actions with REST API. 
  • Fetching records from Google sheets
  • Creating records in Google sheets
As we're aware, Plugs in the Codeless bot builder are used to create custom actions or third-party integrations using deluge. You can create a plug and add it as a card in the bot builder, like rest cards. Now let's learn how to create this plug step by step. 
 
Step 1 - Creating a connection with Google service.   
  • In your SalesIQ Dashboard, navigate to Settings > Developers > Plugs > Click on Add.
  • Provide your plug a name, and description, select the Platform as SalesIQ Scripts, and finally, click on Connection to your left bottom. You will be redirected to the connection interface. 

  •  Click on Create connection at the top right corner. Under Default connection, select Google service. 


  • Click on Create And Connect. Upon successful authentication,  Zoho SalesIQ will be connected with the Google service. 
Note: The Connection Link Name is used to scripts to invoke URL tasks.
 

 
Step 2 - Create the plug using Connection:
 
First let's look at fetching records from Google sheets. Any data that is available in sheets can be fetched. For example, if you're running an e-commerce business and maintaining all the stock information such as item name, quantity, price etc. on sheet, those details can be fetched here and displayed to the visitor. 
  • Copy, paste the below code and changes the sheet ID, name, row range, and connection name. 
  1. //Add a output parameter named "allproducts" and select "Option list" as datatype
  2. google_spreadsheet_id = "1y92rI_ITWLxpXOQMtyO8W9_7P6HwygxfneeVxdoRd-E";
  3. sheet_name = "Fetching+records";
  4. //specify the correct range like "a1:b11"
  5. url = "https://sheets.googleapis.com/v4/spreadsheets/" + google_spreadsheet_id + "/values/" + sheet_name + "!a2:b11?majorDimension=ROWS";
  6. //googlesheets - Connection link name made using the connection interface (Step 1)
  7. apiresponse = invokeurl
  8. [
  9. url :url
  10. type :GET
  11. connection:"googlesheets"
  12. ];
  13. values = apiresponse.get("values");
  14. productList = List();
  15. //Adding all the product and ID in an option list | Ref - https://www.zoho.com/salesiq/help/developer-section/plugs-datatype-optionlist.html
  16. for each  entry in values
  17. {
  18. id = entry.get("0");
  19. product = entry.get("1");
  20. productList.add({"id":id,"text":product});
  21. info productList;
  22. }
  23. response = Map();
  24. //parasing the plug output 
  25. // allproducts - Name of output parameter; productList - Value to be associated to "allproducts"
  26. response.put("allproducts",productList);
  27. return response;
  • Then, click save, preview the plug and publish it. For your reference, we have made the sheet public.
Note: API invoked in the plug spreadsheets.values.get API


  • The above reference shows the spreadsheet ID and the sheet name.
Now, let's look at creating records in Google sheets. Any type of data can be pushed to sheets, such as feedback, comments, etc. 
  •  Copy, paste the below code and change the sheet ID, name, and connection name.
  1. //Add two input parameters named "visitorID","feedback" and select the datatype as "String"
  2. if(session.containsKey("visitorID"))
  3. {
  4. id = session.get("visitorID").get("value");
  5. }
  6. if(session.containsKey("feedback"))
  7. {
  8. feedback = session.get("feedback").get("value");
  9. }
  10. google_spreadsheet_id = "1y92rI_ITWLxpXOQMtyO8W9_7P6HwygxfneeVxdoRd-E";
  11. sheet_name = "Create+records";
  12. //specify the correct range like "A3:B3"
  13. url = "https://sheets.googleapis.com/v4/spreadsheets/" + google_spreadsheet_id + "/values/" + sheet_name + "!A3:B3:append?valueInputOption=USER_ENTERED";
  14. params = {"majorDimension":"ROWS","values":{{id,feedback}}};
  15. apiresponse = invokeurl
  16. [
  17. url :url
  18. type :post
  19. parameters:params.toString()
  20. headers:{"Content-Type":"application/json"}
  21. connection:"googlesheets"
  22. ];
  23. info apiresponse;
  24. response = Map();
  25. return response;
  • Then, click Save, preview the plug and Publish it. For your reference, we have made the sheet public
Note: API invoked in the plug spreadsheets.values.append
 
  •  Navigate to Settings > Bot > Add, provide the necessary information, and select Codeless Bot Builder as a bot platform or open an existing bot.
  •  Select the Plugs under Action Card and select the required plug (Only published plugs will be listed here)
  •  Provide the plug inputs and outputs.
  •  Click Save


In the above video, we've used a plug, fetched some products and displayed them as options to the visitor. 
 
Heads up:
Related links:
To know more about the features of Zobot, kindly visit our Resources Section. 

Best regards,
Sasidar Thandapani



        • Recent Topics

        • Zoho Desk Android app update - Swipe action customization

          Hello everyone! We have brought in support for the swipe action customization in latest version(v2.9.13) of the Zoho Desk Android app update, enabling you to configure left and right swipe gestures on tickets to carry out the actions swiftly without opening
        • Import KB template OR Export template for zoho desk?

          Greetings. Can you tell me if there is a way to get an EXPORT of my KB articles? OR is there a template you supply for importing KB articles into my zoho desk? I am looking for a method of understanding what fields can be imported, and what their possible
        • XML format to import knowledgebase into Zoho Desk

          Hi, We just started to use Zoho Desk and want to import our knowledgebase from our old support system (Freshdesk) to Zoho Desk. Can anyone give us information about the format of xml file to import? There is no explanation on the related page.
        • Zoho Desk integration with Power BI

          Hi, I want to be able to create a Power BI report which has live updates of ticket data from zoho desk, is this possile at all? Thanks Jack
        • Arranging Ticket Templates

          Is there any way to arrange our ticket templates? It doesn't look very organised when it's just arranged according to when they were created. We want the list to look more organised, by arranging/grouping them by topics, or even just by alphabetical
        • New Mandatory One-Click Unsubscribe Link Overshadowing Custom Unsubscribe Link

          I was recently informed by Zoho CRM Support that they are now mandated by the large email service providers like Google and Yahoo to provide a one-click unsubscribe option in the header (not the body) of all mass emails. I have a custom unsubscribe link
        • What they mean with "Portal"?

          I just downloaded this app to take my personal notes on digital art studio because it seemed to me the most comfortable app to do it, I use it very often, what do they mean by “no activity on your portal”? I have about 1 year of work here and I don't
        • Inactive User Auto Response

          We use Zoho One, and we have a couple employees that are no longer with us, but people are still attempting to email them. I'd like an autoresponder to let them no the person is no longer here, and how they can reach us going forward. I saw a similar
        • favorites no longer listed

          Hello, I can no longer navigate to my Favorites from the pulldown at the top of my grid view (see attached screenshot). I wasn't able to find it anywhere! Please help me display my Favorites. Thank you!
        • Notecards Disappeared

          Got a new phone. Downloaded and signed in Zoho Notebook. Not finding the Note cards. Just Empty Note books. Frustrating.
        • Table Errors

          Hello, I'm new to Zoho Notebook and using it on several Mac/Apple devices. My question is regarding tables: Why do they become broken, and how to fix the error without retyping all my data? (Please see the screenshot attached.)
        • Aggregating the First Value in the Group By of a dataset

          Hi I am trying to get the following Aggregate Formula to work in my chart, but cannot seem to get the right format. I have a series of data that I am running an include_groupby and want to SUM only a column in the first row of each group. So for example.
        • Zoho Tables instead of Zoho Creator Spreadsheet reports <3

          That would make my day for sure. Zoho Creator is create, but miss data entering as AirTable/Spreadsheet can. Seeing Zoho putting effort in this makes me think maybe one day we could see a similar interface for Zoho Creator spreadsheet reports. B.
        • Zoho Sheet - Desktop App or Offline

          Since Zoho Docs is now available as a desktop app and offline, when is a realistic ETA for Sheet to have the same functionality?I am surprised this was not laucned at the same time as Docs.
        • Notebook Stack

          Hi Everyone I Hope you´re fine, I´m sorry if this idea was posted before (I made a search but I haven´t find anything related). So, Having the possibility of stacking notebooks would be an interesting way to order notebooks that correspond to the same
        • Writing on sketch cards is bugged when zoomed in

          When zoomed in, it writes a noticeable distance above or to the side of where you're actually trying to write. The further you're zoomed in, the more noticeable it is. Zooming is also entirely absent on the desktop version.
        • Swipe between notes on iPhone

          It'd be convenient if I could move from one note to the next in a notebook simply by swiping left to right.
        • Sales IQ chat is not working in signed android apk

          I have integrated ZOHO sales IQ support chat and i have followed each step and its working fine in my development build but when i create signed APK for it. Chat does not work in it and showing awaiting for detail. I previously asked the same query but
        • COQL order by COUNT not working

          Dear community, I am trying to get a list of deal amounts per planner working on it and sorted to get see who has the least amount of deals. For some reason, I am unable to use sort by in combination with a COUNT. My original code was: query = "select
        • I want to duplicate a report and name it something else

          Hi, I have created a report, and now want to reproduce it and call it something else. so that I will end up with TWO separate reports with different titles. Please tell me how do I copy / reproduce a report please
        • Zoho CRM: Sales Rep Professional Certification Program on Coursera

          We are happy to share that we have published the Zoho Sales Representative Professional Certificate in partnership with Coursera, a leading platform for online learning and career development that offers access to courses and degrees from leading universities
        • OS X Notebook quits immediately upon launch

          NoteBook for OS X (Sequoia, but also under Sonoma) always quits immediately upon launch (so I cannot use the "Attach user log" option). I've restarted my MacBook but the problem persists. If it helps, attached is a diagnostic report from Library>Log
        • Can External users upload files or images to WorkDrive?

          I want to know if it is possible for someone externally through a link and PW be able to upload files and images onto WorkDrive?
        • Multi-line fields character limits

          Is there a way to set the character limit higher on multi-line fields so that we are not losing information pasted into the field? When the text is entered or pasted, there is no error to say that the text is too large. After saving and going back to view most of the text is gone.   Also, when viewing the resume, the text is not wrapped in the multi line fields and can t be read without scrolling across the page.
        • Taz bot not working — What should I do to resolve this issue?

          I am experiencing issues with the Taz bot in Zoho Cliq—not receiving responses or it does not seem to work as expected. Could you please explain why the Taz bot might not be functioning and what steps I should take to resolve this issue? Thank you!
        • Zoho Calendar soft bounce on @hotmail.com and @yahoo.com email addresses

          Hello, our Zoho calendar recently does not send the calendar invites to emails with hotmail and yahoo domains and comes back with a "soft bounce". other domains like Gmail works fine. Also sending "email" to the same emails to the above domains work well
        • OneNote Migration

          I am trying to migrate two notebooks from OneNote. For five days now I have had no notification that migration has completed and the migration page show 50% complete - one notebook completed one not finished. It just stays like this. I am unable to cancel
        • Set various time slot reminders for task and event

          Hi I would like known if there is possibility to set various time reminders for a task or event like we have the possibility to do in google calendar or google task. For example I'am creating an event or task and I want to be alerted before 30min and
        • is it possible to add more than one Whatsapp Phone Number to be integrated to Zoho CRM?

          so I have successfully added one Whatsapp number like this from this User Interface it seems I can't add a new Whatsapp Number. I need to add a new Whatsapp Number so I can control the lead assignment if a chat sent to Whatsapp Phone Number 1 then assign
        • Zoho Calendar not functioning---cannot edit, add attendees, etc.

          Hello, My calendar is acting strange. I'm using Chrome as my browser and pop ups are not blocked (the calendar worked fine yesterday). When creating an event, I'm not able to "edit" the event and add attendees, etc. The link is non-responsive. I cannot
        • Spilt Axis for stacked column and line graph

          Each month around this time I prepare a business review deck. One of the biggest annoyances I have with Zoho, also happens to be something that most other platforms have provided for a long time now, and that is being able to create a chart with stacked
        • Pin a note on top

          Dear Zoho Notebook Team, Please highly consider adding ability to pin a note on top and arrange pinned notes. I have a lot of notes that I want to pin important ones on top and this feature is missing badly. Thank you.
        • Windows 11 app ver 2.2.8

          I have been trialing Zoho Notes syncing between my PC and iphone. No problems with iphone but the Windows 64 bit app ver 2.2.8 was very buggy and would lock up completely, needing a Control Alt Delete etc to close it down. It seemed to be connected to
        • Deluge Script: Onboarding → Access Form

          Hello everyone, Edit: Sorry, I think I put this topic in the wrong section. I’ve recently run into an issue that’s been giving me a bit of a headache for the past few weeks. Context: This is my first time using Deluge to create a script, but it’s not
        • ZOHO BOOKS - EXCESSIVELY SLOW TODAY

          Dear Zoho Books This is not the first time but it seems to be 3 times per week now that the system is extremely slow. I work on Zoho Books 95% of my day so this is very frustrating. Zoho you need to do something about this. I have had my IT guy check
        • Windows Device Authentication

          We have recently started using ManageEngine, and my boss saw a device management feature in the Zoho One directory. We thought it would either help give us more intergration into Zoho one through bringing ManageEngine services through Zoho one. Or, it
        • How can I change spell check language?

          I cannot find the way to change spell check language. My "display language" is English, and I want to have the same one for Spell Check, but it is Russian!!! How can I change it? In one of your explanations you mentioned that I have to choose it from
        • Mail is so slow - doesn't even work!

          Mail has been getting slower and slower - and today it's not even pulling up emails in either Inbox or Unread. This is beyond frustrating since email is a big part of business. Sent a request through the useless help portal - no response. Called the useless
        • User marked as SPAMMER. Mail Fetch has also been disabled for any active POP accounts.

          I am the administrator for joelles.com One of our accounts has been blocked saying this: User marked as SPAMMER. Mail Fetch has also been disabled for any active POP accounts. I cannot change the disabled account in the control panel as it says that it
        • My domain did not activate

          Hi, my domain (apsaindustrial.com.ar) did not activate, and the phone verification message never arrived. Please would you solve this problem? Thanks.
        • Next Page