You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/osa/deployment/widget.md
+52-14Lines changed: 52 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,15 +17,33 @@ Add two script tags to your HTML:
17
17
18
18
The widget appears as a chat bubble in the bottom-right corner of the page.
19
19
20
+
## How Configuration Works
21
+
22
+
Widget configuration uses a two-layer approach:
23
+
24
+
1.**YAML defaults** (community-level): Title, greeting, placeholder, and suggested questions are defined in each community's `config.yaml` under the `widget` section. These are served by the `GET /communities` API endpoint.
25
+
2.**JavaScript overrides** (page-level): Embedders can override any field via `setConfig()`. Any value set in JavaScript takes precedence over the YAML defaults.
26
+
27
+
This means most embedders only need to set `communityId`; the widget fetches its display configuration from the API automatically.
28
+
20
29
## Configuration Options
21
30
31
+
### Display Options (from YAML defaults)
32
+
33
+
These fields are typically configured in the community's `config.yaml` and loaded automatically. You can override them per-page via `setConfig()`:
34
+
22
35
| Option | Type | Default | Description |
23
36
|--------|------|---------|-------------|
24
37
|`communityId`| string |`'hed'`| Which community assistant to use |
25
-
|`title`| string |`'HED Assistant'`| Widget header title |
26
-
|`initialMessage`| string | HED greeting | First message shown to user |
27
-
|`placeholder`| string |`'Ask about HED...'`| Input placeholder text |
|`title`| string | From YAML or community name | Widget header title |
39
+
|`initialMessage`| string | From YAML | First message shown to user |
40
+
|`placeholder`| string | From YAML or `'Ask a question...'`| Input placeholder text |
41
+
|`suggestedQuestions`| string[]| From YAML | Clickable suggestion buttons |
42
+
43
+
### Behavior Options
44
+
45
+
| Option | Type | Default | Description |
46
+
|--------|------|---------|-------------|
29
47
|`apiEndpoint`| string | Auto-detected | Backend API URL |
30
48
|`storageKey`| string | Auto-derived | localStorage key for chat history |
31
49
|`turnstileSiteKey`| string |`null`| Cloudflare Turnstile site key |
@@ -37,10 +55,11 @@ The widget appears as a chat bubble in the bottom-right corner of the page.
37
55
|`pageContextStorageKey`| string |`'osa-page-context-enabled'`| localStorage key for page context preference |
38
56
|`pageContextLabel`| string |`'Share page URL...'`| Label text for the page context checkbox |
39
57
|`fullscreen`| boolean |`false`| Open chat in fullscreen mode |
58
+
|`widgetInstructions`| string |`null`| Per-page context hint sent to the assistant (max 2000 chars) |
40
59
41
60
### Minimal Configuration
42
61
43
-
Only `communityId` is required. Everything else has sensible defaults:
62
+
Only `communityId` is required. The widget fetches display settings (title, greeting, placeholder, suggested questions) from the `/communities` API automatically:
@@ -51,6 +70,22 @@ Only `communityId` is required. Everything else has sensible defaults:
51
70
</script>
52
71
```
53
72
73
+
### Per-Page Customization
74
+
75
+
Use `widgetInstructions` to give the assistant context about the specific page where the widget is embedded. This is sent to the backend as part of the page context and helps the assistant provide more relevant answers:
widgetInstructions:'The user is on the HED online validation tools page. Focus on helping with validation errors and tool usage.'
83
+
});
84
+
</script>
85
+
```
86
+
87
+
This is useful when the same community assistant is embedded across multiple pages (e.g., documentation, tools, tutorials) and you want the assistant to adapt its responses to the page context.
88
+
54
89
### Full Configuration
55
90
56
91
```html
@@ -67,6 +102,7 @@ Only `communityId` is required. Everything else has sensible defaults:
67
102
'Validate my HED string',
68
103
'What tools are available?'
69
104
],
105
+
widgetInstructions:'User is on the annotation guide page.',
70
106
showExperimentalBadge:false,
71
107
allowPageContext:true,
72
108
pageContextDefaultEnabled:true
@@ -142,26 +178,30 @@ When configured, users must complete a Turnstile challenge before sending messag
142
178
143
179
## API Endpoints
144
180
145
-
The widget communicates with two backend endpoints:
181
+
The widget communicates with the following backend endpoints:
146
182
147
183
| Endpoint | Method | Description |
148
184
|----------|--------|-------------|
185
+
|`/communities`| GET | Fetch available communities and widget config |
149
186
|`/{communityId}/ask`| POST | Send a question, get a response |
150
187
|`/health`| GET | Check backend status |
151
188
189
+
On load, the widget fetches `/communities` to get display configuration (title, greeting, placeholder, suggested questions) for all available communities. This eliminates the need to hardcode these values in JavaScript.
"widget_instructions": "User is on the getting started page."
160
200
}
161
201
}
162
202
```
163
203
164
-
The `cf_turnstile_response` field is also sent by the widget when Turnstile is configured, but this is consumed by the Cloudflare Worker proxy, not the backend API.
204
+
The `widget_instructions` field is optional and only sent when configured via `setConfig({ widgetInstructions: '...' })`. The `cf_turnstile_response` field is also sent by the widget when Turnstile is configured, but this is consumed by the Cloudflare Worker proxy, not the backend API.
165
205
166
206
### Response Format
167
207
@@ -193,14 +233,12 @@ To host the widget yourself:
193
233
194
234
## Demo Page
195
235
196
-
The demo page at [osa-demo.pages.dev](https://osa-demo.pages.dev)showcases all available community assistants with URL-based routing:
236
+
The demo page at [osa-demo.pages.dev](https://osa-demo.pages.dev)dynamically loads all available communities from the `/communities` API and showcases them with URL-based routing:
197
237
198
-
-`/` - Landing page with community cards
199
-
-`/hed` - HED assistant demo
200
-
-`/bids` - BIDS assistant demo
201
-
-`/eeglab` - EEGLAB assistant demo
238
+
-`/` - Landing page with community cards (populated from API)
Each community page auto-configures the widget with the appropriate settings.
241
+
Each community page auto-configures the widget using the YAML-defined defaults. New communities added to the registry appear on the demo page automatically without frontend changes.
Copy file name to clipboardExpand all lines: docs/osa/registry/quick-start.md
+23-10Lines changed: 23 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,16 @@ github:
67
67
- org/my-tool
68
68
- org/my-tool-plugins
69
69
70
+
# Widget display configuration (optional)
71
+
widget:
72
+
title: My Tool Assistant
73
+
initial_message: "Hi! I can help with My Tool. What would you like to know?"
74
+
placeholder: Ask about My Tool...
75
+
suggested_questions:
76
+
- How do I get started with My Tool?
77
+
- What are the configuration options?
78
+
- How do I use the API?
79
+
70
80
# Paper search and citation tracking
71
81
citations:
72
82
queries:
@@ -129,26 +139,29 @@ uv run osa sync all --community my-tool
129
139
130
140
## Step 6: Deploy the Widget (Optional)
131
141
132
-
Add the chat widget to your community's website:
142
+
Add the chat widget to your community's website. If you configured the `widget` section in your `config.yaml`, only `communityId` is needed; the widget fetches display settings from the API automatically:
|`extensions`| object | No |`null`| Extension points (plugins, MCP) |
20
21
21
22
## `id`
@@ -205,6 +206,33 @@ extensions:
205
206
url: https://mcp.my-tool.org
206
207
```
207
208
209
+
## `widget`
210
+
211
+
Widget display configuration for the embedded chat widget. These values provide defaults that the widget loads from the `/communities` API endpoint, so embedders only need to set `communityId` in their JavaScript.
212
+
213
+
| Field | Type | Required | Default | Description |
initial_message: "Hi! I'm the HED Assistant. I can help with HED annotation, validation, and related tools."
224
+
placeholder: Ask about HED...
225
+
suggested_questions:
226
+
- What is HED and how is it used?
227
+
- How do I annotate an event with HED tags?
228
+
- What tools are available for working with HED?
229
+
- Explain this HED validation error.
230
+
```
231
+
232
+
When the widget is embedded on a page, it fetches community defaults from `GET /communities` and applies them automatically. Embedders can still override any field via `setConfig()` in JavaScript; see the [Widget Deployment Guide](../deployment/widget.md).
233
+
234
+
If `widget` is omitted, the widget falls back to generic defaults (title = community name, placeholder = "Ask a question...").
235
+
208
236
## `enable_page_context`
209
237
210
238
When `true` (default), the assistant includes a `fetch_current_page` tool that retrieves content from the web page where the widget is embedded. This allows the assistant to provide contextually relevant answers based on what the user is currently reading.
@@ -254,6 +282,14 @@ citations:
254
282
dois:
255
283
- "10.1016/j.neuroimage.2021.118766"
256
284
285
+
widget:
286
+
title: HED Assistant
287
+
initial_message: "Hi! I'm the HED Assistant. I can help with HED annotations."
0 commit comments