Chapter 01 · Instagram B2B AI DM Automation SaaS
SentLogic
Built by Biresh as a Lead AI/ML Intern at PGAGI Consultancy, not as a Biru Labs contract.
A B2B SaaS that automates Instagram DMs for merchants and creators. A merchant connects Instagram, and optionally Shopify, and AI handles customer conversations in the DMs. A separate AI Business Advisor helps merchants understand and run their own account.
- Client
- United States
- Integrations
- Instagram, Shopify
- Role
- Lead AI/ML Intern, PGAGI Consultancy
- Period
- January to August 2026
Built by Biresh and the team during our internship at PGAGI Consultancy, with ownership across AI, backend systems, integrations, billing, knowledge management, and production infrastructure.
What we built.
AI replies with RAG
Claude Sonnet and Haiku on AWS Bedrock, Titan embeddings stored in pgvector, and query expansion for better retrieval. Simple questions go to the smaller model and knowledge-heavy ones to the larger. Bedrock Guardrails keep customer-facing and merchant-facing replies safe.
Human handoff you can trust
Each reply gets a confidence score that weights the evidence found (60%) above the model's own opinion of itself (40%). Below 0.7 the AI pauses and the merchant takes over. Complaints and business enquiries escalate automatically, with an email and a push notification.
It's a practical rule of thumb, not a statistical guarantee.
A knowledge base with versions
Merchants add URLs, PDFs, Word files, text, FAQs and product catalogues. Up to five versions, one live at a time, with rollback. The AI only reads the live version, and live documents can't be deleted by accident. A report suggests what's missing for the merchant's kind of business.
The Business Advisor
A floating assistant that answers "how are my automations doing?" from real database queries instead of guesses. Merchants can create, pause, edit or delete automations in plain English: similar names trigger a clarifying question, and destructive actions ask for confirmation.
It knows which page you're on, remembers past chats, searches the web for competitor questions and has its own daily AI budget.
Automations
Comment, story and DM-responder automations with follow-gates, email capture, images, buttons and tracked links. Unfinished automations are saved as drafts, and stopped ones go to an archive instead of being deleted.
Conversations and nudges
A dashboard with pause and resume, human replies, and automatic pause with a grace period. Haiku classifies every message into seven types and tracks sentiment, and a nudge system follows up with people who go quiet mid-conversation.
Billing and limits
Stripe checkout, portal and cancellation with idempotent webhooks, five tiers, and monthly conversation credits. Customer replies and the Advisor have separate daily AI budgets, so heavy customer traffic can't starve the merchant's own assistant.
Controls and notifications
A global kill switch puts the whole account in manual mode. Web Push works on Android and on iPhone home-screen web apps, with per-type preferences so merchants only get what they want.
Analytics
Funnels, click-through, per-automation and per-product stats, peak hours, AI resolution rate, and link-click tracking with revenue attribution.
Internal admin panel
Role-based access, an append-only audit log, user and billing tools, a support inbox, a content CMS, broadcasts, platform analytics, two-factor login and time-limited read-only impersonation.
From comment to counted sale.
We chose cart links over UTM parameters and cookies, which can be stripped or blocked during checkout. Putting the attribution in the Shopify cart gave the backend a source of truth that survives.
- 1
A comment
A customer comments a keyword on a post.
- 2
An AI reply
The AI answers in the DM, using the merchant's knowledge base.
- 3
A tracked cart link
The reply carries a cart link with the conversation, workspace and channel.
- 4
Shopify checkout
The customer pays, and the attributes travel with the order.
- 5
Revenue credited
The order webhook is verified and de-duplicated, then the sale is credited to the conversation.
Problems we solved.
- 01
Paid access that outlived the subscription
Subscription status was cached in a login token that lasted seven to eight days, so a cancelled user kept paid access until they signed in again. We moved the check to the database.
We also added an automatic downgrade the moment a payment dispute opens.
- 02
A bot that apologised for a sandwich that didn't exist
In testing, the AI apologised to a customer who claimed to have found a cockroach in a sandwich the merchant doesn't even sell. Claims about products and complaints are now checked against the knowledge base before the AI admits or apologises for anything.
- 03
Answers from a half-built index
While a document was being re-chunked and re-embedded, the playground could answer from stale data, and the Advisor was reading drafts. We locked input during processing and limited retrieval to the live version.
- 04
Revenue counted twice
Webhooks get retried. Order handling checks the Shopify order ID first, and revenue moves through explicit states (untracked, attributed, paid, partially refunded, refunded, cancelled) so partial refunds are right too.
- 05
Choosing a model with evidence
We built a side-by-side comparison of Sonnet and Haiku on the same prompts and the same knowledge base, so the client could choose from real outputs instead of hunches.
Built with.
- Python
- FastAPI
- PostgreSQL
- pgvector
- Redis
- AWS Bedrock
- Claude Sonnet
- Claude Haiku
- Titan embeddings
- Stripe
- Shopify
- Instagram Graph API
- Exa search
- Web Push
- Amazon S3
- SendGrid