WIP Project Code at https://github.com/AnaCoda/Discord_NLP_Reminder_Bot_Public
Over summer, I participated in an AI4All summer camp during which I was lucky enough to win a free NVIDIA Jetson Nano during a talk by the director of AI at NVIDIA. After the camp and receiving the Jetson, I was wondering how I could use some of the new AI knowledge I gained at the camp while learning to use the Jetson, so I decided on this project.
To parse natural language, I came across and tried a few possibilities. Some of them were very complicated, involving vectorizing and maximum entropy models. I was able to get some results with these methods, but they seemed to be overfit and it would have taken me a lot of trial and error to get a usable version of it.
Instead, I decided on a much more simple method (which I learned from the CS50x AI course): using regex to find templates from a list of sample inputs. For example, from "remind me to eat lunch at noon" and given that the subject is "eat lunch" and the time is "noon", the template finder may decide that subjects can occur after "remind me to" and that times can occur after "at". This method is more effective than I expected, although not completely optimal.
I found that with templates, for many examples it will find more than two keywords (for example, if your input contains "on Tuesday at 10", because it contains two time keywords "on" and "at") and it will extract more than one possibility. To enable the user to choose which one they want, the bot sends a message with the choices and the user reacts with the one that they want. There is an example in the images below.
After that, it was a lot of fiddling with the discordpy library to figure out how to deal with bot-user interaction. I was thinking about storing the reminders in a file on the Jetson to read if the bot needs to restart, but I thought it would be more interesting to store it on Discord itself. To do so, I created a private text channel that the robot sends reminder information to (and deletes when no longer needed). This does come with security risks, as all the reminders could be read by the owner of the server, but few modifications would be required to save the information to a local file instead (or some sort of secure cloud storage).
Parsing the reminder time is simply handled by the parsedatetime library.
The actual reminder timing is handled by the Asyncio library. I run a periodic task to check if the next reminder is near in time, and start a timer if it is. It sends a message to the user and the user has 30 seconds to send a message if they want to snooze it (hoping to figure out a way to extend this time).
Working on this with the Jetson Nano was easier than expected; it runs off an SD card with Linux on it and is pretty fully-featured (it can also work with an SSD). I connected it to a monitor and a keyboard, and was able to get VSCode working on it from this tutorial. It runs quickly, and although this isn't a very heavy project, I tried some computer vision examples from their developer resources and was impressed with the performance.
Here are some pictures to show it in action: