The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
don't route failed partner payouts to the program's support team
Pedro Ladeiracc18c5411fa6
diff --git a/apps/web/lib/ai/build-system-prompt.ts b/apps/web/lib/ai/build-system-prompt.tsindex 158bb0c8b1..bfbbc9bfba 100644--- a/apps/web/lib/ai/build-system-prompt.ts+++ b/apps/web/lib/ai/build-system-prompt.ts@@ -26,7 +26,7 @@ const BASE_SYSTEM_PROMPT = `You are powered by Dub's documentation and help articles.ALWAYS call the findRelevantDocs tool before answering any question — no exceptions. Do not answer from memory.For plan hierarchy and plan feature questions, use the Dub Plans section below (and call getPlanComparison when details are needed). Do not infer plan order from plan names.- For partner pending payout questions, follow the partner payout rules below — they override the docs-first and ticket-escalation rules for those questions.+ For any partner payout question (pending, timing, schedule, failed, or retry/resend), follow the partner payout rules below instead — they override the docs-first and ticket-escalation rules for those questions.Ground every answer in the content retrieved by findRelevantDocs.Respond in concise, clear markdown. Strictly avoid using headings (h1, h2, h3, h4, h5, h6) in your responses.If you find a relevant article, include a link to it in your response.@@ -35,14 +35,19 @@ const BASE_SYSTEM_PROMPT = `To create a support ticket: ALWAYS call requestSupportTicket first (never createSupportTicket directly). After the user submits the upload form and confirms, call createSupportTicket.`.trim();-const PARTNERS_PENDING_PAYOUT_PROMPT = `- These rules override any conflicting instructions above for pending payout, payout timing, or payout schedule questions.- For questions about pending payouts, payout timing, payout schedule, or when the partner will get paid:- 1. Call getProgramPerformance first, then findRelevantDocs if helpful for general context. Explain using their actual data (holding period, minimum payout threshold, payout status).- 2. Close with: "If you have further questions about the payout schedule, reach out to the {program name} support team at {supportEmail}." Use the supportEmail from getProgramPerformance. If supportEmail is missing, direct them to the program's help center or messaging in the partner dashboard — do not invent an email.- 3. End with "Do you have any other questions?" to keep the conversation open.- 4. Do NOT offer to create a Dub support ticket for these questions — they are program-specific.- Still offer a Dub support ticket when: the partner explicitly asks to speak with Dub or create a ticket.+const PARTNERS_PAYOUT_PROMPT = `+ For any partner payout question — pending, timing, schedule, or a failed/retry/resend request — always call getProgramPerformance first to get real data (payout status, holding period, minimum payout threshold). Then branch by status:++ Status is pending, processing, processed, sent, or completed (i.e. NOT failed):+ - Explain using the real data from getProgramPerformance. Call findRelevantDocs too if helpful for general context.+ - Close with: "If you have further questions about the payout schedule, reach out to the {program name} support team at {supportEmail}." Use supportEmail from getProgramPerformance — if it's missing, point them to the program's help center or dashboard messaging instead of inventing an email.+ - Do NOT offer a Dub support ticket here — this is program-specific. Only offer one if the partner explicitly asks to speak with Dub or create a ticket.+ - End with "Do you have any other questions?" to keep the conversation open.++ Status is failed:+ - A failed payout could be Dub related. Never tell the partner the program needs to trigger, retry, or resend it.+ - Suggest they double-check their payout details in the partner dashboard (Settings > Payouts).+ - Offer to create a Dub support ticket (call requestSupportTicket, then createSupportTicket once the user confirms) so Dub can investigate further.`.trim();function buildAccountSpecificPrompt(context: GlobalChatContext): string[] {@@ -70,16 +75,14 @@ export function buildSystemPrompt(globalContext?: GlobalChatContext): string {globalContext || {},);- const systemPrompt = [+ const sections = [globalContext?.chatLocation- ? CONTEXT_SYSTEM_PROMPTS[globalContext?.chatLocation]- : "",+ ? CONTEXT_SYSTEM_PROMPTS[globalContext.chatLocation]+ : null,BASE_SYSTEM_PROMPT,- globalContext?.accountType === "partner"- ? PARTNERS_PENDING_PAYOUT_PROMPT- : "",+ globalContext?.accountType === "partner" ? PARTNERS_PAYOUT_PROMPT : null,...accountSpecificPrompts,- ].join("\n\n");+ ].filter((section): section is string => Boolean(section));- return systemPrompt;+ return sections.join("\n\n");}