Skip to content

feat: add Convex backend — private/public APIs, schema, HTTP actions,… - #11

Merged
ladaniprem merged 1 commit into
masterfrom
06-convex-backend
Jul 4, 2026
Merged

ladaniprem merged 1 commit into
masterfrom
06-convex-backend

Conversation

@ladaniprem

Copy link
Copy Markdown
Owner

… playground

Copilot AI review requested due to automatic review settings July 4, 2026 12:19
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@ladaniprem, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 4e295001-2ed4-486a-96f2-5a05e5023ece

📥 Commits

Reviewing files that changed from the base of the PR and between 1da4d58 and d46f4b5.

⛔ Files ignored due to path filters (1)
  • packages/backend/convex/_generated/api.d.ts is excluded by !**/_generated/**
📒 Files selected for processing (21)
  • packages/backend/convex/constants.ts
  • packages/backend/convex/convex.config.ts
  • packages/backend/convex/http.ts
  • packages/backend/convex/playground.ts
  • packages/backend/convex/private/contactSessions.ts
  • packages/backend/convex/private/conversations.ts
  • packages/backend/convex/private/files.ts
  • packages/backend/convex/private/messages.ts
  • packages/backend/convex/private/plugins.ts
  • packages/backend/convex/private/secrets.ts
  • packages/backend/convex/private/vapi.ts
  • packages/backend/convex/private/widgetSettings.ts
  • packages/backend/convex/public/contactSessions.ts
  • packages/backend/convex/public/conversations.ts
  • packages/backend/convex/public/messages.ts
  • packages/backend/convex/public/organizations.ts
  • packages/backend/convex/public/plugins.ts
  • packages/backend/convex/public/secrets.ts
  • packages/backend/convex/public/widgetSettings.ts
  • packages/backend/convex/schema.ts
  • packages/backend/package.json

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@ladaniprem
ladaniprem merged commit 3764e89 into master Jul 4, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Convex-powered backend package, adding schema + generated API types and a set of Convex functions split across public/ and private/ modules, plus integration of the @convex-dev/agent component.

Changes:

  • Add Convex schema tables for contact sessions, conversations, files, widget settings, plugins, and secrets.
  • Add new Convex queries/mutations/actions for widget settings, secrets, plugins, conversations, contact sessions, files, and agent-backed messaging.
  • Wire up Convex app configuration to include the @convex-dev/agent component and update generated API typings.

Reviewed changes

Copilot reviewed 18 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/backend/package.json Adds @convex-dev/agent dependency for agent-backed messaging.
packages/backend/convex/schema.ts Defines new tables used by the Convex backend.
packages/backend/convex/public/widgetSettings.ts Public query to fetch widget settings by organization.
packages/backend/convex/public/secrets.ts Public secret upsert and Vapi secret retrieval endpoint.
packages/backend/convex/public/plugins.ts Public plugin read/remove endpoints (org-scoped).
packages/backend/convex/public/organizations.ts Public organization “validate” action.
packages/backend/convex/public/messages.ts Public agent-backed message list/create endpoints.
packages/backend/convex/public/conversations.ts Public query to fetch a conversation if it matches a contact session.
packages/backend/convex/public/contactSessions.ts Public contact session create/get/validate endpoints.
packages/backend/convex/private/widgetSettings.ts Private org-scoped widget settings read/upsert endpoints.
packages/backend/convex/private/vapi.ts Private actions to call Vapi API using server API key.
packages/backend/convex/private/secrets.ts Private secret upsert endpoint (org-scoped).
packages/backend/convex/private/plugins.ts Private plugin read/remove endpoints (org-scoped).
packages/backend/convex/private/messages.ts Private agent-backed message endpoints + OpenAI response enhancement action.
packages/backend/convex/private/files.ts Private file list/add/delete endpoints backed by Convex storage.
packages/backend/convex/private/conversations.ts Private conversation list/get/updateStatus endpoints (includes last-message lookup).
packages/backend/convex/private/contactSessions.ts Private query to fetch contact session by conversation id.
packages/backend/convex/convex.config.ts Registers the agent component with the Convex app.
packages/backend/convex/_generated/api.d.ts Updates generated API module typings to include the new modules.
packages/backend/convex/playground.ts Present in PR context (contents not provided in prompt).
packages/backend/convex/http.ts Present in PR context (contents not provided in prompt).
packages/backend/convex/constants.ts Present in PR context (contents not provided in prompt).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +4
import { query, action } from "../_generated/server";
import { v } from "convex/values";
import { paginationOptsValidator } from "convex/server";
import { listMessages, saveMessage } from "@convex-dev/agent";
Comment on lines +1 to +4
import { query, mutation, action } from "../_generated/server";
import { v } from "convex/values";
import { paginationOptsValidator } from "convex/server";
import { listMessages, saveMessage } from "@convex-dev/agent";
Comment on lines +44 to +52
handler: async (_ctx, args) => {
const { prompt } = args;
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
},
body: JSON.stringify({
@@ -0,0 +1,63 @@
import { action, mutation } from "../_generated/server";
Comment on lines +39 to +63
export const getVapiSecrets = action({
args: {
organizationId: v.string(),
},
handler: async (ctx, args) => {
const { organizationId } = args;

const secret = await ctx.db
.query("secrets")
.filter((q) =>
q.and(
q.eq(q.field("service"), "vapi"),
q.eq(q.field("organizationId"), organizationId),
),
)
.first();

if (!secret) {
return null;
}

const value = secret.value as { publicApiKey?: string };
return value.publicApiKey ? { publicApiKey: value.publicApiKey } : null;
},
});
Comment on lines +20 to +25
handler: async (ctx, args) => {
const result = await ctx.db
.query("files")
.order("desc")
.paginate(args.paginationOpts);

Comment on lines +48 to +60
handler: async (ctx, args) => {
const { bytes, filename, mimeType, category } = args;

const storageId = await ctx.storage.store(bytes);

const fileId = await ctx.db.insert("files", {
name: filename,
type: mimeType,
size: bytes.byteLength,
storageId,
category,
organizationId: "",
});
Comment on lines +70 to +79
handler: async (ctx, args) => {
const { entryId } = args;
const file = await ctx.db.get("files", entryId);
if (!file) {
throw new Error("File not found");
}

await ctx.storage.delete(file.storageId);
await ctx.db.delete("files", entryId);
},
Comment on lines +32 to +36
const lastMessage = await ctx.db
.query("messages")
.withIndex("by_threadId", (q) => q.eq("threadId", conversation.threadId))
.order("desc")
.first();
Comment on lines +4 to +8
export const getAssistants = action({
args: {},
handler: async () => {
const apiKey = process.env.VAPI_API_KEY;
if (!apiKey) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants