Polls in RocketChat

Wajeeh Ahsan
1 min readOct 12, 2020

--

Here you will find information on how to install and use the Poll App inside the Rocketchat.

Prerequisite

Your work space must be registered in rocketchat cloud console.

Installation

You can install our Poll Rocket.Chat App from your Rocket.Chat Administration area.

  • Go to Administration > Marketplace
  • Search for the Poll app and click on the item
  • Click on the Install button

Then

  1. Administration -> Integrations -> New Outgoing Webhook Integration
  2. Enabled: true
  3. Channel: leave blank or set the channels (comma separated) you want this enabled in
  4. Trigger Words: !poll
  5. URLs: https://dev.null
  6. Post as: rocket.cat
  7. Alias: Rocket Poll
  8. Avatar URL: https://cdn2.iconfinder.com/data/icons/Siena/256/poll%20green.png
  9. Script Enabled: true
  10. Script: Paste the script below into this item
  11. Save
class Script {
@params {object} request
prepare_outgoing_request({ request })
{
const emojis = [
':zero:',
':one:',
':two:',
':three:',
':four:',
':five:',
':six:',
':seven:',
':eight:',
':nine:',
':ten:' ];
let match;
match = request.data.text.match(/((["'])(?:(?=(\\?))\3.)*?\2)/g);
let title = '';
let options = [];
match.forEach((item, i) => {
item = item.replace(/(^['"]|['"]$)/g, '');
if (i === 0) {
title = item;
} else {
options.push(emojis[(options.length + 1)] + ' ' + item);
}
});
return {
message: {
text: '_Please vote using reactions_',
attachments: [
{
color: '#0000DD',
title: title,
text: options.join('\n')
}
]
}
};
}
process_outgoing_response({ request, response }) { }
}

Usage

In type message section, run this command accordingly to create a poll.

Usage: !poll "question?" "option 1" "option 2"

--

--

Wajeeh Ahsan
Wajeeh Ahsan

No responses yet