USE db_abos_v0.1;

-- =============================================================================================
-- agent_context_godigital.sql — Grounds Amber (TechMAC's site chat agent) in Go Digital: the
-- real fixed-price website/store/restaurant-ordering platform, not the vague "digitisation
-- package" description Amber previously had. Supersedes that one line in "What TechMAC does"
-- and adds dedicated documents per plan category plus ordering/FAQ context, so Amber can discuss
-- and recommend specific plans and point visitors to the right /go-digital/order?plan= link.
--
-- Safe to re-run: WHERE NOT EXISTS seed guards; the correction below is an UPDATE guarded by a
-- content match so re-running it is a no-op once applied.
-- =============================================================================================

SET @tenant_id := 1;
SET @techmac_business_id := (SELECT id FROM businesses WHERE tenant_id = @tenant_id AND name = 'TechMAC' LIMIT 1);

-- ── Correct the outdated Go Digital description in the existing overview doc ────────────────
UPDATE dim_agent_context_documents
SET content = 'TechMAC builds and operates ABOS, a micro-ERP platform for small and mid-sized businesses. Our four solutions are GO DIGITAL (a fixed-price website, online store, or takeaway ordering platform — 11 plans across three categories, from £49/mo, with every price published up front), RDABS (rapid deployment of ABOS for businesses that want the full ERP quickly), IADA (integration and data automation for businesses whose data is fragmented across tools), and ABOS itself (the full system-of-record ERP: CRM, inventory, finance, projects, and a public web/store module). Every package has a published starting price — there is no "contact us for pricing" on our core solutions.'
WHERE tenant_id = @tenant_id AND business_id = @techmac_business_id AND title = 'What TechMAC does'
  AND content LIKE '%guided digitisation package%';

-- ── Go Digital: what it is and how the categories differ ────────────────────────────────────
INSERT INTO dim_agent_context_documents (tenant_id, business_id, title, content, tags, is_active, is_deleted)
SELECT @tenant_id, @techmac_business_id,
       'Go Digital — overview and categories',
       'Go Digital is TechMAC''s fixed-price website, online store, and takeaway-ordering platform, live at /go-digital. It has 11 plans across 3 categories, each priced and published with no quotes: Website (brochure sites with CMS, blog, booking — 4 plans, from £49/mo), E-commerce Store (for businesses shipping physical goods — 4 plans, from £99/mo), and Restaurant/Takeaway (menu, delivery zones, table bookings — 3 plans, from £89/mo). A visitor should pick Website if they sell services or just need an informational/brochure presence, Store if they ship a physical product, and Restaurant if they sell food for collection or delivery. Every plan has a monthly price, an optional yearly price (roughly 10 months'' cost paid annually), and a one-off setup fee that covers the initial build (the two Enterprise-tier plans have custom setup instead of a fixed fee, scoped individually). Ordering a plan is done via the "Order" button on its plan card, which goes to /go-digital/order?plan={plan code}.',
       'godigital,overview,pricing', 1, 0
WHERE @techmac_business_id IS NOT NULL AND NOT EXISTS (
    SELECT 1 FROM dim_agent_context_documents WHERE tenant_id = @tenant_id AND business_id = @techmac_business_id AND title = 'Go Digital — overview and categories'
);

-- ── Go Digital: Website plans ────────────────────────────────────────────────────────────────
INSERT INTO dim_agent_context_documents (tenant_id, business_id, title, content, tags, is_active, is_deleted)
SELECT @tenant_id, @techmac_business_id,
       'Go Digital — Website plans',
       'The Website category has 4 plans. Website Starter: £49/mo (£490/yr, £199 setup) — up to 5 pages with a drag-and-drop CMS, mobile-responsive premium theme, free SSL and custom domain, contact form with email notifications, basic SEO meta tags, 1 admin user. Website Growth (most chosen): £89/mo (£890/yr, £299 setup) — everything in Starter plus up to 20 pages, a blog module, online appointment booking, Google Analytics, nav/footer management, 3 admin users. Website Professional: £149/mo (£1,490/yr, £499 setup) — everything in Growth plus unlimited pages, premium service pages, GTM/Meta Pixel/TikTok integrations, an AI-assisted media library, role-based admin (editor + admin), priority email support. Website Enterprise: £299/mo (£2,990/yr, custom setup) — everything in Professional plus multiple verified domains, public API and webhooks, a custom component registry, unlimited admin users, a 99.9% uptime SLA and a dedicated account manager.',
       'godigital,website,pricing,plans', 1, 0
WHERE @techmac_business_id IS NOT NULL AND NOT EXISTS (
    SELECT 1 FROM dim_agent_context_documents WHERE tenant_id = @tenant_id AND business_id = @techmac_business_id AND title = 'Go Digital — Website plans'
);

-- ── Go Digital: E-commerce Store plans ───────────────────────────────────────────────────────
INSERT INTO dim_agent_context_documents (tenant_id, business_id, title, content, tags, is_active, is_deleted)
SELECT @tenant_id, @techmac_business_id,
       'Go Digital — E-commerce Store plans',
       'The E-commerce Store category has 4 plans, for businesses selling physical goods online. Shop Starter: £99/mo (£990/yr, £399 setup) — up to 100 products with images, Stripe and PayPal checkout, order confirmation emails, basic inventory tracking, mobile-optimised storefront, 1 admin user, up to 500 orders/month. Shop Growth (most chosen): £179/mo (£1,790/yr, £699 setup) — everything in Starter plus up to 1,000 products with variants, discount codes and flash sales, abandoned-cart recovery emails, UK and international shipping zones, 5 admin users, up to 5,000 orders/month. Shop Professional: £279/mo (£2,790/yr, £999 setup) — everything in Growth plus unlimited products, subscription/repeat billing, multi-currency and VAT rules, B2B tier pricing and quotes, 15 admin users and priority support, up to 25,000 orders/month. Shop Enterprise: £449/mo (£4,490/yr, custom setup) — everything in Professional plus a headless storefront API, ERP/accounting sync, wholesale buyer portals, custom checkout flows, unlimited products/orders/admin users, a dedicated success manager and SLA.',
       'godigital,ecommerce,store,pricing,plans', 1, 0
WHERE @techmac_business_id IS NOT NULL AND NOT EXISTS (
    SELECT 1 FROM dim_agent_context_documents WHERE tenant_id = @tenant_id AND business_id = @techmac_business_id AND title = 'Go Digital — E-commerce Store plans'
);

-- ── Go Digital: Restaurant / Takeaway plans ──────────────────────────────────────────────────
INSERT INTO dim_agent_context_documents (tenant_id, business_id, title, content, tags, is_active, is_deleted)
SELECT @tenant_id, @techmac_business_id,
       'Go Digital — Restaurant / Takeaway plans',
       'The Restaurant/Takeaway category has 3 plans, built on the same platform already running a live takeaway''s real orders. Restaurant Starter: £89/mo (£890/yr, £349 setup) — up to 150 menu items with modifier groups (sizes, extras, sauces), collection orders with cash payment, order tracking by order number or phone, mobile-optimised ordering site, opening hours and holiday closures, 1 admin user, up to 500 orders/month. Restaurant Growth (most chosen): £159/mo (£1,590/yr, £599 setup) — everything in Starter plus unlimited menu items and meal-deal bundles, delivery zones with postcode-based fees and minimum order, Stripe online payments (card, Apple Pay, Google Pay), promo codes and automatic discounts, cookie-consent and promo banners, 3 admin users, up to 5,000 orders/month. Restaurant Professional: £249/mo (£2,490/yr, £999 setup) — everything in Growth plus table reservations, scheduled/pre-orders for later pickup or delivery, multi-location/multi-branch support, priority support and dedicated onboarding, 10 admin users, unlimited orders.',
       'godigital,restaurant,takeaway,pricing,plans', 1, 0
WHERE @techmac_business_id IS NOT NULL AND NOT EXISTS (
    SELECT 1 FROM dim_agent_context_documents WHERE tenant_id = @tenant_id AND business_id = @techmac_business_id AND title = 'Go Digital — Restaurant / Takeaway plans'
);

-- ── Go Digital: ordering process, VAT, and plan-change policy ───────────────────────────────
INSERT INTO dim_agent_context_documents (tenant_id, business_id, title, content, tags, is_active, is_deleted)
SELECT @tenant_id, @techmac_business_id,
       'Go Digital — ordering, VAT, and changing plans',
       'To order a Go Digital plan, a visitor picks a plan on /go-digital and clicks its Order button, which takes them to /go-digital/order?plan={code} with an order form. After they submit: a TechMAC architect reviews the order within one business day and confirms scope before any build starts; the setup fee covers the build itself (content migration, theme setup, category-specific configuration); the monthly plan then covers hosting, support, and the platform from go-live. All prices shown are exclusive of VAT, which is added at the applicable rate for the customer''s business. Customers can change plans later — most start on the Growth tier of their category and move up to Professional as they grow; they just contact their account contact to switch, no separate cancellation/re-signup needed. Amber should never submit an order on a visitor''s behalf: if someone wants to order, Amber should recommend the specific plan and share its direct order link (/go-digital/order?plan={code}) for them to complete themselves, or suggest booking a discovery call at /forms/discovery-call if they are unsure which plan or category fits.',
       'godigital,ordering,vat,faq', 1, 0
WHERE @techmac_business_id IS NOT NULL AND NOT EXISTS (
    SELECT 1 FROM dim_agent_context_documents WHERE tenant_id = @tenant_id AND business_id = @techmac_business_id AND title = 'Go Digital — ordering, VAT, and changing plans'
);
