Skip to content

Commit 09d48e3

Browse files
doc fix an npm build fix
1 parent 6a45bac commit 09d48e3

File tree

5 files changed

+27
-30
lines changed

5 files changed

+27
-30
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ examples
1010
docs
1111
docshim.js
1212
jsdoc.json
13-
ts
13+
/ts
1414
tslint.json
1515
THIRDPARTY.md
1616
CONTRIBUTING.md

CUSTOM_COMPONENT.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ module.exports = {
4848
}
4949
}
5050
```
51-
The old style of defining the `invoke` function using the `done` callback argument is still supported:
51+
The old style of defining the `invoke` function using the `done` callback argument is still supported (with `conversation` as the old name for the `context` argument):
5252

5353
```javascript
54-
invoke: (context, done) => {
55-
context.reply('hello world');
54+
invoke: (conversation, done) => {
55+
conversation.reply('hello world');
5656
done();
5757
}
5858
}
@@ -64,7 +64,7 @@ In addition, you no longer have to remember to call `done()` at every place in y
6464

6565
When using typescript, the custom component class should implement the `CustomComponent` interface which requires two methods to be present:
6666
- the `metadata` method that should return an object of type `CustomComponentMetadata`.
67-
- the `invoke` method that should accept two arguments, the context of type `CustomComponentContext` and a callback of type `InvocationCallback`.
67+
- the `invoke` method that should accept one argument, the context of type `CustomComponentContext`.
6868

