fix(ai-agent): scope automationExecution lookup by instagramAccountId in extractContactInfoFromText

Open
#42 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, typescript

Research direction

Start in apps/api/src/instagram/services/instagram-ai-agent.service.ts at extractContactInfoFromText and trace where the active Instagram account or conversation context is available. Check how AutomationExecution relates to its folder, then scope the lookup to the current instagramAccountId. Confirm the lookup cannot select another account's execution and run the relevant API tests.

Written by the indexing model from the issue text.

Description

backend bug
Problem Description

In apps/api/src/instagram/services/instagram-ai-agent.service.ts (extractContactInfoFromText, lines 103-107), when extracting contact info (email/phone) from an incoming DM, the service queries:
automationExecution.findFirst({ where: { instagramUserId: senderId } })
without scoping by instagramAccountId.

At 1k-10k users scale, when the same Instagram user (senderId) interacts with multiple accounts/workspaces on the platform, Company A's AI Agent can pull Company B's latest AutomationExecution and route Company A's captured lead into Company B's targetAudienceListId or emailConnectorId.


Expected Behavior
  • extractContactInfoFromText must only look up AutomationExecution records belonging to the current instagramAccountId (or current companyId).

Where to Look
  • apps/api/src/instagram/services/instagram-ai-agent.service.ts (extractContactInfoFromText)

Solution / Implementation Guide
  1. Pass instagramAccountId into extractContactInfoFromText (or read it from the active conversation/context).
  2. Add automation: { folder: { instagramAccountId } } to the where clause of automationExecution.findFirst(...).
Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
6m
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sumamakhan761/tryinstance

All issues in sumamakhan761/tryinstance

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.