aboutsummaryrefslogtreecommitdiff
path: root/apps/web/app/api/onboarding
diff options
context:
space:
mode:
authorMaheshtheDev <[email protected]>2026-01-25 01:04:15 +0000
committerMaheshtheDev <[email protected]>2026-01-25 01:04:15 +0000
commit6834bc687609ec28aff0280df367f5bec6d0e275 (patch)
tree6dac32e6551cb2ea580df784decadad9aebd91c8 /apps/web/app/api/onboarding
parentfeat: added advanced analytics events (#702) (diff)
downloadsupermemory-6834bc687609ec28aff0280df367f5bec6d0e275.tar.xz
supermemory-6834bc687609ec28aff0280df367f5bec6d0e275.zip
feat: onboarding config, reset onboarding, xai agentic migration (#701)01-24-feat_onboarding_config_reset_onboarding_xai_agentic_migration
- Created a new `useOrgOnboarding` hook that uses `org.metadata.isOnboarded` to track onboarding state - Updated the home page to conditionally use either the old localStorage-based onboarding or the new DB-backed onboarding based on feature flag - Added a "Restart Onboarding" option in the user dropdown menu - Improved the onboarding chat sidebar with per-link loading indicators - Enhanced the X/Twitter research API to better handle different URL formats - Updated the integrations step to use the new onboarding completion method - Added `updateOrgMetadata` function to the auth context for easier metadata updates
Diffstat (limited to 'apps/web/app/api/onboarding')
-rw-r--r--apps/web/app/api/onboarding/research/route.ts57
1 files changed, 23 insertions, 34 deletions
diff --git a/apps/web/app/api/onboarding/research/route.ts b/apps/web/app/api/onboarding/research/route.ts
index 5e9b933e..67bf4654 100644
--- a/apps/web/app/api/onboarding/research/route.ts
+++ b/apps/web/app/api/onboarding/research/route.ts
@@ -7,11 +7,22 @@ interface ResearchRequest {
email?: string
}
-// prompt to get user context from X/Twitter profile
-function finalPrompt(xUrl: string, userContext: string) {
+function extractHandle(url: string): string {
+ const cleaned = url
+ .toLowerCase()
+ .replace("https://x.com/", "")
+ .replace("https://twitter.com/", "")
+ .replace("http://x.com/", "")
+ .replace("http://twitter.com/", "")
+ .replace("@", "")
+
+ return (cleaned.split("/")[0] ?? cleaned).split("?")[0] ?? cleaned
+}
+
+function finalPrompt(handle: string, userContext: string) {
return `You are researching a user based on their X/Twitter profile to help personalize their experience.
-X/Twitter Profile URL: ${xUrl}${userContext}
+X Handle: @${handle}${userContext}
Please analyze this X/Twitter profile and provide a comprehensive but concise summary of the user. Include:
- Professional background and current role (if available)
@@ -29,18 +40,12 @@ export async function POST(req: Request) {
if (!xUrl?.trim()) {
return Response.json(
- { error: "X/Twitter URL is required" },
+ { error: "X/Twitter URL or handle is required" },
{ status: 400 },
)
}
- const lowerUrl = xUrl.toLowerCase()
- if (!lowerUrl.includes("x.com") && !lowerUrl.includes("twitter.com")) {
- return Response.json(
- { error: "URL must be an X/Twitter profile link" },
- { status: 400 },
- )
- }
+ const handle = extractHandle(xUrl)
const contextParts: string[] = []
if (name) contextParts.push(`Name: ${name}`)
@@ -51,29 +56,13 @@ export async function POST(req: Request) {
: ""
const { text } = await generateText({
- model: xai("grok-4-1-fast-reasoning"),
- prompt: finalPrompt(xUrl, userContext),
- providerOptions: {
- xai: {
- searchParameters: {
- mode: "on",
- sources: [
- {
- type: "web",
- safeSearch: true,
- },
- {
- type: "x",
- includedXHandles: [
- lowerUrl
- .replace("https://x.com/", "")
- .replace("https://twitter.com/", ""),
- ],
- postFavoriteCount: 10,
- },
- ],
- },
- },
+ model: xai.responses("grok-4-fast"),
+ prompt: finalPrompt(handle, userContext),
+ tools: {
+ web_search: xai.tools.webSearch(),
+ x_search: xai.tools.xSearch({
+ allowedXHandles: [handle],
+ }),
},
})