potatonator
- 4 Devlogs
- 2 Total hours
š„ Potatonator is a fun, potato-powered Slack bot that brings games, randomness, and potato chaos to your workspace.
š„ Potatonator is a fun, potato-powered Slack bot that brings games, randomness, and potato chaos to your workspace.
I added the /potatonator-explore command, which is the first real gameplay feature for Potatonator.
The idea is that users can send their potato on a random adventure. Each adventure gives the potato XP and coins.
I created a new /explore endpoint in the Cloudflare Worker and added several random events, such as finding treasure, discovering golden potatoes, finding coins, or fighting a carrot.
At first, the API only returned the XP and coins without saving them. I then added a coins column to the D1 database and updated the endpoint so the rewards are permanently saved.
There were a few small issues along the way, including accidentally trying to add the coins column twice, which resulted in a duplicate-column error. Since the first command had already worked, the second one wasnāt needed.
After testing the API locally, I connected /explore to Slack and deployed the updated Cloudflare Worker.
I also updated /potatonator-profile so it displays the coins earned from exploring.
I added the /potatonator-profile command.
The goal was to let users view the potato they adopted and all of its stats.
First, I created a new /profile endpoint in the Cloudflare Worker. It takes the userās Slack ID and searches the D1 database for their potato.
I also connected the endpoint to index.ts so Cloudflare knows about the new route.
There was a small issue where the /profile endpoint wasnāt appearing in the API documentation. Turns out VS Code hadnāt properly saved the changes, so after saving a few more times, it worked.
I then tested the endpoint using PowerShell and confirmed that it could retrieve the saved potato.
Finally, I connected the API to the Slack bot using Axios. The bot sends the userās Slack ID to the API, which retrieves their potato from D1 and sends the information back to Slack.
The command now displays:
š„ Potato name
Type
Rarity
āļø Power
š„ Crunch
š Luck
ā Level
⨠XP
After testing it in Slack, /potatonator-profile worked successfully.
Potatonator now has both potato adoption and profiles, giving us the foundation for adding actual gameplay features next. š„
I started this project with the goal of making a Slack bot that could respond to custom slash commands. I wasnāt sure what the bot should actually do, so I decided to make it potato-themed and named it Potatonator.
I started with basic commands like:
/potatonator-ping
/potatonator-help
/potatonator-potatofact
For the potato facts, I first learned about APIs and Axios, which lets the bot make requests to an API. I originally considered using an existing API, but decided to make my own potato API instead.
I first ran the API locally, but realized that meant it wouldnāt work when my PC was turned off. I decided to move it to Cloudflare Workers, which gave me a permanent URL:
https://potatonator-api.potatonator.workers.dev
I then connected my Slack bot to this API.
After that, I wanted Potatonator to become more like a game, so I created /potatonator-adopt. Users could permanently adopt a randomly generated potato with stats such as:
Name
Type
Rarity
Power
Crunch
Luck
Level
XP
To save this information, I added a Cloudflare D1 database.
There were a few mistakes along the way. I initially ran a command from the wrong folder, and later discovered that my local D1 database didnāt have the table even though the remote database did. I also had an issue where Axios treated the āalready have a potatoā response as an error. After fixing these, everything worked.
Now /potatonator-adopt successfully creates a potato and remembers it even after the bot restarts.
Next, Iām planning to add /potatonator-profile, which will let users view their potato and its stats.
Created the bot on slack and then I added the code to vs code. I tested the first ping command which resulted in a success!