Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
added inquiry features in rishabh branch #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
added inquiry features in rishabh branch #40
Changes from all commits
2c8f169a7299b64b85dd3bf6bc23File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Conversational Inquiry Mode ΓÇö Implementation Plan
Replace the static "Send Inquiry" link/form with an AI-driven conversational workflow: the agent detects purchase intent, collects the required details naturally over the conversation, validates them, confirms with the user, and submits the inquiry automatically to the brand owner (email for testing, pluggable to CRM/webhook later).
This plan is grounded in the actual architecture of this repo. It reuses patterns that already exist and work, so we are extending the system, not inventing a new subsystem.
1. Why this fits the existing architecture
We are not building from scratch. The codebase already contains every building block:
BaseTool+ToolRegistry+ Plan-and-ExecuteOrchestratorpackages/tools/src/tools/types.py,packages/agent_runtime/src/agent_runtime/orchestrator.pyContextConnectorToolΓÇö declares required fields, returns "Missing required fields: X", LLM asks follow-ups, resolved values remembered across turnsapps/api/app/services/tool_registry.pyToolRegistryService.enabled_runtime_tools()/enabled_context_connector_tools()apps/api/app/services/tool_registry.pyShortTermMemory(role/content history,remembered_inputs/resolved_inputs)packages/memory/TOOL_REGISTRYprovider listapps/api/app/services/tool_registry.pyon_event(tool_start/tool_result)orchestrator.pyDesign decision: implement inquiry capture as a new builtin tool (
submit_inquiry) that mirrors theContextConnectorToolslot-filling behavior, plus a small delivery service behind an interface (SMTP email for testing, swappable later). Intent detection is driven by the system prompt (same mechanism that already drives product<product_info>tagging), optionally reinforced by a lightweight keyword pre-trigger.2. End-to-end workflow
Key point: the "ask follow-up questions and resume" behavior is already implemented by the
ContextConnectorToolmissing-fields pattern. We copy it.3. Data model
3.1 Inquiry record (stored in brand DB, new
inquiriescollection)MongoDB auto-creates the collection on first insert (same as
conversations,episodic_memory, etc. — no manual creation needed).{ "_id": "ObjectId", "inquiry_id": "uuid", "brand_id": "uuid", "brand_slug": "aandindia", "agent_id": "uuid", "conversation_id": "session-or-conversation id", "status": "submitted", // submitted | delivered | delivery_failed "product_context": { // what the user was asking about "sku": "755", "name": "FZ/FX-GD Series Jewellery Gold Balance" }, "contact": { "name": "…", "email": "…", "phone": "…", "company": "…" // optional }, "requirements": "free-text: quantity, use case, timeline, etc.", "delivery": { "method": "email", // email | webhook | ... "delivered_at": "iso8601 | null", "error": "string | null" }, "created_at": "iso8601", "updated_at": "iso8601" }3.2 Agent config block (new
inquirysection)Added to the agent config object (same object that holds
llm_config,rag_config,features,tools,context_connectors). Configured from the admin UI (Step: Features / Tools).4. Component changes (file by file)
4.1 Config ΓÇö add SMTP settings (for email testing)
File:
apps/api/app/config.pyAdd toSettings:Add
SMTP_PORTto the int-parsing validator list andSMTP_USE_TLSto the bool-parsing validator list. Never commit real credentials ΓÇö set via.env/.env.dockeronly.4.2 Delivery service ΓÇö pluggable sender
New file:
apps/api/app/services/inquiry_delivery_service.pyclass InquiryDeliveryServicewithasync def send(inquiry: dict, agent_config: dict) -> DeliveryResult.delivery_method:email→_send_email()usingaiosmtplib(async; already have SMTP deps ecosystem) or stdlibsmtplibin a threadpool. Sends a formatted inquiry email torecipient_email.webhook(future) → POST JSON towebhook_url, reusing the SSRF-safety helpers already intool_registry.py(_is_safe_external_url,_host_allowed).status=delivery_failedso nothing is lost).inquiry_id, brand, status.4.3 Inquiry persistence
New file (or add to
knowledge_service/a small service):apps/api/app/services/inquiry_service.pyasync def save_inquiry(...)→ inserts into the brand DBinquiriescollection via the existingconnection_manager(brand-scoped DB routing already exists).async def mark_delivered(inquiry_id, ...)/mark_failed(...).4.4 The tool —
submit_inquiryNew file:
packages/tools/src/tools/builtin/inquiry_tool.pyModel it directly onContextConnectorTool's field-collection logic.resolved_inputsmetadata pattern (already used byContextConnectorTool) persists captured fields into short-term memory so the user never re-enters data.4.5 Register the tool per-agent
File:
apps/api/app/services/tool_registry.pyenabled_inquiry_tool(agent_config, brand_ctx, remembered_inputs)returning anInquiryToolinstance whenagent_config["inquiry"]["enabled"]is true.enabled_runtime_tools/enabled_context_connector_toolsare collected and registered into theToolRegistryfor a turn (inmessage_service.py).4.6 Message flow wiring
File:
apps/api/app/services/message_service.pyToolRegistry, also register the inquiry tool (if enabled).resolved_inputsfrom short-term memory, same mechanism as connectors).inquiry_submitted) viaon_eventfor the widget to show a confirmation state.4.7 System prompt ΓÇö intent + tool usage instructions
Add to the agent's system prompt (this is how intent detection is driven, consistent with
<product_info>tagging):This can be baked into the E-commerce/Inquiry template so new inquiry-based brands get it automatically.
4.8 Admin UI ΓÇö configure inquiry
Files:
apps/admin/src/components/AgentWizard/StepFeatures.tsx(+ agent config form/types)inquiryblock.4.9 Widget (optional, phase 2)
Files:
apps/widget/src/components/MessageBubble.tsxinquiry_submittedevent arrives.5. Email testing setup (your mail, for now)
Recommended for fastest testing: Gmail SMTP with an App Password (works without changing the codebase later ΓÇö you just swap env values or switch
delivery_methodto a webhook/CRM in production)..env.docker(never commit real values):recipient_emailto the address that should receive inquiries (can be the same test address).Later, for production, swap SMTP for a proper transactional provider (SendGrid/SES) or route to HubSpot/Salesforce/Zendesk/Google Sheets ΓÇö all already present as providers in
TOOL_REGISTRY.6. Security, privacy, and safety (per repo AGENTS.md)
inquiry_id, brand, delivery status. Store in the brand-isolated DB. This aligns with the existing PII-vaulting / redaction rules.confirm_before_sendprevents sending on a misread; the agent shows a summary and waits for explicit "yes"._is_safe_external_url/_host_allowedguards (blocks localhost/private IPs).7. Observability (per repo standards)
tool_start/tool_resultevents forsubmit_inquiry(already supported byon_event).inquiry_submitted/inquiry_delivery_failedobservability event (mirrorobservability_serviceusage).8. Build phases (incremental, testable)
Phase 1 ΓÇö Core capture + email (MVP for your testing)
InquiryDeliveryServiceemail path (4.2)inquiry_servicepersistence (4.3)InquiryToolwith slot filling + confirm (4.4)inquiryblock until UI is ready)Phase 2 ΓÇö Admin UI + robustness
Phase 3 ΓÇö Production delivery + widget polish
9. Definition of Done (Phase 1)
submit_inquiryinstead of a form link.inquiriescollection.status=delivery_failed) and tells the user to try again / gives a fallback contact.10. Open questions to confirm before building
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.