An AI Order Returns Assistant widget for the Medusa admin. You can use natural language to explain the situation, and it will extract all necessary data to create the return order. Built with Medusa UI, OpenAI, and Vercel AI SDK.
Feel free to take this code and use it to create any Medusa AI assistant you need. By editing the system prompt in src/api/routes/admin/completion/order-returns.ts
and the functions in src/util/gpt-functions/returns.ts
and src/admin/widgets/assistants/order-assistant.tsx
, you can change its behavior and give it access to different admin hooks.
Disclaimer: this code is the result of my experimentation, and is by no means optimized or actively maintained.
Screen.Recording.2023-10-11.at.18.39.45.mov
- This widget requires an OpenAI platform account and API key. Go to https://platform.openai.com/account/api-keys to set this up.
- You need a valid Medusa database. The fastest way to set this up is by using create-medusa-app.
- Clone repo and install dependencies.
- In your
.env
file, add anOPENAI_API_KEY
environment variable containing your API key, and link your database:
OPENAI_API_KEY=<YOUR OPENAI API KEY>
DATABASE_URL=<YOUR MEDUSA DB URL>
- Start your dev server and log into the admin. Open any order details page and the widget will appear on the bottom of the page!