Discord Scheduling Bot
Discord has for many years been popular in the gaming community. But due to the explosion of Remote Work and Work From Home opportunities, it's strongly competing in the business world with tools like Slack, Google and Zoom.
YouTube Demo: https://www.youtube.com/watch?v=e5SpHXVMlKw
You can join our Discord server and try this bot yourself: https://discord.gg/j3gd5Qk5uW
We love Discord at Spurwing, it provides all features we need for free: text and voice channels, video calls, video conferencing, screen sharing and recently the addition of stage channels. You can emulate an office experience with these channels, an ideal solution for a conservative managers.
On top of that it provides a superb API, developer community and resources for building bots and automation solutions. The business of scheduling appointments and managing calendars is a complex one, fortunately Spurwing helps simplify and streamline just that.
In this article I'll share our simple solution for scheduling appointments on Discord. The full code is available on our GitHub repository. This Discord Bot is connected to our Spurwing API for scheduling appointments and managing our calendar.
A discord bot is a piece of code that listens to text (or voice) data and can then respond however you program it. The easiest way to call/use a bot is to use a prefix character like ! or *. To see all available commands we can enter !help:
The second command we can use is !slots [date]. This returns a list of bookable slots on our calendar:
Do note that these slots contain a timezone offset +0200 which means GMT+2. This timezone depends the local time of the machine hosting your bot. But we can also provide a custom timezone or offset to see the times relative to your own location:
If there are no bookable slots available for a certain date then you'll receive an error message:
Now that we are able to find bookable slots, we can start scheduling appointments using our third command !book [slot] [@email]. You can use one of the slots as [slot] argument or provide a custom Date and Time, as long as it will evaluate to valid and bookable slot:
Once again if booking fails you will be given an error:
These three simple commands allows Discord users to schedule simple 1-on-1 appointments with you. In the next sections we'll explain how to install and configure this bot, but also how to customize it for 1-to-many appointments and incorporate multiple calendars.
- NodeJS v12.x or v14.x is highly recommended
- If you don't have a Discord Bot yet, follow step 1 of this tutorial to obtain your bot's token and adding the bot to your Discord server.
- Clone, fork or download our repository: https://github.com/Spurwing/Chat-Bot-Integrations/
- Navigate to /Discord/NodeJS/ and execute npm install
- Copy the file config.sample.js to config.js and edit it
- Provide your Discord Bot Token
- Provide your Spurwing Provider Id
- Optionally provide a Spurwing Appointment Type Id
- Run the bot: node index.js
- Optionally use PM2 or nodemon to keep the bot running 24/7
Upon successful connection you should see a message like:
If you didn't provide an Appointment Type Id, the code will fetch a random one from your Spurwing account. Each appointment type has an associated duration (15min, 30min, 45min, ...). Our API uses it to generate bookable slots.
This bot is merely a basic implementation for demo purposes. We can extend it with more advanced features to facilitate Calendar Management, Group Bookings, Reminders, Sending Emails, Voice Commands and more.
The Spurwing Provider ID (PID) represents an individual calendar. You can extend the bot to keep a mapping of Discord Members and their PIDs. If your Spurwing account has Organizational privileges then you can create multiple accounts (and thus PIDs) for all your members. Each calendar can also be two-way synced with any third-party email provided (Gmail, Outlook, Apple).
Our demo bot only allows for 1-on-1 bookings, hence the single [@email] argument for the !book command. You can extend that command to allow a list of email addresses.
Alternatively you can create a mapping of Discord Members and their email addresses. Now instead of providing their emails explicitly to the command you can use the @username notation by Discord.
To incorporate automated reminders, either as public announcements or private messages, you make the bot poll for all calendar events (every minute or so). And based on your preferences make it send reminders to all participants.
We already have a Spurwing Library for sending emails using the SMTP protocol. Our iCalendar Library Repository contains all the logic you need inside index.js, in particular the sendMail function which you can re-use here.
The thing I love about Discord the most are its voice channels. It's just a virtual place you can join and talk to everyone inside the channel. No annoying meeting links needed to instantly hop on a call with someone.
A Discord Bot can also join a voice channel and listen to all speakers individually (but can also send audio data). One of my personal open-source projects DiscordEarsBot uses NLP and Machine Learning to transcribe and interpret what is being said. This solution is pretty accurate and supports 32 of languages. You can use that solution for adding Voice Commands or generated suggestions based on what is being said during a conversation:
Another cool UX improvement to the !book [slot] ... command is to make return a few bookable slots if it fails to schedule for the [slot] you provided.
Discord Bots are amazing tools that can help us automate tasks and be more productive at our daily business. If you enjoy our content, make sure to give us a star on GitHub and follow us for more. Visit Spurwing and schedule a free demo today. Have a great day!