The Slash Command Series - Build a command to create polls!

The Slash Command Series - Build a command to create polls!

Your team has decided to go for lunch and you're in charge of the menu. But before you decide on the menu, it's important to know their preferences. For instance, what if somebody is vegan and you haven't taken that into account!

Now now, we know hard it is to arrange the menu for a small group of 4, let alone for 50.   How can Cliq help this situation you may ask? Ah, simple. Create a poll using Cliq's slash commands!

With /poll command you can just post a message in channel, ask everybody to vote and get the list. The /poll command  helps you collect data, interpret, analyze and make a decision. Let's take a look at the command workflow, it's pretty easy. :D  

Command Workflow  

The command syntax would be   /poll -topic" " - optn " " 

The user would have to just specify the question (topic) and options in the command syntax and execute the command in a chat window. A poll message card is posted with the question and the options as buttons. Now, to wait for everybody to take their pick! 

The poll question and the options are stored as records in Zoho Creator and when an option is chosen, the selection made is also stored as a record.

To put it in a nutshell, this command is a classic example of multiple workflows and integration with other Zoho Products ( i.e Zoho Creator) 

Now there are four parts to the command execution- three in Cliq and one in Creator. Breaking down the command creation and execution  

Store the questions and results - Creator Application 

  • Create an application in Zoho Creator - Refer this  How to create an application help page in Zoho Creator. 
  • Create two forms - for Poll Questions and one for the Poll Results with the necessary fields. 
  • Use the zoho.creator.createRecord task and zoho.creator.getRecord task in your command and function execution code to create and get records from Creator.  Refer this  help page  

Sample Syntax for the create record task :

 

zoho.creator.createRecord("ownerName","appLinkName","formLinkName",dataMap,"connectionLinkNam", userAccess )

 

Get the owner name, appLinkName and formLinkName from the creator application URL. 

 

URL Format:  https://app.zohocreator.com/ownerName/appLinkName#formLinkName

 

Sample URL:  https://app.zohocreator.com/scottfisher5/poll-command#Questions

 

Note: We've attached a sample Poll application file for you. Download and import this file in your creator account to get an idea of the Poll application. 

Connect to the storage - Cliq Connections (authenticated)

Connections are used to integrate your application with other Zoho Applications or Third Party Web Services in an authenticated manner. 

Create a connection to invoke operations on the Creator Application from Cliq, using Cliq Platform. Use the connectionLinkName and define the userAccess parameter in the creator deluge tasks. 

Share the poll with  a group - Cliq commands 

Create a poll command and specify the command parameters. Command parameters will help fetch the question and the options given by the user in the poll. 

The command execution code is attached here. Copy the code in your deluge editor and try executing the command!


  1. message = Map();
  2. card = Map();
  3. card.put("theme","poll");
  4. b = options.get("Topic");
  5. a = options.get("Optn");
  6. buttonnames = a.toList(",");
  7. info buttonnames.size();
  8. card.put("title","POLL");
  9. message.put("text",b);
  10. dataMap = {"Question":options.get("Topic"),"Answers":options.get("Optn"),"Creator":user.get("email")};
  11. respFromCreator = zoho.creator.createRecord("ownerName","appLinkName","formLinkName",dataMap," connectionLinkName ",  
  12. userAccess );
  13. creatorId = respFromCreator.get("values").get("ID");
  14. buttons = List();
  15. for each  name in buttonnames
  16. {
  17. button = {"label":name,"hint":"Choose an option.","type":"+","action":{"type":"invoke.function","data":{"name":"FunctionName","owner":"yourname@yourdomain.com"}},"key":creatorId};
  18. buttons.add(button);
  19. }
  20. info buttons;
  21. if(buttons.size() > 0)
  22. {
  23. button = {"label":"View Result","hint":"Select an option.","type":"+","action":{"type":"invoke.function","data":{"name":"FunctionName","owner":"yourname@yourdomain.com"}},"key":creatorId};
  24. buttons.add(button);
  25. }
  26. info creatorId;
  27. card.put("thumbnail","<insert_image_url>");
  28. message.put("card",card);
  29. message.put("buttons",buttons);
  30. message.put("card",card);
  31. //aa = zoho.cliq.postToChat(chat.get("id"),message);
  32. info message;
  33. return message;

Variables used in the code

Line no 12: You'll find these in your creator application URL

Line no 18 & 24: Give your function name and email ID.

Poll Votes and Results - Cliq Buttons and Functions

  Functions work in association with buttons. Our aim for the function here should be  

  • To allow users to select an answer and store the selection in Creator.
  • To get the list of all answers for the poll when a user clicks the 'View Result' button.
  • To restrict users from answering a poll more than once. 

When a user clicks the 'View Result' option, the function will get records from Creator to display the total number of responses received for the poll. (u se the button name as the criteria for this)

Likewise, when a user tries responding to the poll twice, use the parameter 'Key' to identify if the user has already responded. If yes, then go ahead and show an error message. If no, take the user's response to the poll. 

That sure was a lengthy read. Well, have a look at this video for better understanding! 

So what are you waiting for? Go on and create a poll! Let us know how this command helps you and your team. 

If you're new here, welcome! Take a look at our slash command guide . You can also learn how to connect to accuweather.com and get weather forecast right inside your chat window. Cool right? Then, check this out !

Questions and discussions are welcome!

Until next time,

Manasa

Cliq


 

 

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation
                                              • Sticky Posts

                                              • Convert a message on Cliq into a task on Zoho Connect

                                                Message actions in Cliq are a great way to transform messages in a conversation into actionable work items. In this post, we'll see how to build a custom message action that'll let you add a message as a task to board on Zoho Connect. If you haven't created
                                              • Cliq Bots - Post message to a bot using the command line!

                                                If you had read our post on how to post a message to a channel in a simple one-line command, then this sure is a piece of cake for you guys! For those of you, who are reading this for the first time, don't worry! Just read on. This post is all about how
                                              • Cliq Bots - How to make a bot respond to your messages?

                                                Bots are just like your buddies with whom you can interact. They carry out your tasks, keep you notified about your to-dos and come in handy when you need constant updates from a third party application.  So, how can you make your bot respond to a message? The bot message handler is a piece of code triggered when a message is sent to the bot. Message handlers help you customise your bot responses to make it look conversational. The message input from the user can be either a string or an option selected
                                              • Cliq Bots - Get notifications about any action on an application with the incoming webhook handler!

                                                Webhooks can be used to get notified about events happening in other applications inside Cliq. All bots in Cliq have their own incoming webhook endpoint. This makes it simple to post messages to the bot from external applications. Unlike the send message
                                              • The Slash Command Series - Types of Command Suggestions

                                                Hi Everybody! I hope you guys tried the /zdocs command and now have an idea of how command suggestions with click to execute work. If you have no clue of what command suggestion is, I recommend you to take a look at all the Slash Command Series posts, especially the one on Command Suggestions ! This post is all about the different types of command suggestions.  Customise your command suggestions  Did you know you could customise your command suggestion list with a title, description, image? Well,


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now