6969
```typescript
7070
import {CustomComponent, CustomComponentMetadata, CustomComponentContext, InvocationCallback } from '@oracle/bots-node-sdk/lib';
@@ -79,7 +79,7 @@ export class HelloWorld implements CustomComponent {
7979
}
8080
}
8181

82-
public async invoke(conversation: CustomComponentContext): Promise<void> {
82+
public async invoke(context: CustomComponentContext): Promise<void> {
8383
context.reply('hello world');
8484
}
8585
}

ENTITY_EVENT_HANDLER.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
An entity event handler (EEH) works in concert with a `System.ResolveEntities` (RE) or `System.CommonResponse` (CRC) component that is defined in the YAML dialog flow to resolve a composite bag entity. An EEH is deployed in a custom component service, in the same way as a custom component, but does not have its own state in the YAML. The RE or CRC component identifies a series of events which you can write event handlers for in an EEH component. Whenever such an event occurs, the RE or CRC component will check whether an EEH is registered with the composite bag entity, and whether the EEH has a handler defined for this specific event. If this is the case, the RE or CRC component will invoke the event handler method in the EEH.
2323

24-
This event-driven approach makes it much easier for a developer to execute the right code at the right moment while resolving the composite bag entity. Furthermore, it provides full control over the bot messages that are sent to the user, any "candidate" message generated by CRC or RE can always be replaced by writing a corresponding event handler.
24+
This event-driven approach makes it much easier for you to execute the right code at the right moment while resolving the composite bag entity. Furthermore, it provides full control over the bot messages that are sent to the user, any "candidate" message generated by CRC or RE can always be replaced by writing a corresponding event handler.
2525

2626
While freemarker expressions can still be used in the various fields of a composite bag item, you can choose to avoid writing any freemarker expressions by including the appropriate handlers in his EEH using Javascript.
2727

@@ -103,9 +103,9 @@ export class MyEntityEventHandler implements EntityEventHandler {
103103
## Writing Event Handler Functions <a name="writing">
104104

105105
The first argument of each event method is the `event` object. The properties available in this object depend on the type of event.
106-
See the list of supported entity events for information pn which properties are available with which event.
106+
See the list of supported entity events for information on which properties are available with which event.
107107

108-
The second argument each event method is the `context` object. This object references the [EntityResolutionContext](https://oracle.github.io/bots-node-sdk/EntityResolutionContext.html) that provides access to many convenience methods to create your event handler logic.
108+
The second argument of each event method is the `context` object. This object references the [EntityResolutionContext](https://oracle.github.io/bots-node-sdk/EntityResolutionContext.html) that provides access to many convenience methods to create your event handler logic.
109109

110110
More information on creating conversation messages from an event handler can be found [here](https://github.com/oracle/bots-node-sdk/blob/master/MESSAGE_MODEL.md).
111111

@@ -128,7 +128,7 @@ The table below lists all entity level events currently supported:
128128

129129
| Event | Description | Event Properties |
130130
|--|--|--|
131-
| validate | Handler for entity-level validations that include two or more bag item values. Validation errors can be registered by calling context.addValidationError(itemName,errorMessage). If validation should fail, this handler should return false. if validation fails, NONE of the item values provided by the user in the last user message will be updated.<br/><br/>NOTE: This handler is called when at least one bag item value has changed. | <ul><li><b>newValues</b>: JSONObject with key-value pairs where key is the item name and value the new item value.</li><li><b>oldValues</b>: JSONObject with key-value pairs where key is the item name and value the old item value.</li><li><b>currentItem</b>: name of item currently being resolved.</li></ul>
131+
| validate | Handler for entity-level validations that include two or more bag item values. Validation errors can be registered by calling `context.addValidationError(itemName,errorMessage)`. If validation should fail, this handler should return false. if validation fails, NONE of the item values provided by the user in the last user message will be updated.<br/><br/>NOTE: This handler is called when at least one bag item value has changed. | <ul><li><b>newValues</b>: JSONObject with key-value pairs where key is the item name and value the new item value.</li><li><b>oldValues</b>: JSONObject with key-value pairs where key is the item name and value the old item value.</li><li><b>currentItem</b>: name of item currently being resolved.</li></ul>
132132
| publishMessage | Generic fallback handler that is called when item-specific prompt or disambiguate handler is not specified. | <ul><li><b>currentItem</b>: name of item currently being resolved.</li><li><b>promptCount</b>: number of times the user is prompted for current item (only set in case of prompt event).</li><li><b>disambiguationValues</b>: list of values that matches the user input (only set in case of disambiguate event).</li></ul>
133133
| maxPromptsReached | Generic fallback handler when item-specific handler for reaching max prompts is not specified. | <ul><li><b>currentItem</b>: name of item currently being resolved.</li><li><b>promptCount</b>: number of times the user is prompted for current item (only set in case of prompt event).</li></ul>
134134
| resolved | Function that gets called when the composite bag entity is resolved. You will typically use this function to call some backend API to complete the transaction which the composite bag entity collected the data for. If the backend API call return some errors, possibly forcing you to re-prompt for some invalid bag items, you can do so by simply clearing those bag items. The RE/CRC component will notice the entity is not fully resolved after all, and will resume prompting for missing bag items. | none
@@ -148,7 +148,7 @@ The table below lists all entity-item level events currently supported:
148148

149149
## Code Samples <a name="samples">
150150

151-
The samples below use an Expense composite bag entity, which has the following items:
151+
The samples below use an `Expense` composite bag entity, which has the following items:
152152

153153
| Name | Type | Entity Name |
154154
|--|--|--|
@@ -158,7 +158,7 @@ The samples below use an Expense composite bag entity, which has the following i
158158
| Type | Entity | ExpenseType
159159

160160
### How to conditionally prompt for an item <a name="prompt">
161-
We only want to prompt for a receipt when the expense amount is greater than 25 dollars. This can be achieved by adding the shouldPrompt event handler for an item
161+
We only want to prompt for a receipt when the expense amount is greater than 25 dollars. This can be achieved by adding the `shouldPrompt` event handler for an item
162162

163163
```javascript
164164
items: {
@@ -169,7 +169,7 @@ items: {
169169
}
170170
```
171171
172-
Note here that the Amount item returns a CURRENCY JSON object, and amount property inside this object holds the amount value.
172+
Note here that the `Amount` item returns a `CURRENCY` JSON object, and `amount` property inside this object holds the amount value.
173173
174174
### How to validate an item <a name="validate">
175175
Here is the event handler to enforce the expense amount is at least 5:
@@ -186,7 +186,7 @@ items: {
186186
}
187187
```
188188
189-
Note how we obtain the new value from the validation event object. And since the Amount item value is a CURRENCY JSON object, we need to obtain the amount property from it. We use the `addValidationError` function to register the error message . We could also have used `conversation.reply()` directly. The difference is that when using `conversation.reply()` further processing in the RE/CRC component is stopped, so other items that just got a value are not validated.
189+
Note how we obtain the new value from the validation event object. And since the `Amount` item value is a CURRENCY JSON object, we need to obtain the `amount` property from it. We use the `addValidationError` function to register the error message . We could also have used `conversation.reply()` directly. The difference is that when using `conversation.reply()` further processing in the RE/CRC component is stopped, so other items that just got a value are not validated.
190190
191191
To read the validation error message from the skill resource bundle, instead of hardcoding the text, the translate function can be used:
192192

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This section explains the basic CLI commands to get your component service up an
3131
bots-node-sdk init MyComponentService
3232
```
3333

34-
This creates a new commponent service named `MyComponentService` in a directory by the same name.
34+
This creates a new component service named `MyComponentService` in a directory by the same name.
3535
The component service includes one sample custom component named `helloWorld`.
3636

3737
### Adding a Custom Component to Existing Service
@@ -103,12 +103,12 @@ See the README.md created in your scaffolded typescript project for more informa
103103
<!--[nodoc]-->
104104
- [Using the CLI](https://github.com/oracle/bots-node-sdk/blob/master/bin/CLI.md) - Command line capabilities to facilitate writing custom components and entity event handlers.
105105
- [Writing Custom Components](https://github.com/oracle/bots-node-sdk/blob/master/CUSTOM_COMPONENT.md) - Guidelines and tips for writing custom components.
106-
- [Writing Entity Event Handlers](https://github.com/oracle/bots-node-sdk/blob/master/ENTIY_EVENT_HANDLER.md) - Guidelines and tips for writing entity event handlers.
107-
- [Conversation Messaging](https://github.com/oracle/bots-node-sdk/blob/master/MESSAGE_MODEL.md) - Creating conversation messages from custom code
106+
- [Writing Entity Event Handlers](https://github.com/oracle/bots-node-sdk/blob/master/ENTITY_EVENT_HANDLER.md) - Guidelines and tips for writing entity event handlers.
107+
- [Conversation Messaging](https://github.com/oracle/bots-node-sdk/blob/master/MESSAGE_MODEL.md) - Creating conversation messages from custom code.
108108
- [Writing Webhooks](https://github.com/oracle/bots-node-sdk/blob/master/WEBHOOK.md) - Integrate with custom messaging channels using incoming/outgoing webhook.
109109
- [Unit Testing](https://github.com/oracle/bots-node-sdk/blob/master/testing/TESTING.md) - Unit testing facilities.
110110
- [Documentation](https://oracle.github.io/bots-node-sdk) - Full SDK documentation.
111-
- [Release Notes](https://github.com/oracle/bots-node-sdk/blob/master/RELEASE_NOTES.md) - List of new features and fixed issues for each release
111+
- [Release Notes](https://github.com/oracle/bots-node-sdk/blob/master/RELEASE_NOTES.md) - List of new features and fixed issues for each release.
112112
<!--[/nodoc]-->
113113

114114
## Contributing

bin/CLI.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# CLI Developer Tools
22

3-
This SDK includes a CLI with developer-oriented productivity tools.
4-
Presently these tools are geared towards **Custom Component** development.
3+
This SDK includes a command-line intertace (CLI) to help you creating and packaging custom components and entity event handlers.
54

65
```text
76
Usage: bots-node-sdk [options] <subcommand> [options]
@@ -36,9 +35,9 @@ bots-node-sdk init
3635
bots-node-sdk init my-project
3736
```
3837

39-
> Creates a fresh Custom Component package in an empty directory
38+
> Creates a fresh custom component service package in an empty directory
4039
41-
As an alterative approach, install `@oracle/bots-node-sdk` as a dependency
40+
As an alternative approach, install `@oracle/bots-node-sdk` as a dependency
4241
dependency to your application, and use commands accordingly.
4342

4443
```shell
@@ -50,16 +49,16 @@ npm install --save-dev @oracle/bots-node-sdk
5049
$(npm bin)/bots-node-sdk init
5150
```
5251

53-
> Initializes a new Custom Component package from within an existing node project.
52+
> Initializes a new custom component service package from within an existing node project.
5453
5554
## Usage
5655

5756
| Command | Feature | Description |
5857
|--|--|--|
59-
| `init` | Components | Generates source code for Custom Component projects |
58+
| `init` | Components | Generates source code for custom component service projects |
6059
| `init component` | Components | Adds a component to an existing project |
61-
| `service` | Components | Starts a local server for hosting a Component Package |
62-
| `pack` | Components | Validates project and creates a deployable Component Package artifact |
60+
| `service` | Components | Starts a local server for hosting a component package |
61+
| `pack` | Components | Validates project and creates a deployable component package |
6362

6463
### 1. Start a project: `init [options] [dest]`
6564

@@ -78,7 +77,7 @@ projects with more components. If provided, `[dest]` or `--name` will be used fo
7877
### 2. Add Components: `init component <name> <type> <dest>`
7978

8079
This command will create a _new_ custom component or event handler within an **existing** component
81-
package, and write to the `<dest>` output path. If the output path is not specified, the component will be written to the `components` directory or `src\components` directory when using typesript. If this directory doesn't exist it will be created.
80+
package, and write to the `<dest>` output path. If the output path is not specified, the component will be written to the `components` directory or `src\components` directory when using typescript. If this directory doesn't exist it will be created.
8281
The component `<name>` and `<type>` are required and `<type>` should be set to `[c]ustom` or `[e]ntityEventHandler`.
8382

8483
For example, to create a new entity event handler component named `resolvePizza`, you can use the following command:
@@ -104,9 +103,7 @@ A node supervisor may also be used in the same way.
104103

105104
### 4. Package for Deployment: `pack [options]`
106105

107-
Most often, custom implementations can be packaged with `npm pack` or `zip`
108-
depending on the deployment target. The `pack` command here is intended to
109-
provide validation and convenience methods for creating a deployable artifact.
106+
The `npm pack` command can be used to package the component service as a `.tgz` file that can be uploaded to the ODA embedded container.
110107

111108
| Option | Description | Default |
112109
|--|--|--|

0 commit comments

Comments
 (0)