I built a one click order fulfillment process into a discord bot for automated shipping label purchase, back-up, and printing along with custom generated packing slips enabled by an LLM to make the shipping method selection resulting in a 44% boost in order processing speed and 71% decrease in user interaction per order, as well as combining both the Etsy and eBay order feeds into one process.
Anything’s a problem if it gets 100x bigger
To fulfill each Etsy transaction via their online shop manager takes 14 clicks to complete and print, and about 45 second on average to purchase, print, and save the labels. Individually not long to do, but what if you had a hundred? After starting up my Etsy shop and gaining some traction and daily orders, I recognized the repeated motion of getting the shipping label to generate, then to print and back it up and all that work. I saw the tradjectory of where this could head to and how just purchasing and printing shipping labels could end up taking some nontrivial portion of my day, so I turned to automation and coding for a solution.
Automated with some oversight
To accomplish this task of a system to automate fulfillment, I knew I wanted a chatbot style interface I could host in the background and command to start from any device, leading me to develop this project as a Discord bot that is run in a Docker container in my homelab. This was also around the beginnings of when AI was now being used as a new tool in the arsenal for specific tasks, where this one seemed like an incredible one. Essentially with LLMs being next token predictors, given a context of what the available rates are and what the customer has paid, it can make an accurate determination of the correct shipping rate.
To get the order and item information the Etsy API was used (then including eBay API as that grew), allowing me access order data and also update shipping status with third party purchased shipping label info. To get shipping labels without clicking anything another API was involved, ShipStation API (formerly ShipEngine). By inputting the my sender info and the buyers info as well as specifics about the package such as package type and dimensions, an array of rates are returned that can be selected from in varying prices. This now tells our program the necessary information we want; how much did the customer pay for shipping, and what’s the rates available.
By then taking that data fed as a prompt to an LLM, the correct shipping rate can be identified and programmatically chosen by the AI. This allows for wide flexibility in the data, even allowing the model to identify when the input data is missing and can’t give a confident answer. For the initial version of the project I had an additional approval step to ensure the AI did in fact make the correct choice before actually allowing it to purchase it. This allowed one last line of defense against hallucinations when tuning the model choice and parameters to work with best reliability and latency. Once a strong favorite model and configuration was tested to be reliable the final approval step was removed to get the advertised speed improvements over the standard Etsy website, and has not yet made an error in the selection other than intentionally throwing an error when no clear solution was present.
The bot is set to not handle international orders when they pop up, and the process is triggered by an integrated discord command !fulfillx and then one by one each order will be shown in chat asking to fulfill (‘yes’), exit (‘no’), or skip (‘skip’). If the order is ready to be sent out it’ll be confirmed with a ‘yes’ in chat and the rate comparison, purchase, printing, and backup is all done automatically before presenting the next order, ready to continue one after another until the end of the available orders.
Results and impact
Compared to the manual method of purchasing and processing labels for sending out orders I was able to achieve a 44% speed boost from around 45 seconds to 25 seconds on average. Hosting the application as a Discord bot allowed for it to be accessible to complete orders from devices such as my phone outside my home network, a capability not easily possible with Etsy’s integrated setup. For physical burden on the user to accomplish all steps with over a dozen clicks and keystrokes for each order a 71% reduction was achieved from 14 to 4. By moving order completion and label processing to a separate system, it was possible for me to integrate order completion on eBay as well as Etsy. This allowed me to simultaneously check both marketplace order queues anywhere without having to log into either one streamlining my productivity and decreasing time clicking through websites.
A future version of this would integrate with an inventory keeping system to check against before completing, and completing all eligible in-stock orders at once, in larger batches with multi-threading to allow for multiple fold increases in speed. However at 25 seconds per order I am already outpacing my label printer, and there is not much of a desire to go much faster than this for now.
What I learned
APIs are awesome. This was my first larger project that involved not just one notable API or library. This one was a combination of using requests in Python to interact with standard web APIs from ShipEngine, Etsy, and eBay, and specialized libraries like that by openai for GPT model completions integration for shipping decision or crewai for building out workflows of multiple steps. This also taught me some lessons in testing and writing prompts for repeatable performance from an LLM, as well as some A/B comparisons between models of varying sizes to gauge how well smaller models handle at this use case and their resulting accuracy.
