UNPKG

10.7 kBMarkdownView Raw
1# MSBot Command Line tool
2
3[![npm version](https://badge.fury.io/js/msbot.svg)](https://badge.fury.io/js/msbot)
4
5The msbot tool is a command line tool to create and manipulate a bot resources via a .bot.
6
7
8# What is a .bot file?
9
10Bots usually consume lots of diverse services such as [LUIS.ai](http://luis.ai), or [QnaMaker.ai](http://qnamaker.ai). When you are developing a bot there is no uniform place to store the the metadata about the services that are in use. This prevents us from building tooling that looks at a bot as a whole.
11
12To address this problem we have created a **.bot file** to act as the place to unify all of these services together to enable tooling. For example: the new Bot Framework Emulator uses a the .bot file to create a unified view over the connected services your bot consumes.
13
14Via the .bot file you can register services like:
15
16* **Localhost** local debugger endpoints
17* [**Azure Bot Service**](https://azure.microsoft.com/en-us/services/bot-service/) Azure Bot Service registrations
18* [**LUIS.AI**](https://www.luis.ai/) Language Understanding (LUIS) allows your application to understand what a person wants in their own words.
19* [**QnA Maker**](https://qnamaker.ai/) Build, train and publish a simple question and answer bot based on FAQ URLs, structured documents or editorial content in minutes
20* [**Dispatcher**](https://github.com/Microsoft/botbuilder-tools/tree/master/Dispatch) models for dispatching across heterogeneous sources
21
22## Pre-requisite
23
24- [Node.js](https://nodejs.org/) version 8.5 or higher
25
26# Installation
27
28To install simply invoke npm
29
30```shell
31npm install -g msbot
32```
33
34This will install msbot into your global path.
35
36# Usage
37
38## Creating a bot file
39
40To create a bot file you run
41
42```shell
43msbot init [options]
44```
45
46It will ask you the name of the bot and the local endpoint for it and create the *name.bot* file.
47
48Arguments
49
50| Option | Description |
51| -------------------- | --------------- |
52| -n, --name <botname> | name of the bot |
53| -d, --description <description> |(optional) description of the bot|
54| -e, --endpoint <endpoint> |(optional) local endpoint for the bot|
55|-q, --quiet |do not prompt|
56|-h, --help |output usage information|
57
58Example:
59
60```shell
61msbot init --name TestBot --endpoint http://localhost:9499/api/messages
62```
63
64
65
66## Connecting your bot to a service
67
68To connect your bot to a service you run
69
70```shell
71msbot connect [command]
72```
73
74Where the command is one of the services
75
76| Command | Description |
77| ------ | ----------- |
78| azure |connect your bot to an Azure Bot Service registration|
79| localhost| connect your bot to a localhost endpoint|
80|luis |connect your bot to a LUIS application |
81| qna |connect your bot to a QnA Knowledgebase|
82|help [cmd] |display help for [cmd]|
83
84### Connecting to a Localhost service
85
86To connect your bot to localhost server you run
87
88```shell
89msbot connect localhost [options]
90```
91
92With the following options
93
94| Option | Description |
95| ---------------------------- | ------------------------------------------------------------ |
96| --secret <secret> | (Required) bot file secret password for encrypting service secrets |
97| -n, --name <name> | name of the azure bot service |
98| -a, --appId <appid> | (Required) Microsoft AppId for the Azure Bot Service |
99| -p, --appPassword <password> | (Required)Microsoft app password for the Azure Bot Service |
100| -e, --endpoint <endpoint> | (Required) endpoint for the bot using the MSA AppId |
101| -b, --bot <path> | (Optional) path to bot file. If omitted, local folder will look for a .bot file |
102| -h, --help | output usage information |
103
104Here is an example invocation:
105
106```shell
107msbot connect localhost --secret EncryptItPlease --name "Debug TestBot" --appId "562789d2-a344-445c-b4b1-41e8583f9f72" --appPassword 1abHDN3421342 --endpoint http://localhost:9090/api/messages
108```
109
110### Connecting to Azure Bot Service
111
112To connect your bot to Azure Bot Service you run
113
114```shell
115msbot connect azure [options]
116```
117
118With the following options
119
120|Option | Description|
121| ------ | ----------- |
122|-b, --bot <path> | (Optional) path to bot file. If omitted, local folder will look for a .bot file |
123|--secret <secret> |(Required) bot file secret password for encrypting service secrets|
124|-i, --id <id> |(Required) Azure Bot Service bot id|
125|-n, --name <name> |name of the azure bot service|
126|-a, --appId <appid> |(Required) Microsoft AppId for the Azure Bot Service|
127|-p, --appPassword <password> |(Required)Microsoft app password for the Azure Bot Service|
128|-e, --endpoint <endpoint> |(Required) endpoint for the bot using the MSA AppId|
129|-h, --help |output usage information|
130
131Here is an example invocation:
132```shell
133msbot connect azure --secret EncryptItPlease --id testbot --name "Test Bot" --appId "562789d2-a344-445c-b4b1-41e8583f9f72" --appPassword 1abHDN3421342 --endpoint https://testbot.azurewebsites.net/api/messages
134```
135
136
137
138### Connecting to LUIS Application
139
140To connect your bot to a LUIS application you run
141
142```shell
143msbot connect luis [options]
144```
145
146With the following options
147
148| Option | Description |
149| ---------------------------- | ------------------------------------------------------------ |
150|-b, --bot <path> | (Optional) path to bot file. If omitted, local folder will look for a .bot file |
151| --secret <secret> | (Required) bot file secret password for encrypting service secrets |
152| -n, --name <name> | name of the Luis application |
153| -a, --appId <appid> | (Required) Application Id for the LUIS application|
154|-v, --version <version> |version for the LUIS App, (example: v0.1)|
155| --authoringKey <authoringkey> |(Required) authoring key for authoring LUIS models via the authoring API |
156| -h, --help | output usage information|
157
158Here is an example invocation:
159
160```shell
161msbot connect luis --secret EncryptItPlease --name "My Luis Model" --appId "562789d2-a344-445c-b4b1-41e8583f9f72" --version v0.1 --authoringKey "6e5adf8b-88ea-46f3-ba2c-c97ecacd4304"
162```
163
164
165
166### Connecting to QnA Maker Knowledge base
167
168To connect your bot to a QNA maker knowledge base you run
169
170```shell
171msbot connect qna [options]
172```
173
174With the following options
175
176| Option | Description |
177| ----------------------------- | ------------------------------------------------------------ |
178| -b, --bot <path> | (Optional) path to bot file. If omitted, local folder will look for a .bot file |
179| --secret <secret> | (Required) bot file secret password for encrypting service secrets |
180| -n, --name <name> | name of the QnA knowledgebase |
181| -k, --kbId <kbId> |QnA Knowledgebase Id|
182| --subscriptionKey <subscriptionKey> | SubscriptionKey for accessing the qna service|
183| -h, --help | output usage information |
184
185Here is an example invocation:
186
187```shell
188msbot connect qna --secret EncryptItPlease --name "QnA Sauce" --kbId "cfbc14a3-9f69-4fb1-8882-e6f333691a2a" --subscriptionKey "cfbc14a3-9f69-4fb1-8882-e6f333691a2a"
189```
190
191### Connecting to Bot Dispatch
192
193To connect your bot to bot dispatch definition you run
194
195```shell
196msbot connect dispatch [options]
197```
198
199With the following options
200
201|Option | Description|
202| ------ | ----------- |
203|-b, --bot <path> | path to bot file. If omitted, local folder will look for a .bot file|
204|--secret <secret> | bot file secret password for encrypting service secrets|
205|-n, --name <name> | name for the dispatch|
206|-a, --appId <appid> | LUID AppId for the dispatch app|
207|-v, --version <version> | version for the dispatch app, (example: 0.1)|
208|--subscriptionKey <subscriptionKey> | subscription key used for querying the dispatch model|
209|--authoringKey <authoringkey> | authoring key for using manipulating the dispatch model via the LUIS authoring API|
210|--stdin | arguments are passed in as JSON object via stdin|
211|--input <dispatchfile> | arguments passed in as path to arguments in JSON format|
212
213Here is an example invocation:
214```shell
215msbot connect dispatch --input my.dispatch
216```
217
218## Listing connected services
219
220To access the list of connected services you run
221
222```shell
223msbot list [options]
224```
225
226Where options are:
227
228| Option | Description |
229| ----------------------------- | ------------------------------------------------------------ |
230| -b, --bot <path> |path to bot file. If omitted, local folder will look for a .bot file|
231|--secret <secret> | bot file secret password for encrypting service secrets|
232|-h, --help | output usage information|
233
234If you omit the secret, you will get the configured services with the secrets encrypted. If you pass the secret password, you will see the secrets decrypted.
235
236## Disconnecting a service
237You can remove a service by using the disconnect command
238
239```shell
240msbot disconnect [serviceid_or_name]
241```
242Where *serviceid_or_name* is the id or name of the connected service.
243Example using name:
244```shell
245msbot disconnect MyLuisApp
246```
247Example using id:
248```shell
249msbot disconnect "339411fa-ac8d-47ad-8d92-4b083a2c5305"
250```
251
252# Bot Secrets
253
254It is useful for tools like the emulator to have secure access to keys it needs to work with the services that are connected to the bot. The MSBot tool supports this by allowing you to specify a **secret** which is a password that is used to encrypt/decrypt secure keys in the .bot file.
255
256Any command which accepts the --secret option has data which needs to be encrypted with the secret.
257
258This allows you to check in a .bot file into a public repo safely, and only need the secret to unlock all of the keys your bot uses.
259
260> NOTE: You should make sure that you use the same secret when adding all of the services.