Skip to content

Commit d6e07ac

Browse files
New version 2.7.0 (#48)
- Added new event handler types LlmComponent and LlmTransformation - Added textStream message type - Added support for footerForm - Added support for rich form layout
1 parent 3148e06 commit d6e07ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2460
-898
lines changed

CUSTOM_COMPONENT.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
- [Using TypeScript](#ts)
88
- [The Metadata Object](#metadata)
99
- [The Invoke Method](#invoke)
10-
- [Control the Flow with keepTurn and transition](#flowControl)
10+
- [Control the Flow with keepTurn and transition](#flow-control)
1111
- [Access the Backend Using HTTP REST Calls](#rest)
1212
- [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)
1919
- [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)
2121

2222
## Introduction <a name="introduction">
2323

@@ -171,7 +171,7 @@ The argument of the `invoke` method is the `context` object. This object referen
171171

172172
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).
173173

174-
## Control the Flow with keepTurn and transition <a name="flowControl">
174+
## Control the Flow with keepTurn and transition <a name="flow-control">
175175

176176
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.
177177

@@ -238,7 +238,7 @@ The code to make REST calls with `node fetch` looks like this:
238238

239239
## Code Samples <a name="samples">
240240

241-
### How to Get a Component Property Value <a name="propertyValue">
241+
### How to Get a Component Property Value <a name="property-value">
242242

243243
You can call `context.properties()` to get an object that contains all the component properties. For example:
244244

@@ -272,7 +272,7 @@ or
272272
const name = context.properties()['name'] || '';
273273
```
274274

275-
### How to Get a Context Variable Value <a name="getVar">
275+
### How to Get a Context Variable Value <a name="get-var">
276276

277277
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:
278278

@@ -286,18 +286,18 @@ if (latitudeVariable) {
286286
}
287287
```
288288

289-
### How to Get a User or Profile Variable Value <a name="getProfile">
289+
### How to Get a User or Profile Variable Value <a name="get-profile">
290290

291291
To get the value of a user or profile variable, you prefix the name of the variable with `profile.` or `user.` as shown here.
292292
```javascript
293293
let _profileVarValue = context.getVariable('profile.<name>');
294294
let _userVarValue = context.getVariable('user.<name>');
295295
```
296-
### How to Get a Skill's Custom Parameter Value <a name="getCustomParam">
296+
### How to Get a Skill's Custom Parameter Value <a name="get-custom-param">
297297

298298
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.
299299

300-
### How to Set a Context Variable Value <a name="setVar">
300+
### How to Set a Context Variable Value <a name="set-var">
301301

302302
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:
303303

@@ -324,7 +324,7 @@ if (addressVariable){
324324
}
325325
```
326326

327-
### How to Set a Composite Bag Item Value <a name="setBagItem">
327+
### How to Set a Composite Bag Item Value <a name="set-bag-item">
328328

329329
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.
330330

@@ -364,7 +364,7 @@ You can call this function multiple times to send multiple messages. When you ca
364364

365365
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.
366366

367-
### How to Keep Prompting for User Input <a name="keepPrompting">
367+
### How to Keep Prompting for User Input <a name="keep-prompting">
368368

369369
This code sample keeps showing the user a random quote of the day until the user indicates they want to quit.
370370

DATA_QUERY_EVENT_HANDLER.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
- [Using TypeScript](#ts)
88
- [Writing SQL Query Handler Functions](#writing)
99
- [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)
1212
- [Access the Backend Using HTTP REST Calls](#rest)
1313
- [Code Samples](#samples)
14-
- [How to Set the Query Title](#queryTitle)
14+
- [How to Set the Query Title](#query-title)
1515
- [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)
2222

2323
## Introduction <a name="introduction">
2424

@@ -206,7 +206,7 @@ When using TypeScript, you will automatically get code completion support if you
206206

207207
## Supported Events <a name="events">
208208

209-
### Entity Level Events <a name="entityEvents">
209+
### Entity Level Events <a name="entity-events">
210210
The table below lists all entity level events:
211211

212212
| Event | Description | Event Properties |
@@ -215,7 +215,7 @@ The table below lists all entity level events:
215215
| `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>
216216
| `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>
217217

218-
### Attribute Level Events <a name="attributeEvents">
218+
### Attribute Level Events <a name="attribute-events">
219219
The table below lists all attribute level events:
220220

221221
| Event | Description | Event Properties |
@@ -266,7 +266,7 @@ All code samples are using TypeScript. If you are using JavaScript, you just nee
266266

267267
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.
268268

269-
### How to Set the Query Title<a name="queryTitle">
269+
### How to Set the Query Title<a name="query-title">
270270
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:
271271

272272
```javascript
@@ -291,7 +291,7 @@ entity: {
291291
}
292292
```
293293
294-
### How to Add a Footer Text<a name="footerText">
294+
### How to Add a Footer Text<a name="footer-text">
295295
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.
296296
297297
```javascript
@@ -314,7 +314,7 @@ changeBotMessages: async (event: ChangeBotMessagesEvent, context: DataQueryConte
314314
}
315315
```
316316
317-
### How to Add a Total Row <a name="totalRow">
317+
### How to Add a Total Row <a name="total-row">
318318
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.
319319
320320
```javascript
@@ -328,7 +328,7 @@ changeResponseData: async (event: ChangeResponseDataEvent, context: DataQueryCon
328328
}
329329
```
330330
331-
### 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">
332332
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.
333333
334334
```javascript
@@ -349,7 +349,7 @@ changeBotMessages: async (event: ChangeBotMessagesEvent, context: DataQueryConte
349349
}
350350
```
351351
352-
### 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">
353353
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.
354354
355355
```javascript
@@ -416,7 +416,7 @@ changeBotMessages: async (event, context) => {
416416
}
417417
```
418418
419-
### How to Change Attribute Display Settings <a name="attributeDisplay">
419+
### How to Change Attribute Display Settings <a name="attribute-display">
420420
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:
421421
```javascript
422422
hiredate: {
@@ -430,7 +430,7 @@ hiredate: {
430430
}
431431
```
432432
433-
### How to Format an Attribute Value <a name="attributeFormat">
433+
### How to Format an Attribute Value <a name="attribute-format">
434434
We can use the attribute level `format` event to format the attribute value.
435435
```javascript
436436
hiredate: {

ENTITY_EVENT_HANDLER.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
- [Using TypeScript](#ts)
88
- [Writing Event Handler Functions](#writing)
99
- [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)
1212
- [Access the Backend Using HTTP REST Calls](#rest)
1313
- [Code Samples](#samples)
1414
- [How to Conditionally Prompt for an Item](#prompt)
@@ -17,9 +17,9 @@
1717
- [How to Set or Update Bag Items](#update)
1818
- [How to Create a Summary Message](#summary)
1919
- [How to Use Custom Events](#custom)
20-
- [How to Invoke a REST API](#restSample)
20+
- [How to Invoke a REST API](#rest-sample)
2121
- [How to Send Rich Conversation Messages](#messages)
22-
- [How to Modify Candidate Messages](#modifyMessage)
22+
- [How to Modify Candidate Messages](#modify-message)
2323

2424
## Introduction <a name="introduction">
2525

@@ -124,7 +124,7 @@ When using TypeScript you will automatically get code completion support when yo
124124

125125
## Supported Events <a name="events">
126126

127-
### Entity Level Events <a name="entityEvents">
127+
### Entity Level Events <a name="entity-events">
128128
The table below lists all entity level events currently supported:
129129

130130
| Event | Description | Event Properties |
@@ -139,7 +139,7 @@ The table below lists all entity level events currently supported:
139139
| `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>
140140
| `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>
141141

142-
### Entity-Item Level Events <a name="itemEvents">
142+
### Entity-Item Level Events <a name="item-events">
143143
The table below lists all entity-item level events currently supported:
144144

145145
| Event | Description | Event Properties |
@@ -347,7 +347,7 @@ custom: {
347347
}
348348
```
349349
350-
### How to Invoke a REST API <a name="restSample">
350+
### How to Invoke a REST API <a name="rest-sample">
351351
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.
352352
353353
```javascript
@@ -371,7 +371,7 @@ entity: {
371371
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.
372372
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.
373373
374-
### How to Modify Candidate Messages <a name="modifyMessage">
374+
### How to Modify Candidate Messages <a name="modify-message">
375375
376376
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:
377377

0 commit comments

Comments
 (0)