# Milestone 1.6 — Widget `data-site-id` Configuration Learning Guide

This directory documents the implementation of **Milestone 1, Step 1.6: Widget `data-site-id` Configuration**.

---

## Documents in this folder

- **[01-data-site-id.md](file:///c:/Users/alokc/chatbot/backend/docs/learning/m1-6-site-id/01-data-site-id.md)** — Explains HTML5 `data-*` attributes, `document.currentScript`, runtime extraction flow, and graceful error handling.
- **[02-m1-6-revision.md](file:///c:/Users/alokc/chatbot/backend/docs/learning/m1-6-site-id/02-m1-6-revision.md)** — Short revision summary and top 5 interview Q&As.

---

## How to Verify Milestone 1.6

1. **Build the bundle:**
   ```bash
   cd widget
   npm run build
   ```

2. **Open test harness in browser:**
   Open `widget/demo.html`.
   - Check Console (`F12` $\rightarrow$ `Console`): `Widget initialized with siteId: site_demo_123`.
   - Click the chat bubble to open panel. Subtitle displays: `Site ID: site_demo_123`.

3. **Verify Missing Attribute Test:**
   Remove `data-site-id="site_demo_123"` from `demo.html` script tag and reload:
   - Console displays warning: `Universal Chatbot Widget: Missing data-site-id attribute on script tag.`
   - Chat panel displays setup warning without throwing page errors.

---

## What You Should Understand Before Moving to M1.7

- In **Milestone 1.7**, the widget will pass this extracted `siteId` to the backend REST API (`POST /api/v1/session/init`) to create or resume a visitor session.
