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: content/recipes/genie-conversational-analytics.md
+78-45Lines changed: 78 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,41 +2,83 @@
2
2
3
3
Embed a Databricks AI/BI Genie chat interface so users can explore data through natural language. Configure a Genie space, wire up the server and client plugins, declare app resources, and deploy.
4
4
5
-
### 1. Create a Genie space in your Databricks workspace
5
+
:::info[Choose your path]
6
6
7
-
Open your Databricks workspace, navigate to **AI/BI Genie**, and create a new Genie space connected to your data tables. Note the **space title** (display name) shown in the Genie list or space header.
Use the `title` string as **Genie space name** and the `space_id` value wherever a space ID is required (scaffold `--set`, `.env`, and `databricks.yml`).
21
+
Use the `space_id` value wherever a space ID is required (scaffold `--set`, `.env`, and `databricks.yml`).
22
+
23
+
:::tip[Avoid repeating `--profile` on every command]
24
+
Add your profile to the bundle's `databricks.yml` under the target — then `bundle deploy` and `apps` commands pick it up automatically:
25
+
26
+
```yaml
27
+
targets:
28
+
default:
29
+
workspace:
30
+
profile: <PROFILE>
31
+
```
32
+
33
+
This is more reliable than `export DATABRICKS_CONFIG_PROFILE` since it persists across shells and works for agents running commands in subshells.
34
+
:::
16
35
17
36
### 2. New app: scaffold with the Genie feature
18
37
19
38
If you are starting a new app, scaffold it with the Genie feature flag. This generates all server, client, resource, and environment wiring automatically.
20
39
40
+
Run this from a neutral directory (not inside another app folder) — `apps init` creates the project folder in your current working directory:
41
+
21
42
```bash
22
43
databricks apps init \
23
44
--name <app-name> \
24
45
--version latest \
25
46
--features=genie \
26
47
--set 'genie.genie-space.id=<your-space-id>' \
27
-
--run none --profile <PROFILE>
48
+
--run none
28
49
```
29
50
30
-
Use the `space_id` from step 1 (or the **About** tab on the space) for `<your-space-id>`. The CLI maps this to `DATABRICKS_GENIE_SPACE_ID`.
51
+
`--run none`skips launching the app locally after scaffolding. Use the `space_id` from step 1 for `<your-space-id>`.
31
52
32
53
**App name:** Use at most 26 characters, **lowercase letters, digits, and hyphens only** (no underscores). Example: `my-genie-app`, not `my_genie_app`.
33
54
34
-
After `init`, open `databricks.yml` and check **`targets.default.variables`**. Some templates set **`genie_space_id`** but omit **`genie_space_name`**. If **`genie_space_name`** is missing or empty, set it to the exact **space title** from step 1 (the same title shown in the Genie UI). Deploy requires both **name** and **space ID** in the bundle for the `genie_space` resource.
55
+
:::warning[Fix generated `databricks.yml` before deploying]
56
+
The scaffold generates a `genie_space_name` variable and references it as `name: ${var.genie_space_name}`, but never assigns a value. `bundle deploy` will fail with _no value assigned to required variable genie_space_name_.
57
+
58
+
Your `variables:` block should look like this after the fix — only `genie_space_id`, no `genie_space_name`:
59
+
60
+
```yaml
61
+
variables:
62
+
genie_space_id:
63
+
description: Default Genie Space ID
64
+
```
65
+
66
+
And the `genie_space` resource block should use a hardcoded label:
35
67
36
-
`apps init` creates a project folder in **kebab-case** matching `<app-name>`. For deploy and test (step 8), run all commands from **inside that folder** (the directory that contains `databricks.yml`).
68
+
```yaml
69
+
genie_space:
70
+
name: genie-space
71
+
space_id: ${var.genie_space_id}
72
+
permission: CAN_RUN
73
+
```
74
+
75
+
The `name: genie-space` is an internal label used by `app.yaml` (`valueFrom: genie-space`), not the Genie space display title.
76
+
:::
37
77
38
78
Skip to step 8 to deploy.
39
79
80
+
---
81
+
40
82
### 3. Existing app: add Genie server plugin
41
83
42
84
The following steps match what `apps init --features=genie` generates. Apply them to an existing scaffolded AppKit app.
@@ -125,18 +167,10 @@ import { GeniePage } from "./pages/genie/GeniePage";
125
167
126
168
The Genie space must be declared as an app resource with the `dashboards.genie` API scope. Without the scope, on-behalf-of user execution fails at runtime.
127
169
128
-
For local development, add the space ID to `.env` (use the `space_id` from `databricks genie list-spaces` or the space **About** tab):
129
-
130
-
```bash
131
-
DATABRICKS_GENIE_SPACE_ID=<your-space-id>
132
-
```
133
-
134
-
Add the genie-space variables, the `user_api_scopes` and genie resource under your app, and the target variable values. The **name** is the Genie space **title**; **space ID** must match the same space:
170
+
Add the `genie_space_id` variable, the `user_api_scopes`, and the genie resource under your app. The `name: genie-space` on the resource is the key that `app.yaml` references via `valueFrom`:
135
171
136
172
```yaml
137
173
variables:
138
-
genie_space_name:
139
-
description: Genie space display title (as shown in the Genie UI)
140
174
genie_space_id:
141
175
description: Genie space ID (from list-spaces or About)
142
176
@@ -149,19 +183,16 @@ resources:
149
183
resources:
150
184
- name: genie-space
151
185
genie_space:
152
-
name: ${var.genie_space_name}
186
+
name: genie-space
153
187
space_id: ${var.genie_space_id}
154
188
permission: CAN_RUN
155
189
156
190
targets:
157
191
default:
158
192
variables:
159
-
genie_space_name: "<your-space-title>"
160
193
genie_space_id: <your-space-id>
161
194
```
162
195
163
-
The `name: genie-space` on the resource is the key that `app.yaml` references via `valueFrom`.
164
-
165
196
### 7. Existing app: map the environment variable in `app.yaml`
166
197
167
198
Add the Genie space ID mapping so the deployed app receives the value at runtime:
@@ -180,49 +211,51 @@ For local development, add the space ID to `.env`:
180
211
DATABRICKS_GENIE_SPACE_ID=<your-space-id>
181
212
```
182
213
214
+
---
215
+
183
216
### 8. Deploy and verify
184
217
185
-
From the app project directory (the folder with `databricks.yml`), deploy and run in one step:
218
+
From inside the app project folder (the directory containing `databricks.yml`):
186
219
187
220
```bash
188
221
cd <app-name>
189
-
databricks apps deploy --profile <PROFILE>
190
-
```
191
-
192
-
When run from that directory **without** a trailing app name argument, the CLI runs the full pipeline: validate the project (for Node: install if needed, typecheck, lint, build), sync the bundle to the workspace, create an app deployment, and start the app.
193
-
194
-
:::tip[Multiple CLI profiles for the same workspace]
195
222
196
-
If the CLI reports that **multiple profiles matched** your workspace host, pass **`--profile <PROFILE>`** on each command, set **`DATABRICKS_CONFIG_PROFILE`** to one profile, or add **`workspace.profile`** under your bundle target in `databricks.yml` so the bundle resolves auth consistently.
197
-
198
-
:::
223
+
# Build the client
224
+
npm run build
199
225
200
-
:::tip[Bundle deploy vs apps deploy]
226
+
# Deploy bundle resources and sync files to workspace
227
+
# Copy the upload path printed in the output — you'll need it below
228
+
databricks bundle deploy
201
229
202
-
`databricks bundle deploy`updates bundle state and synced files in the workspace, but it does **not** run the full Apps build-and-run pipeline. If you only run `bundle deploy`, the app can stay **UNAVAILABLE** with a message like _deploy source code_ while compute is active. Use `databricks apps deploy` from the app directory when you want the runnable app updated. You may still use `bundle deploy` when you are only changing bundle or workspace configuration and will run `apps deploy` afterward.
230
+
# Put the app in RUNNING state and wait for compute to be ready
231
+
# The loop polls every 5 seconds — press Ctrl+C if it hangs more than 2 minutes
232
+
databricks apps start <app-name>
233
+
until databricks apps get <app-name> -o json | grep -q '"ACTIVE"'; do sleep 5; done
203
234
204
-
:::
205
-
206
-
Optional flags:
235
+
# First deploy requires --source-code-path: paste the path from bundle deploy output above
- `--target <target>`if you use a non-default bundle target.
209
-
- `--skip-validation`to skip local build/typecheck/lint (use only when you accept skipping checks).
240
+
`bundle deploy`prints the workspace upload path (`Uploading bundle files to ...`) — copy that value for `--source-code-path`. `apps start` puts the app into RUNNING state; the `until` loop waits for compute to be ACTIVE. `apps deploy` deploys the source and starts the app server.
210
241
211
-
Check app status, URL, and logs (replace `<app-name>` with the name from `databricks.yml`):
242
+
For subsequent deploys, `--source-code-path` is not needed — the app remembers the path:
212
243
213
244
```bash
214
-
databricks apps get <app-name> --profile <PROFILE>
If the app is **UNAVAILABLE** with _deploy source code_, run `databricks apps deploy` from the app project directory again (not from a parent repo root). If **compute** is **STOPPED**, start it:
Open the app URL from `databricks apps get` while signed in to Databricks, navigate to the Genie page, and ask a natural-language question about your data to verify the integration.
256
+
Open `<app-url>/genie` while signed in to Databricks and ask a natural-language question about your data to verify the integration.
257
+
258
+
If compute is **STOPPED**, run `databricks apps start <app-name>` and wait for `compute_status.state: ACTIVE` before deploying.
0 commit comments