Tanisha Mart Chatbot — Implementation Specification
1. Role and starting point
Act as a senior Laravel engineer and conversational-AI architect. Build a standalone shopping chatbot in a freshly installed Laravel 13 project on my local machine, using VS Code and the Codex extension.
The existing Tanisha Mart system already manages the store. This new project is the chatbot application, not a replacement e-commerce application. It will connect to the existing Mart database to retrieve authoritative business data.
Work incrementally. Inspect the fresh project and available Mart schema before choosing table mappings. Do not invent existing table names, business rules, APIs, or order-creation capabilities. Ask before implementing unresolved choices affecting money, orders, or customer data.
2. Project scope
Build:
- A text-first shopping assistant, followed by voice input and output.
- Bangla, English and mixed Banglish product search and conversations.
- Product, price, stock, pack-size, brand and offer inquiries using Mart data.
- A chatbot-owned draft cart and checkout-detail collection.
- Customer confirmation and staff review of order requests.
- Actual Mart order submission through a verified integration when available.
- Conversation history, tool-call records, optional audio retention and chatbot staff screens.
- A standalone chat page for local testing, followed by a widget that can be integrated into the existing Mart website.
Do not rebuild the storefront, catalog administration, inventory management, promotions engine, payment gateway, shipping system or general Mart admin panel. Do not assume this repository contains the Mart application, its models, authentication, checkout services or frontend.
Reported catalog context, to validate against the connected data: approximately 3,100 products; categories up to four levels; brands; pack sizes such as 500gm, 1Ltr, 2Pcs and 250(±)20gm; regular and sale prices in BDT; and offers such as Buy 2 Get 1.
Cash on delivery is the intended payment method. Delivery eligibility, fees and timing must come from verified Mart rules; do not promise a universal 1–2 hour delivery window.
3. Application and database boundaries
Use two explicitly named database connections as the proposed deployment arrangement:
| Connection | Ownership and purpose |
|---|---|
chatbot — default |
Chatbot-owned writable database: sessions, messages, draft carts, order requests, synonyms, staff accounts, audit records and framework tables. |
mart |
Existing Mart database: scoped read access to approved catalog and operational data. |
These databases can run on the same database server. The separation is about ownership and migration safety, not a requirement for separate servers. If a single database is required, obtain agreement on chatbot table prefixes and scoped permissions before migrations; never treat Mart tables as chatbot-owned.
Requirements:
- Configure connections through environment variables and Laravel configuration. Keep secrets out of prompts, source control, frontend code and logs.
- Use a least-privilege Mart database account with read-only access to the approved tables/views initially. Prefer sanitized development data for tests.
- Explicitly assign Mart models/repositories to the
martconnection and map the actual table names, primary keys and relationships. - Place all new migrations, seeders, session/cache/queue tables and chatbot staff authentication on the chatbot connection.
- Never run
migrate:fresh, rollback, seeders, truncation or schema modifications against Mart. Test isolation must prevent accidental access to production Mart data. - Do not add source, verification or voice-session columns to existing Mart order tables from this project.
- Store external Mart identifiers as references in chatbot tables. Do not assume cross-database foreign keys, shared transactions or shared authentication.
- Do not load or clone the entire customer/order database for chatbot context. Retrieve only authorized fields necessary for a specific capability.
- Direct database access retrieves data; it does not execute the Mart application's pricing services, validation, inventory workflows or event listeners.
Mart remains authoritative for catalog and completed orders. The chatbot owns conversational state and draft requests. A draft cart does not reserve Mart stock.
4. Step 0 — Inspect and map, then stop
Inspect the fresh Laravel project, dependency lockfiles, installed frontend/auth components, test framework and local runtime. Inspect the available Mart schema through authorized read-only access or a supplied schema export.
Produce a mapping of:
- Products and sellable variants/SKUs, categories, brands, units and pack sizes.
- Current prices, sale-price eligibility, stock and availability rules.
- Offers and their conditions, including cases where database fields alone cannot establish eligibility.
- Delivery zones, fees, minimum orders and operating hours, if available.
- Any documented integration for checkout quotes, order creation, idempotency, order status and customer verification.
For every required capability, mark it as available, partially known or unavailable. A table's existence does not prove its business semantics. If rules require Mart source code or an integration contract, request that specific information; do not inspect nonexistent Mart code in the fresh project.
Return:
- Findings with evidence and a Mart field-to-chatbot mapping.
- A compact proposed architecture and local development stack.
- Proposed chatbot-owned tables and external references.
- An order integration decision and any blocking business questions.
- A phased implementation plan with acceptance criteria.
Wait for approval before implementation. Once a phase is approved, complete its routine implementation and tests without repeated permission requests.
5. Initial technical approach
- Backend: the installed Laravel 13 project and MySQL-compatible connections, verified locally.
- UI proposal: Blade, lightweight JavaScript and the project's asset pipeline. Reuse installed components where suitable; do not introduce a separate SPA solely for a chat widget.
- Staff UI: a small authenticated chatbot review area. It is separate from Mart staff authentication unless an explicit integration is provided.
- Transport: turn-based HTTP with push-to-talk for the first voice release. WebSockets, continuous listening and barge-in are deferred until measurements justify them.
- Queue and storage: configurable; keep chatbot jobs and framework persistence separate from Mart. Private audio storage only.
- Agent: prefer the first-party Laravel AI SDK if its installed version supports the required provider features. Otherwise use an official SDK/HTTP client behind an application interface.
- Preferred language model provider: Claude, with explicit configurable model ID. Verify current compatibility before implementation.
- Keep STT, agent and TTS replaceable through small interfaces. Avoid unnecessary microservices or vector infrastructure in the initial release.
6. Product search and language handling
Use bounded, parameterized repository/Eloquent queries. The LLM must never generate or execute SQL. Centralize Mart schema mapping in the integration layer rather than scattering Mart column names through tools and controllers.
Support:
- Bangla, English and Banglish aliases: chal/chaal, dal/daal, tel, dim, piyaj/peyaj, alu, chini, lobon, murgi and gorur mangsho.
- Bangla digits and number words, including ek, dui, tin, adha, der/dera and arai.
- Compatible units: kg/gm, liter/ml, pieces, packets, hali and dozen.
- Corrections such as “na, 2 ta na, 3 ta.”
- Clarification when multiple brands, sizes or products match; show the best 2–3 candidates with current prices and packs.
Maintain editable synonyms in the chatbot database, referencing Mart products, brands or categories. Distinguish aliases from alternatives: a synonym must not authorize a different brand or product substitution.
Keep requested amount, unit, selected SKU/pack and number of packs separate. Ask before mapping a request to an ambiguous pack arrangement. Never convert kg of oil to liters. Variable-weight products require verified Mart pricing rules; do not invent a final amount from a weight label.
For this catalog size, start with existing indexes, bounded lookup and curated aliases. Do not alter Mart indexes without separate authorization. If needed, propose a chatbot-owned search index with refresh/deletion rules; live price and stock must still be revalidated.
7. Server-side tools
All tools must validate input, enforce session ownership, bound result sizes and return structured status/error information. A signed session token is not a substitute for authorization.
| Capability | Required behavior |
|---|---|
search_products |
Search approved Mart data and return sellable IDs, names, brand, pack, prices, currency and availability. |
get_product_details |
Return verified product fields; distinguish unknown from unavailable. |
list_offers |
Return verified active offers and conditions; do not independently reproduce undocumented promotion logic. |
| Cart tools | Read/add/update/remove chatbot draft lines; validate ownership, quantity and current product identity. |
set_checkout_details |
Store validated name, phone, address and notes in the local draft without changing Mart customer records. |
get_delivery_info |
Use verified Mart data/integration; return unknown when eligibility or charges cannot be determined. |
prepare_checkout |
Obtain an authoritative quote if supported; otherwise identify the draft as an estimate requiring staff follow-up. |
submit_order_request |
Persist a confirmed local request for staff review; never describe it as a Mart order. |
place_order |
Available only through the approved Mart integration and only after all customer and staff gates pass. |
request_human_handoff |
Persist a follow-up request and report its actual state. |
Order tracking is optional and deferred. If added, require authenticated ownership or an approved verification mechanism; an order number and phone number alone must not expose order details.
8. Order requests and Mart integration
The fresh project does not have access to Mart checkout services merely because it shares database access. Do not create orders by guessing inserts into Mart order, item, stock or payment tables.
Use two explicit stages:
- Local order request: the customer confirms a draft; it is saved in the chatbot database for staff review. The customer receives a request reference and is told it is awaiting verification, not yet placed in Mart.
- Actual Mart order: staff approve the request and the chatbot submits through an approved Mart API, service bridge or other documented integration that enforces the existing checkout rules. Only a successful Mart receipt permits the “order placed” message.
An API is not assumed to exist. If none exists, implement local requests and review first. Keep automated Mart submission disabled until a bridge is separately defined and authorized. Staff may manually create an order through Mart's existing UI and link its verified reference; the chatbot must not claim it created that order automatically.
The integration contract must define authentication, sellable identifiers, quote calculation, stock validation, required customer/delivery fields, promotion rules, idempotency, errors and status reconciliation. Changes needed in the separate Mart project must be listed as external dependencies, not silently implemented here.
Confirmation and submission rules:
- Read/display items, packs, quantities, subtotal, discounts/fees where applicable, delivery charge, total, name, phone, address, COD and pending-review explanation.
- If final pricing cannot be verified, clearly label amounts as estimates. Confirmation then authorizes a follow-up request only; obtain final customer confirmation before any actual order submission.
- Bind confirmation to an expiring quote/draft version and direct customer evidence. Cart or material checkout changes invalidate it.
- “Yes, but change…” is a correction, not approval. Interrupted voice summaries must be completed or restarted before approval is accepted. Support explicit text confirmation in text mode.
- Revalidate final terms and stock through Mart at actual submission. Price, pack, item, fee or destination changes require renewed customer confirmation.
- Staff cannot bypass customer confirmation by editing and approving. No automatic approval option in the initial release.
- Use durable idempotency for local requests and remote submissions. Repeated clicks, repeated “yes” and network retries must not create duplicates.
- A local database transaction cannot atomically commit a separate Mart API request. Persist submission attempts and reconcile uncertain remote results using stable identifiers before retrying.
- If Mart cannot provide safe idempotency/status reconciliation, retain manual submission until the risk is resolved.
Proposed local states: draft → awaiting_customer_confirmation → pending_review → approved → submitting → submitted. Also support needs_reconfirmation, rejected, expired and submission_unknown. Record failure/retry details separately. Do not assume a local approval reserves stock or starts delivery.
9. Conversation and voice behavior
Be warm, brief and polite. Use the customer's language. Ordinary replies should be 1–2 short sentences; checkout readback may be longer. Spoken output must not contain Markdown, URLs or decorative symbols.
Only assert business facts returned by authoritative tools. Do not invent discounts, stock, delivery promises or order status. Normalize supported Bangladesh phone formats, read the number digit by digit and distinguish format validation from ownership verification.
Ask when a product or correction is ambiguous. Offer human follow-up when requested or after repeated unsuccessful clarification. Three failed attempts and extra checks above 10 units/BDT 10,000 are proposed configurable policies requiring approval.
Voice requirements:
- STT supports Bangla, English and code-switching; do not use browser Web Speech as the primary engine.
- Compare 2–3 providers using current official capability/pricing information and representative grocery recordings before selecting one. Do not claim Bangla accuracy without evaluation.
- TTS supports understandable Bangla and English, including local product names, amounts and phone readback.
- Store finalized transcripts and provider metadata. Confidence is nullable when unavailable; never invent a score.
- Provisional captions cannot mutate a cart or confirm an order.
- Microphone denial or STT/TTS failure falls back to text while retaining the cart.
- Treat first meaningful audio within approximately two seconds as a measurement target, not a guarantee. Track STT, model/tools, TTS and end-to-end latency separately.
Create a versioned agent system prompt that encodes these behavior rules. Server-side policy must enforce authorization and checkout gates regardless of prompt compliance.
10. Chatbot-owned data and review screens
Create only the tables required for the approved phase, using local conventions:
| Data | Purpose |
|---|---|
| Sessions/messages | Ownership, consent version/time, locale, ordered finalized messages, timestamps, provider IDs and outcomes. |
| Extractions/tool calls | Intent, entities, candidate/selected Mart IDs, uncertainty, sanitized tool inputs/outputs, status and duration. |
| Draft carts/items | Local item selections and quantities referencing Mart sellable IDs, with cart version. |
| Order requests/quotes | Immutable confirmed snapshots, confirmation evidence, review state and expiry. |
| Submission attempts | Stable idempotency key, integration result, external order reference and reconciliation state. |
| Synonyms | Editable multilingual aliases and target mappings. |
| Staff/audit/follow-up | Chatbot staff access, review actions, before/after changes and follow-up state. |
Store optional audio on a private disk and keep references in local message records. Avoid duplicating full customer details into every extraction/tool record. External Mart IDs are references, not proof of ownership or authorization.
The chatbot staff area must provide session/request filtering, transcript review, optional audio playback, tool/extraction inspection, confirmed-vs-current details, approve/reject/follow-up actions, and submission status. Material edits require reconfirmation. Record who acted, when, why and what changed.
Session outcomes must distinguish inquiry_only, abandoned, request_submitted, order_submitted, handed_off and error. A request waiting for review is not an order placed.
11. UI and website integration
First deliver a standalone chat page in the fresh Laravel application. Include text entry, message history, product options, draft cart, checkout summary and clear status messages.
Then add a mobile-first widget with a floating microphone/chat button using green (#16a34a), captions, push-to-talk, keyboard access and accessible status updates. Test actual Android Chrome and iOS Safari recording/playback behavior.
Integration with the existing Mart website is a separate deployment step. Determine hosting origins and select an iframe, same-origin proxy or another explicit embedding contract. Configure HTTPS, allowed origins, session authentication and CSRF/CORS as appropriate. Never assume browser cookies or Mart login automatically work across the two applications. Do not expose database/provider credentials to the browser.
12. Privacy, reliability and operations
- Show a truthful notice before microphone capture or personal-data collection. Distinguish transient speech processing, retained transcripts and optional archived audio; store notice version and consent time.
- Define retention for transcripts, audio, tool records and order evidence. Ninety days of audio is a proposal, not a fixed requirement. Provide scheduled pruning after policy approval.
- Protect customer fields and private audio; enforce staff permissions and mask sensitive application logs.
- Rate-limit sessions/requests, bound audio size/duration, cap tool loops and provider spending, and configure timeouts.
- Treat customer text and Mart descriptions as untrusted data; they cannot override tool permissions or business rules.
- Queue summaries, analytics and optional archival. Persist request/confirmation evidence durably before reporting success. Do not defer required audit evidence to an unreliable background job.
- Handle Mart outages and stale data explicitly; do not report an old price/stock value as current. Do not confirm an executable order from stale data.
- Keep feature flags for chatbot availability and Mart submission. Disabling new submissions must preserve review/reconciliation for existing requests.
- Report costs using measured audio, model usage, infrastructure and review effort; do not invent a fixed cost per minute.
13. Phased implementation
| Phase | Work | Completion gate |
|---|---|---|
| 0 | Fresh-project inspection, read-only Mart mapping, architecture and integration decisions | Approve mappings and blocking policies; no application implementation yet. |
| 1 | Separate connections, local persistence, product tools, synonyms and text inquiries | Verified Mart reads, ownership protection and inquiry logging pass tests. |
| 2 | Local draft cart, customer details, request confirmation and staff review | Requests are safely recorded; no direct Mart order writes or false order-success messages. |
| 3 | Approved Mart order integration or documented manual handoff | Quote validation, approval, idempotency and recovery pass in a test environment before automated submission is enabled. |
| 4 | STT/TTS, push-to-talk and accessible voice UI | Language, device, interruption and text-fallback tests pass. |
| 5 | Website embedding, monitoring, retention and controlled rollout | Deployment, permission, outage and recovery checks pass. |
If the Mart bridge is unavailable, phase 4 may proceed for inquiries and local requests; automated order submission stays disabled. Security and required logging are implemented with each feature, not postponed to the last phase.
After each phase, summarize changes, tests, blockers and next steps, then wait for my go-ahead. Keep a concise progress file so a new Codex session can resume without regenerating the whole blueprint.
14. Acceptance criteria
- A fresh setup connects to the approved Mart data while all new tables/framework writes stay in the chatbot database.
- Migrations, seeders and tests cannot modify Mart tables. Test fixtures run against isolated databases.
- “Frutika mango juice er dam koto?” returns a verified current price or asks which size; it never assumes 1000ml when ambiguous.
- “Ami 2 kg chal, ek liter soybean tel ar ek dozen dim chai” resolves brands/packs explicitly and builds the intended local cart.
- “Parachute shampoo ache?” returns actual matching products or an honest no-match response; no silent substitution.
- Quantity corrections/removals affect the correct line; uncertainty triggers clarification.
- Out-of-stock suggestions are not automatically added; offers follow verified rules.
- Bangla digits and supported phone formats normalize correctly and receive digit-by-digit readback.
- Local request submission is clearly distinguished from actual Mart order creation.
- Material changes invalidate confirmation; staff edits require renewed customer approval.
- Repeated confirmations, concurrent requests and uncertain remote timeouts do not duplicate orders.
- No automated Mart submission occurs without an approved integration, customer confirmation and staff approval.
- Mart/provider outages preserve local drafts and return truthful, recoverable errors.
- Cross-session/customer access, prompt injection and unauthorized staff access are rejected.
- Microphone denial, partial transcripts and interrupted readback cannot accidentally authorize submission; text fallback remains usable.
- Inquiry sessions, abandoned drafts, pending requests and submitted orders have distinct outcomes and reviewable evidence.
Use unit/feature tests with fake providers for deterministic behavior, plus separate real-provider speech evaluations. Do not create production orders or contact real customers during automated testing.
15. Deliverables
- Approved connection/schema mapping and a compact architecture plan.
- Chatbot-only migrations, models, factories, seeders and multilingual aliases.
- Mart read repositories/adapters; validated tools; agent/STT/TTS interfaces and implementations.
- Local request, confirmation and staff-review workflow; approved Mart submission adapter when available.
- Standalone chat UI, voice widget and documented website integration.
- Configuration examples without secrets, relevant tests, setup/deployment documentation and phase progress notes.
The README must explain which data belongs to each system, safe migration/testing commands, provider setup, request-versus-order states, integration limitations, review procedures and recovery after submission timeouts.
16. Remaining decisions
Resolve discoverable facts from the fresh repository and Mart schema first. Ask only for unresolved choices needed by the next phase:
- Mart connection access/schema and verified stock, price, offer and delivery semantics.
- Approval of the separate chatbot database arrangement, or a deliberately scoped same-database alternative.
- Available Mart quote/order APIs or the authorized manual/bridge workflow.
- Guest identity, staff access and any future Mart login integration.
- Final pricing/reservation behavior during staff review and how to obtain customer reconfirmation.
- Provider budget, consent/retention policy, support channel and deployment origins.
Do not ask to recreate the entire store or inspect an existing checkout implementation inside this fresh chatbot repository. Start by establishing the new application's boundaries and the real Mart data contract.