Turbocharge Your Rocket.Chat with Bulk Emoji Uploads: Introducing the Ultimate Emoji Management Tool

anefzaoui

Ahmed Nefzaoui

Posted on April 17, 2023

Turbocharge Your Rocket.Chat with Bulk Emoji Uploads: Introducing the Ultimate Emoji Management Tool

Introduction

As a newcomer to the world of dev.to, I am excited to share my first article with you all. In this piece, I'll introduce you to my nifty little tool I developed to address a common pain point for Rocket.Chat users: managing custom emojis. The Rocket.Chat Emoji Bulk Upload tool streamlines the process of adding custom emojis, enabling you to create more personalized and engaging chats with ease. I'll dive into the inspiration behind the project, the key features of the tool, and how you can start using it to enhance your Rocket.Chat experience.

The Inspiration

I own a web development agency, we use Rocket.Chat for our internal communication, so it all started when I finally gave up and admitted that adding custom emojis to my Rocket.Chat instance was a cumbersome and time-consuming task. Each emoji had to be uploaded individually, making it a long and tedious process. I knew there had to be a better way.

The idea sparked in my mind – why not create a tool that allows users to upload emojis in bulk? This would not only save time, but it would also empower community admins and users alike to personalize their chats and enrich their messaging experience.

The Road to Finding the Perfect Solution

The first step was to analyze the problem and outline the requirements of the solution. I had to ask myself, "What features would make the perfect bulk emoji uploader?" After some contemplation, I identified the following key components:

  1. Simple user interface
  2. Compatibility with multiple emoji formats
  3. Easy integration with existing Rocket.Chat instances
  4. Extensive error handling

With these features in mind, I began my research. I delved into Rocket.Chat's API documentation and various libraries, seeking inspiration and guidance. The journey was not without challenges, but I eventually found a way to bring my vision to life.

The Solution: Rocket.Chat Emoji Bulk Upload Tool

The Rocket.Chat Emoji Bulk Upload tool is a NodeJs script that allows users to upload emojis to their Rocket.Chat instance in bulk. It takes care of authentication, file format conversion, and error handling, ensuring a smooth and effortless process.

The script consists of several modules that handle different aspects of the process:

  1. Authentication: The script uses Rocket.Chat's REST API to authenticate the user and obtain the necessary permissions to upload emojis.
  2. Directory Traversal: The script scans the specified source directory and identifies supported emoji files (PNG, JPEG, and GIF) to be uploaded to the Rocket.Chat instance.
  3. Upload: The emojis are uploaded to the user's Rocket.Chat instance using the API, with error handling and feedback to ensure a smooth experience.
  4. User Interface: A clean and intuitive command-line interface guides users through the process, allowing them to specify their credentials, target server, and source directory containing the emojis.

To make this tool accessible to as many users as possible, I open-sourced the repository on GitHub, providing clear documentation and installation instructions.

Usage

Usage

To start using the Rocket.Chat Emoji Bulk Upload tool, follow these simple steps:

  1. Clone the repository: First, clone the GitHub repository to your local machine.
git clone https://github.com/anefzaoui/rocketchat-emoji-bulk-upload.git
Enter fullscreen mode Exit fullscreen mode
  1. Install dependencies: Navigate to the project directory and install the required dependencies using npm:
cd rocketchat-emoji-bulk-upload
npm install
Enter fullscreen mode Exit fullscreen mode
  1. Create .env file: In the project directory, create a .env file and add your Rocket.Chat instance URL, username, and password in the following format:
ROCKETCHAT_URL=YOUR_ROCKETCHAT_URL
ROCKETCHAT_USER=YOUR_USERNAME
ROCKETCHAT_PASSWORD=YOUR_PASSWORD
Enter fullscreen mode Exit fullscreen mode
  1. Prepare the YAML file: Create a YAML file on a remote server, containing the URLs of the custom emojis you want to upload. The YAML file should follow this structure:
emojis:
  - name: emoji_name1
    url: https://example.com/emoji1.png
  - name: emoji_name2
    url: https://example.com/emoji2.jpg
  - name: emoji_name3
    url: https://example.com/emoji3.gif
Enter fullscreen mode Exit fullscreen mode

PS: there's a good list of YAML files with emojis in the repo's readme, don't forget to check them out!

  1. Run the script: Execute the script using the following command:
node import-custom-emojis.js
Enter fullscreen mode Exit fullscreen mode

The script will prompt you to enter the URL of the remote YAML file containing your custom emojis.

The script will authenticate with your Rocket.Chat instance, fetch the custom emojis from the remote YAML file, and upload them using the API. You'll receive feedback about the progress and any errors that may occur during the upload process.

Once the script completes, you can navigate to your Rocket.Chat instance's custom emoji management page to view and use your newly uploaded emojis. Enjoy a more personalized and engaging chat experience with your custom emojis at your fingertips!

Getting Technical

To give you a glimpse of the technical side, let's go through the main components of the script.

  1. Configuration: The script requires the user to provide their Rocket.Chat instance URL, username, and password. These credentials are passed either as command-line arguments or in a .env file, keeping the process straightforward and secure.

  2. Authentication: I chose the requests library to interact with Rocket.Chat's REST API. Upon successful authentication, the script receives an auth token and a user ID, which are required for subsequent API calls.

  3. Emoji Processing: The os and PIL libraries are utilized to traverse the source directory, identify supported emoji files, and convert them into the required format. The script also handles naming conflicts and ensures that emojis adhere to Rocket.Chat's naming conventions.

  4. Bulk Upload: With the emojis processed and ready, the script uploads them to the Rocket.Chat instance by making API calls with the necessary headers and payloads. It also provides progress updates and handles any errors that may arise during the upload.

Conclusion

The Rocket.Chat Emoji Bulk Upload tool has come a long way from its initial conception. It is now an indispensable tool us, making the process of adding custom emojis a breeze.

With its ultra simple approach, compatibility with multiple emoji formats, and easy integration with existing Rocket.Chat instances, the tool has received a positive response from the the admins in our Rocket.Chat instance. And now the GitHub repository is available for everyone to use, contribute, and share their ideas for future improvements.

So go ahead, try out the Rocket.Chat Emoji Bulk Upload tool, and enhance your chat experience with a world of custom emojis at your fingertips. And don't forget to share your experience and suggestions – your feedback is invaluable in refining and perfecting this remarkable tool!

💖 💪 🙅 🚩
anefzaoui
Ahmed Nefzaoui

Posted on April 17, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related