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
- Added new event handler types LlmComponent and LlmTransformation
- Added textStream message type
- Added support for footerForm
- Added support for rich form layout
Copy file name to clipboardExpand all lines: CUSTOM_COMPONENT.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,17 +7,17 @@
7
7
-[Using TypeScript](#ts)
8
8
-[The Metadata Object](#metadata)
9
9
-[The Invoke Method](#invoke)
10
-
-[Control the Flow with keepTurn and transition](#flowControl)
10
+
-[Control the Flow with keepTurn and transition](#flow-control)
11
11
-[Access the Backend Using HTTP REST Calls](#rest)
12
12
-[Code Samples](#samples)
13
-
-[How to Get a Component Property Value](#propertyValue)
14
-
-[How to Get a Context Variable Value](#getVar)
15
-
-[How to Get a User or Profile Variable Value](#getProfile)
16
-
-[How to Get a Skill's Custom Parameter Value](#getCustomParam)
17
-
-[How to Set a Context Variable Value](#setVar)
18
-
-[How to Set a Composite Bag Item Value](#setBagItem)
13
+
-[How to Get a Component Property Value](#property-value)
14
+
-[How to Get a Context Variable Value](#get-var)
15
+
-[How to Get a User or Profile Variable Value](#get-profile)
16
+
-[How to Get a Skill's Custom Parameter Value](#get-custom-param)
17
+
-[How to Set a Context Variable Value](#set-var)
18
+
-[How to Set a Composite Bag Item Value](#set-bag-item)
19
19
-[How to Send Conversation Messages](#messages)
20
-
-[How to Keep Prompting for User Input](#keepPrompting)
20
+
-[How to Keep Prompting for User Input](#keep-prompting)
21
21
22
22
## Introduction <aname="introduction">
23
23
@@ -171,7 +171,7 @@ The argument of the `invoke` method is the `context` object. This object referen
171
171
172
172
More information about creating conversation messages to send to the skill user can be found [here](https://github.com/oracle/bots-node-sdk/blob/master/MESSAGE_FACTORY.md).
173
173
174
-
## Control the Flow with keepTurn and transition <aname="flowControl">
174
+
## Control the Flow with keepTurn and transition <aname="flow-control">
175
175
176
176
You use different combinations of the [CustomComponentContext](https://oracle.github.io/bots-node-sdk/CustomComponentContext.html)`keepTurn` and `transition` functions to define how the custom component interacts with a user and how the conversation continues after the component returns flow control to the skill.
177
177
@@ -238,7 +238,7 @@ The code to make REST calls with `node fetch` looks like this:
238
238
239
239
## Code Samples <aname="samples">
240
240
241
-
### How to Get a Component Property Value <aname="propertyValue">
241
+
### How to Get a Component Property Value <aname="property-value">
242
242
243
243
You can call `context.properties()` to get an object that contains all the component properties. For example:
244
244
@@ -272,7 +272,7 @@ or
272
272
constname=context.properties()['name'] ||'';
273
273
```
274
274
275
-
### How to Get a Context Variable Value <aname="getVar">
275
+
### How to Get a Context Variable Value <aname="get-var">
276
276
277
277
Add a `metadata` property to pass in the name of the context variable, verify that the property was passed in, and then call `context.getVariable(<variable name>)` to retrieve the value. For example:
278
278
@@ -286,18 +286,18 @@ if (latitudeVariable) {
286
286
}
287
287
```
288
288
289
-
### How to Get a User or Profile Variable Value <aname="getProfile">
289
+
### How to Get a User or Profile Variable Value <aname="get-profile">
290
290
291
291
To get the value of a user or profile variable, you prefix the name of the variable with `profile.` or `user.` as shown here.
292
292
```javascript
293
293
let _profileVarValue =context.getVariable('profile.<name>');
294
294
let _userVarValue =context.getVariable('user.<name>');
295
295
```
296
-
### How to Get a Skill's Custom Parameter Value <aname="getCustomParam">
296
+
### How to Get a Skill's Custom Parameter Value <aname="get-custom-param">
297
297
298
298
On the skill's **Settings** tab, add the custom parameter and provide a value (or set the value in the dialog flow). From the custom component, call `context.getVariable('system.config.<parameter-name>')` to retrieve the value.
299
299
300
-
### How to Set a Context Variable Value <aname="setVar">
300
+
### How to Set a Context Variable Value <aname="set-var">
301
301
302
302
Add a `metadata` property to pass in the name of the variable, and then call `context.setVariable(<variable name>, <value>)` to set the value. For example:
303
303
@@ -324,7 +324,7 @@ if (addressVariable){
324
324
}
325
325
```
326
326
327
-
### How to Set a Composite Bag Item Value <aname="setBagItem">
327
+
### How to Set a Composite Bag Item Value <aname="set-bag-item">
328
328
329
329
In the skill, create a context variable and set its type to the name of the composite bag entity. In the custom component, add metadata properties to pass in the name of the composite bag entity variable and the name of the bag item. Add code to check if the entity variable is null, and set it to an empty object if it is. Create an object for the bag item with the desired values and set the bag item to that object. Update the entity variable and return to the skill.
330
330
@@ -364,7 +364,7 @@ You can call this function multiple times to send multiple messages. When you ca
364
364
365
365
The payload can be a string or a rich message object. See the section on [Conversation Messaging](https://github.com/oracle/bots-node-sdk/blob/master/MESSAGE_FACTORY.md) for code samples on how to create the various message types, like text, card, attachment, table and (editable) form messages.
366
366
367
-
### How to Keep Prompting for User Input <aname="keepPrompting">
367
+
### How to Keep Prompting for User Input <aname="keep-prompting">
368
368
369
369
This code sample keeps showing the user a random quote of the day until the user indicates they want to quit.
Copy file name to clipboardExpand all lines: DATA_QUERY_EVENT_HANDLER.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,18 @@
7
7
-[Using TypeScript](#ts)
8
8
-[Writing SQL Query Handler Functions](#writing)
9
9
-[Supported Events](#events)
10
-
-[Entity Level Events](#entityEvents)
11
-
-[Attribute Level Events](#attributeEvents)
10
+
-[Entity Level Events](#entity-events)
11
+
-[Attribute Level Events](#attribute-events)
12
12
-[Access the Backend Using HTTP REST Calls](#rest)
13
13
-[Code Samples](#samples)
14
-
-[How to Set the Query Title](#queryTitle)
14
+
-[How to Set the Query Title](#query-title)
15
15
-[How to Change the Response Message Layout](#layout)
16
-
-[How to Add a Footer Text](#footerText)
17
-
-[How to Add a Total Row](#totalRow)
18
-
-[How to Add a Global Follow Up Query Action](#followUpQueryGlobal)
19
-
-[How to Add a Row Level Follow Up Query Action](#followUpQueryRow)
20
-
-[How to Change Attribute Display Settings](#attributeDisplay)
21
-
-[How to Format an Attribute Value](#attributeFormat)
16
+
-[How to Add a Footer Text](#footer-text)
17
+
-[How to Add a Total Row](#total-row)
18
+
-[How to Add a Global Follow Up Query Action](#follow-up-query-global)
19
+
-[How to Add a Row Level Follow Up Query Action](#follow-up-query-row)
20
+
-[How to Change Attribute Display Settings](#attribute-display)
21
+
-[How to Format an Attribute Value](#attribute-format)
22
22
23
23
## Introduction <aname="introduction">
24
24
@@ -206,7 +206,7 @@ When using TypeScript, you will automatically get code completion support if you
206
206
207
207
## Supported Events <aname="events">
208
208
209
-
### Entity Level Events <aname="entityEvents">
209
+
### Entity Level Events <aname="entity-events">
210
210
The table below lists all entity level events:
211
211
212
212
| Event | Description | Event Properties |
@@ -215,7 +215,7 @@ The table below lists all entity level events:
215
215
| `changeResponseData` | A handler that can be used to change the query result set. For a list of properties you can change, check the `QueryResult` interface in [Data Query Types](https://github.com/oracle/bots-node-sdk/blob/master/ts/lib/dataquery/dataQueryTypes.ts). | <ul><li><b>responseData</b>: The `QueryResult` object.</li></ul>
216
216
| `changeBotMessages` | A handler that can be used to change the candidate bot message(s) that will be sent to the user. See the section on [Conversation Messaging](https://github.com/oracle/bots-node-sdk/blob/master/MESSAGE_FACTORY.md) for more info on adding or changing messages.| <ul><li><b>messages</b>: The list of messages.</li></ul>
@@ -266,7 +266,7 @@ All code samples are using TypeScript. If you are using JavaScript, you just nee
266
266
267
267
Note that some of the samples below implement functionality that can also be implemented declaratively in the Query Entity page in the Oracle Digital Assistant user interface. However, the declarative settings apply to all types of queries that have the entity as root entity, which might not always be what you want. Using event handlers, you can add conditional behavior, for example, you can check for group-by queries by inspecting `context.getSQLQuery()`, and always display such queries in table layout, even if the number of rows is below the threshold for switching from form layout to table layout as configured in the Query Entity page.
268
268
269
-
### How to Set the Query Title<aname="queryTitle">
269
+
### How to Set the Query Title<aname="query-title">
270
270
While we can set a static query title using the `Display Name` on the Query Entity page, we can create a dynamic title using the `changeUISettings` event:
271
271
272
272
```javascript
@@ -291,7 +291,7 @@ entity: {
291
291
}
292
292
```
293
293
294
-
### How to Add a Footer Text<a name="footerText">
294
+
### How to Add a Footer Text<a name="footer-text">
295
295
Here is a code snippet that adds a footer text that displays the execution time of the query. Note that the footerText is also used for the feedback message "Was this answer helpful?" when feedback is enabled, so we need to add our own text before existing footer text.
We can use the `changeResponseData` event to add a total row to the result. In the code example below, we add a total row when the query result contains more than 1 row and there is a `count` attribute present in the result rows.
### How to Add a Global Follow Up Query Action <a name="followUpQueryGlobal">
331
+
### How to Add a Global Follow Up Query Action <a name="follow-up-query-global">
332
332
We can use the `changeBotMessages` event to add a button action that executes a global follow up query. The `DataQueryContext` contains a convenience method `createQueryAction` that takes care of most of the work. The global action button will be added to the `actions` array of the message.
### How to Add a Row Level Follow Up Query Action <a name="followUpQueryRow">
352
+
### How to Add a Row Level Follow Up Query Action <a name="follow-up-query-row">
353
353
We can use the `changeBotMessages` event to add a button action that executes a row level follow up query. The `DataQueryContext` contains a convenience method `createFollowUpQueryAction` that takes care of most of the work. The row level action button will be added to the `actions` array within each `form` within the message.
### How to Change Attribute Display Settings <a name="attributeDisplay">
419
+
### How to Change Attribute Display Settings <a name="attribute-display">
420
420
We can use the attribute level `changeUISettings` event to change the display characteristics of an attribute. For example, we can completely hide it, or change whether the attribute is displayed in form layout or table layout:
421
421
```javascript
422
422
hiredate: {
@@ -430,7 +430,7 @@ hiredate: {
430
430
}
431
431
```
432
432
433
-
### How to Format an Attribute Value <a name="attributeFormat">
433
+
### How to Format an Attribute Value <a name="attribute-format">
434
434
We can use the attribute level `format` event to format the attribute value.
Copy file name to clipboardExpand all lines: ENTITY_EVENT_HANDLER.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@
7
7
-[Using TypeScript](#ts)
8
8
-[Writing Event Handler Functions](#writing)
9
9
-[Supported Events](#events)
10
-
-[Entity Level Events](#entityEvents)
11
-
-[Entity-Item Level Events](#itemEvents)
10
+
-[Entity Level Events](#entity-events)
11
+
-[Entity-Item Level Events](#item-events)
12
12
-[Access the Backend Using HTTP REST Calls](#rest)
13
13
-[Code Samples](#samples)
14
14
-[How to Conditionally Prompt for an Item](#prompt)
@@ -17,9 +17,9 @@
17
17
-[How to Set or Update Bag Items](#update)
18
18
-[How to Create a Summary Message](#summary)
19
19
-[How to Use Custom Events](#custom)
20
-
-[How to Invoke a REST API](#restSample)
20
+
-[How to Invoke a REST API](#rest-sample)
21
21
-[How to Send Rich Conversation Messages](#messages)
22
-
-[How to Modify Candidate Messages](#modifyMessage)
22
+
-[How to Modify Candidate Messages](#modify-message)
23
23
24
24
## Introduction <aname="introduction">
25
25
@@ -124,7 +124,7 @@ When using TypeScript you will automatically get code completion support when yo
124
124
125
125
## Supported Events <aname="events">
126
126
127
-
### Entity Level Events <aname="entityEvents">
127
+
### Entity Level Events <aname="entity-events">
128
128
The table below lists all entity level events currently supported:
129
129
130
130
| Event | Description | Event Properties |
@@ -139,7 +139,7 @@ The table below lists all entity level events currently supported:
139
139
| `disambiguateBagItem` | A handler that can be used to modify the message that is shown to disambiguate between bag items when an entity match applies to more than one bag item. Note that this handler only fires when the skill configuration parameter `Use Enhanced Slot Filling` is switched on. | <ul><li><b>matchValue</b>: The entity value matched based on the user input</li><li><b>matchedBagItems</b>: list of the names of the bag items that are matched against the entity value.</li><li><b>userInput</b>: the last user input message that matched to multiple bag items.</li></ul>
140
140
| `userInputReceived` | A handler that can be used to inspect and modify new item matches and disambiguation values before the bag items are validated and updated. The handler is invoked on every turn while resolving the composite bag entity. | <ul><li><b>currentItem</b>: The full name of the bag item currently being resolved.</li><li><b>userInput</b>: the last user input message.</li><li><b>newItemMatches</b>: a key-value map where each key is the full name of a bag item, and the value the candidate value for the item. The new item matches can be changed using `context.setItemMatches` and `context.clearItemMatch`.</li><li><b>disambiguationValues</b>: a key-value map where each key is the full name of a bag item, and the value a list of matched values for the item. The disambiguation values for an item can be changed using `context.setDisambiguationValues()` or `context.clearDisambiguationValues()`</li><li><b>disambiguationItems</b>: a key-value map where each key is the full name of a bag item, and the value a map with two properties: <ul><li><b>matchValue</b>: an entity value that matches against multiple bag items</li><li> <b>matchedBagItems</b>: list of the names of all the bag items that match against the entity value. The first item in the list is used as the key in the disambiguationItems map.</li></ul> A disambiguation value that matches multiple items can be removed by calling `context.clearDisambiguationItems()` and passing the full name of the first item in the list as argument.</li></ul>
The table below lists all entity-item level events currently supported:
144
144
145
145
| Event | Description | Event Properties |
@@ -347,7 +347,7 @@ custom: {
347
347
}
348
348
```
349
349
350
-
### How to Invoke a REST API <a name="restSample">
350
+
### How to Invoke a REST API <a name="rest-sample">
351
351
Calling a REST API from within an event handler is straightforward. Since all event handlers are async, you can use the `await` keyword in combination with an NPM HTTP request module that supports JavaScript Promises, like `node-fetch`. This allows you to write your asynchronous code in a synchronous matter.
352
352
353
353
```javascript
@@ -371,7 +371,7 @@ entity: {
371
371
As you have seen in the previous examples, you can use `context.addMessage(<payload>)` to create a bot message that is sent to the user.
372
372
You can call this function multiple times to send multiple messages. See the section on [Conversation Messaging](https://github.com/oracle/bots-node-sdk/blob/master/MESSAGE_FACTORY.md) for code samples on how to create the various message types, like text, card, attachment, table and (editable) form messages.
373
373
374
-
### How to Modify Candidate Messages <a name="modifyMessage">
374
+
### How to Modify Candidate Messages <a name="modify-message">
375
375
376
376
In the `publishXXX` event handlers, you can receive the list of candidate messages created by the component by calling `context.getCandidateMessageList()`. This method returns a class representation of every message type, allowing you to use various methods in the class and in the `MessageFactory` to modify the message. You can then use `context.addMessage(<payload>)` to send the message. Here is an example:
0 commit comments