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: README.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -224,3 +224,61 @@ for speech in continuously_listen(silence_len=0.5):
224
224
# do something to actually turn off the lamp
225
225
print("Turning off the lamp")
226
226
```
227
+
228
+
### Dialog Builder
229
+
230
+
You can create a high-level outline of a conversation using the Dialog Builder, available in the Aurora Dashboard. Once you have create the dialog, its ID will be available to you in the "Conversation Details" sidebar (under "Conversation ID"). You can use this ID to create and run the entire conversation in just a few lines of code:
231
+
232
+
```python
233
+
# Import the package
234
+
import auroraapi as aurora
235
+
from auroraapi.dialog import Dialog
236
+
237
+
# Set your application settings
238
+
aurora.config.app_id ="YOUR_APP_ID"# put your app ID here
239
+
aurora.config.app_token ="YOUR_APP_TOKEN"# put your app token here
240
+
241
+
# Create the Dialog with the ID from the Dialog Builder
242
+
dialog = Dialog("DIALOG_ID")
243
+
244
+
# Run the dialog
245
+
dialog.run()
246
+
```
247
+
248
+
If you've used a UDF (User-Defined Function) in the Dialog Builder, you can write the corresponding function and register it to the dialog using the `set_function` function. The UDF must take one argument, which is the dialog context. You can use it to retrieve data from other steps in the dialog and set custom data for future use (both in UDFs and in the builder).
249
+
250
+
If the UDF in the dialog builder has branching enabled, then you can return `True` or `False` to control which branch is taken.
251
+
252
+
```python
253
+
from auroraapi.dialog import Dialog
254
+
255
+
defudf(context):
256
+
# get data for a particular step
257
+
data = context.get_step_data("step_id")
258
+
# set some custom data
259
+
context.set_user_data("id", "some data value")
260
+
# return True to take the upward branch in the dialog builder
261
+
returnTrue
262
+
263
+
dialog = Dialog("DIALOG_ID")
264
+
dialog.set_function("udf_id", udf)
265
+
dialog.run()
266
+
```
267
+
268
+
Here, `step_id` is the ID of a step in the dialog builder and `udf_id` is the ID of the UDF you want to register a function for. `id` is an arbitrary string you can use to identify the data you are setting.
269
+
270
+
You can also set a function when creating the `Dialog` that lets you handle whenever the current step changes or context is changed.
271
+
272
+
```python
273
+
from auroraapi.dialog import Dialog
274
+
275
+
defhandle_update(context):
276
+
# this function is called whenever the current step is changed or
0 commit comments