If you already have a Convex project, here's the easiest way:
- Go to https://dashboard.convex.dev
- Select your project
- Click on Files in the sidebar
- Create/edit these files:
Click "New file" → Name it schema.ts in the convex folder
Paste this:
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
export default defineSchema({
tickets: defineTable({
from_name: v.string(),
question: v.string(),
timestamp: v.string(),
}),
});Click "New file" → Name it mutations.ts in the convex folder
Paste this:
import { mutation } from "./_generated/server";
import { v } from "convex/values";
export const addTicket = mutation({
args: {
from_name: v.string(),
question: v.string(),
timestamp: v.string(),
},
handler: async (ctx, args) => {
return await ctx.db.insert("tickets", {
from_name: args.from_name,
question: args.question,
timestamp: args.timestamp,
});
},
});- Click Deploy button at the top
- Done!
If you prefer the terminal:
- Install:
npm install -g convex - Run:
npx convex dev - It will prompt you to log in with GitHub
- Select your existing project
- Copy the schema and mutations files above
- Run:
convex deploy
- Netlify Dashboard → Your site → Site settings → Environment variables
- Add:
CONVEX_DEPLOYMENT=https://your-project.convex.cloud- Replace
your-projectwith your actual Convex deployment URL
- Replace
- Save
Now when someone submits a ticket, it will:
- Print on your Pi
- Be saved to Convex
- Be viewable in your dashboard