← Back to all files

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:

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:

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:

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:

  1. Findings with evidence and a Mart field-to-chatbot mapping.
  2. A compact proposed architecture and local development stack.
  3. Proposed chatbot-owned tables and external references.
  4. An order integration decision and any blocking business questions.
  5. 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

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:

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:

  1. 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.
  2. 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:

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:

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

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

  1. A fresh setup connects to the approved Mart data while all new tables/framework writes stay in the chatbot database.
  2. Migrations, seeders and tests cannot modify Mart tables. Test fixtures run against isolated databases.
  3. “Frutika mango juice er dam koto?” returns a verified current price or asks which size; it never assumes 1000ml when ambiguous.
  4. “Ami 2 kg chal, ek liter soybean tel ar ek dozen dim chai” resolves brands/packs explicitly and builds the intended local cart.
  5. “Parachute shampoo ache?” returns actual matching products or an honest no-match response; no silent substitution.
  6. Quantity corrections/removals affect the correct line; uncertainty triggers clarification.
  7. Out-of-stock suggestions are not automatically added; offers follow verified rules.
  8. Bangla digits and supported phone formats normalize correctly and receive digit-by-digit readback.
  9. Local request submission is clearly distinguished from actual Mart order creation.
  10. Material changes invalidate confirmation; staff edits require renewed customer approval.
  11. Repeated confirmations, concurrent requests and uncertain remote timeouts do not duplicate orders.
  12. No automated Mart submission occurs without an approved integration, customer confirmation and staff approval.
  13. Mart/provider outages preserve local drafts and return truthful, recoverable errors.
  14. Cross-session/customer access, prompt injection and unauthorized staff access are rejected.
  15. Microphone denial, partial transcripts and interrupted readback cannot accidentally authorize submission; text fallback remains usable.
  16. 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

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:

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.