Skip to content

Commit 696a1eb

Browse files
mayoalexanderclaude
andcommitted
fix(follow-up): resolve actual IG handle from contact_info + notes enrichment
Was using lead.name ("Trapaholics") as the IG handle — wrong profile URL. Now checks: contact_info.instagram → notes "@handle" pattern → name fallback. Lead anomalyco#21665 now correctly resolves to @trap.a.holics. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 7b4b87b commit 696a1eb

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

‎packages/opencode/src/cli/cmd/platform-instagram.ts‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,33 @@ const FollowUpCommand = cmd({
221221
spinner.stop("Error"); console.log(` ${err.message}`); return
222222
}
223223

224-
// Extract IG handle from lead
225-
const igHandle = lead.nickname
226-
|| (lead.name?.startsWith("@") ? lead.name.slice(1) : null)
227-
|| lead.name
228-
|| ""
224+
// Extract IG handle from lead — check multiple sources
225+
let igHandle = ""
226+
227+
// 1. contact_info.instagram (most authoritative)
228+
const contactInfo = typeof lead.contact_info === "string"
229+
? JSON.parse(lead.contact_info || "{}") : (lead.contact_info || {})
230+
if (contactInfo.instagram) {
231+
igHandle = contactInfo.instagram.replace(/^@/, "")
232+
}
233+
234+
// 2. Parse from notes (enrichment stores "@handle" in profile details note)
235+
if (!igHandle) {
236+
const notes = lead.notes || []
237+
for (const note of notes) {
238+
const msg = note.message || note.content || ""
239+
const match = msg.match(/Instagram profile details:\s*@([a-zA-Z0-9._]+)/)
240+
if (match) { igHandle = match[1]; break }
241+
// Also check for "[inbox reply] IG reply from @handle"
242+
const replyMatch = msg.match(/IG reply from @([a-zA-Z0-9._]+)/)
243+
if (replyMatch) { igHandle = replyMatch[1]; break }
244+
}
245+
}
246+
247+
// 3. Nickname or name (fallback — often IS the handle on boards where leads are imported from IG)
248+
if (!igHandle) {
249+
igHandle = (lead.nickname || lead.name || "").replace(/^@/, "")
250+
}
229251

230252
if (!igHandle) {
231253
spinner.stop("Error"); console.log(" No IG handle found on this lead"); return

0 commit comments

Comments
 (0)