You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 47e5aed
Browse filesBrowse the repository at this point in the historyBrowse files
✨ feat(x-bot): fetch parent tweet context when mention is a reply
When someone replies to a tweet mentioning @rnvibecode, the bot now
fetches the parent tweet's text and images to use as context for
classification and app generation. Parent images are merged first,
reply images included only if same author as parent tweet.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: apps/web/lib/x-bot/classify-tweet.ts
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -36,21 +36,26 @@ export type TweetClassification = z.infer<typeof TweetClassificationSchema>
36
36
exportasyncfunctionclassifyTweet(
37
37
tweetText: string,
38
38
hasImages: boolean,
39
-
authorUsername?: string
39
+
authorUsername?: string,
40
+
parentTweetText?: string
40
41
): Promise<TweetClassification>{
41
42
try{
42
43
constanthropic=createAnthropic({
43
44
apiKey: process.env.ANTHROPIC_API_KEY,
44
45
})
45
46
47
+
constparentContext=parentTweetText
48
+
? `\nThis is a REPLY to another tweet. The parent tweet says: "${parentTweetText}"\nThe user is replying to that tweet and mentioning the bot. Consider the parent tweet as context for what the user wants built.`
49
+
: ''
50
+
46
51
constresult=awaitgenerateObject({
47
52
model: anthropic('claude-3-5-haiku-20241022'),
48
53
schema: TweetClassificationSchema,
49
54
prompt: `Analyze this tweet and determine if it's requesting to build/create a mobile app.
- Includes a design mockup or screenshot with the intent to create it
61
66
- Requests a specific type of application (e.g., "build me a todo app")
67
+
- Is a reply to a tweet containing a design/mockup/app idea, asking the bot to create it (e.g., "create this", "build this app", "make this")
62
68
63
69
2. A REGULAR MENTION (not an app request) typically:
64
70
- Is just saying hello or asking a general question
@@ -67,7 +73,7 @@ Classification rules:
67
73
- Is thanking or commenting without an app request
68
74
- Is spam or unrelated content
69
75
70
-
If this IS an app request, extract a clean app description that can be used as a prompt for the AI to build the app. Focus on what the user wants to build, not the conversational parts of the tweet.
76
+
If this IS an app request, extract a clean app description that can be used as a prompt for the AI to build the app. Focus on what the user wants to build, not the conversational parts of the tweet.${parentTweetText ? ' Include relevant details from the parent tweet in the app description.' : ''}
71
77
72
78
Be strict - only classify as an app request if there's clear intent to build something.`,
When a user replies to someone else's tweet with `@rnvibecode create this app`, the bot only sees the reply text and images — not the parent tweet's content. This means design screenshots or app descriptions in the parent tweet are lost.
6
+
7
+
## Solution
8
+
9
+
Fetch the immediate parent tweet when a mention is a reply, and include its text and images in the classification and generation pipeline.
10
+
11
+
## Design Decisions
12
+
13
+
-**Depth**: Immediate parent only (no thread walking)
14
+
-**Image merging**: Parent images first, then reply images (only if reply author === parent tweet author)
15
+
-**Classification**: Pass parent text + image presence to the AI classifier for better context
16
+
-**Generation**: Include parent text in the generation prompt
0 commit comments