Skip to content

VariableVic/medusa-ai-assistant

Repository files navigation

Medusa logo

Medusa AI Order Returns Assistant

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.

Follow @VariableVic

Screen.Recording.2023-10-11.at.18.39.45.mov

Prerequisites

  1. This widget requires an OpenAI platform account and API key. Go to https://platform.openai.com/account/api-keys to set this up.
  2. You need a valid Medusa database. The fastest way to set this up is by using create-medusa-app.

Getting Started

  1. Clone repo and install dependencies.
  2. In your .env file, add an OPENAI_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>
  1. 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!

Releases

No releases published

Packages

No packages published