# 02 - M1.6 Revision Sheet & Interview Q&A

Short revision guide for **Milestone 1.6**.

---

## 1. Quick Summary

- **What We Built:** Added runtime identification logic in `widget/src/widget.js` to read `data-site-id` from the host script tag using `document.currentScript.dataset.siteId`.
- **Demo Tag:** Updated `widget/demo.html` with `data-site-id="site_demo_123"`.
- **Error Handling:** Logged warning and displayed panel warning if `siteId` is missing, preventing page crashes.

---

## 2. 5 Key Interview Q&As

#### Q1: How does the widget read custom attributes from its own script tag?
**Answer:** Using `document.currentScript.dataset.siteId`, which retrieves the `data-site-id` HTML attribute value from the currently executing script element.

#### Q2: Why is `siteId` needed by the widget?
**Answer:** `siteId` is the multi-tenancy isolation key. It identifies which website owner owns the chatbot session, ensuring configuration and messages route to the correct tenant.

#### Q3: What happens if a customer omits `data-site-id` from their script tag?
**Answer:** The widget handles it gracefully: it logs `console.warn(...)` and displays a configuration warning inside the chat header without crashing the webpage.

#### Q4: Why doesn't M1.6 make an API call to the backend?
**Answer:** M1.6 focuses purely on extracting runtime configuration. Session initialization (`POST /api/v1/session/init`) is implemented separately in Milestone 1.7.

#### Q5: Did M1.6 alter any backend files?
**Answer:** No. M1.6 is entirely client-side configuration. All backend Pytest unit tests pass without modification.
