|
| 1 | +bf-chatdown |
| 2 | +======== |
| 3 | + |
| 4 | +Tool for parsing chat files and outputting replayable activities |
| 5 | + |
| 6 | +[](https://oclif.io) |
| 7 | +[](https://npmjs.org/package/bf-chatdown) |
| 8 | +[](https://npmjs.org/package/bf-chatdown) |
| 9 | +[](https://github.com/Microsoft/chatdown/blob/master/package.json) |
| 10 | + |
| 11 | +<!-- toc --> |
| 12 | +* [Usage](#usage) |
| 13 | +* [Commands](#commands) |
| 14 | +<!-- tocstop --> |
| 15 | +# Usage |
| 16 | +<!-- usage --> |
| 17 | +```sh-session |
| 18 | +$ npm install -g chatdown |
| 19 | +$ bf COMMAND |
| 20 | +running command... |
| 21 | +$ bf (-v|--version|version) |
| 22 | +chatdown/1.2.3 darwin-x64 node-v12.1.0 |
| 23 | +$ bf --help [COMMAND] |
| 24 | +USAGE |
| 25 | + $ bf COMMAND |
| 26 | +... |
| 27 | +``` |
| 28 | +<!-- usagestop --> |
| 29 | +# Commands |
| 30 | +<!-- commands --> |
| 31 | +* [`bf chatdown [chat]`](#bf-chatdown-chat) |
| 32 | + |
| 33 | +## `bf chatdown [chat]` |
| 34 | + |
| 35 | +Chatdown is a transcript generator which consumes a .chat file to generate mock transcripts. Generated mock transcript files are output to stdout. |
| 36 | + |
| 37 | +A good bot, just like any successful application or a website, starts with clarity on supported scenarios. Creating mockups of conversations between bot and user is useful for: |
| 38 | + |
| 39 | +Framing the scenarios supported by the bot. |
| 40 | +Business decision makers to review, provide feedback. |
| 41 | +Defining a "happy path" (as well as other paths) through conversational flows between a user and a bot |
| 42 | +.chat file format helps you create mockups of conversations between a user and a bot. Chatdown CLI tool converts .chat files into conversation transcripts (.transcript files) that can be viewed in the Bot Framework Emulator. |
| 43 | + |
| 44 | +``` |
| 45 | +USAGE |
| 46 | + $ bf chatdown [CHAT] |
| 47 | +
|
| 48 | +ARGUMENTS |
| 49 | + CHAT The path of the chat file to be parsed. If omitted, stdin will be used. |
| 50 | +
|
| 51 | +OPTIONS |
| 52 | + -h, --help show CLI help |
| 53 | + --static Use static timestamps when generating timestamps on activities. |
| 54 | +``` |
| 55 | +## .chat File Format |
| 56 | + |
| 57 | +Here's an example `.chat` file: |
| 58 | + |
| 59 | +```markdown |
| 60 | +user=Joe |
| 61 | +bot=LulaBot |
| 62 | + |
| 63 | +bot: Hi! |
| 64 | +user: yo! |
| 65 | +bot: [Typing][Delay=3000] |
| 66 | +Greetings! |
| 67 | +What would you like to do? |
| 68 | +* update - You can update your account |
| 69 | +* List - You can list your data |
| 70 | +* help - you can get help |
| 71 | + |
| 72 | +user: I need the bot framework logo. |
| 73 | + |
| 74 | +bot: |
| 75 | +Here you go. |
| 76 | +[Attachment=bot-framework.png] |
| 77 | +[Attachment=http://yahoo.com/bot-framework.png] |
| 78 | +[AttachmentLayout=carousel] |
| 79 | + |
| 80 | +user: thanks |
| 81 | +bot: |
| 82 | +Here's a form for you |
| 83 | +[Attachment=card.json adaptivecard] |
| 84 | + |
| 85 | +``` |
| 86 | + |
| 87 | +> See the [Examples](https://github.com/Microsoft/botbuilder-tools/tree/master/packages/Chatdown/Examples) folder for more samples. |
| 88 | +
|
| 89 | + |
| 90 | +Chat files are markdown files that contain 2 parts: |
| 91 | +- Header that defines who the participants are in the conversation |
| 92 | +- Back and forth conversation between a user and a bot |
| 93 | + |
| 94 | +### Header |
| 95 | +The header defines who the participants are in the conversation and defines other options. |
| 96 | + |
| 97 | +|Option |Description| |
| 98 | +|---------------------|------------------------------| |
| 99 | +|`user=<user>` |This option tells chatdown that a user message will begin with `<user>` followed by a colon. For example, `user=Joe` instructs chatdown that lines beginning with `Joe:` or `user:` are the start of a message from the user Joe. | |
| 100 | +|`users=<user1>,<user2>,<user3>` |This option tells chatdown that there are multiple users in the conversation. | |
| 101 | +|`bot=<bot>` | This options tells chatdown that a bot message will begin with `<bot>` followed by a colon. For example, `bot=LulaBot` instructs chadown that lines beginning with `LulaBot:` or `bot:` are the start of a message from the bot Lulabot. | |
| 102 | +| `channelId=<channelID>`| This option tells chatdown to use the specified `channelID` for each activity.| |
| 103 | + |
| 104 | +Once the configuration options for `users` and `bot` are defined, the rest of the conversation can use the alias prefixes `user:` and `bot:` or the names directly. Chatdown will correctly make the associations to the specified names for you. |
| 105 | + |
| 106 | +> The Bot will default to sending to the first user in the users list or the last user it received a message from, unless you directly specify a target user by using the bot->user: syntax. |
| 107 | +
|
| 108 | +For example: |
| 109 | +```markdown |
| 110 | +users=Joe,Fred |
| 111 | + |
| 112 | +bot: This will go to Joe, because he's first in the list |
| 113 | +Fred: What about me? |
| 114 | +bot: This will go to Fred, because he's the latest user to talk to the bot |
| 115 | +bot->Joe: This will always go to Joe |
| 116 | +bot->Fred: This will always go to Fred |
| 117 | +``` |
| 118 | + |
| 119 | +### Conversation |
| 120 | +The conversation between the user and the bot with markdown support for bot's responses. Every time a `user:` or `bot:` is found at the beginning of the line, a new activity will be inserted into the transcript. Inside the markdown, you can insert commands to generate richer transcripts: |
| 121 | + |
| 122 | +### Activity commands |
| 123 | +| Command | Description | |
| 124 | +| --------------- | ------------------------------------------------------------ | |
| 125 | +|`[Typing]` | Inserts a typing activity into the transcript to signify that a user or a bot is typing. | |
| 126 | +|`[Delay=<milliseconds>]` | Delays the transcript by `<milliseconds>`. | |
| 127 | +|`[ConversationUpdate=]` | Sends a conversationUpdate, with membersAdded= and membersRemoved= values| |
| 128 | + |
| 129 | +Example ConversationUpdate message |
| 130 | +```markdown |
| 131 | +[ConversationUpdate= |
| 132 | + MembersAdded=Joe,Susan] |
| 133 | +bot->Joe: Hi Joe! |
| 134 | +bot->Susan: Hi Susan! |
| 135 | +``` |
| 136 | + |
| 137 | +### Message commands |
| 138 | +When sending a message there are a number of commands for controlling layout. |
| 139 | + |
| 140 | +|Command | Description | |
| 141 | +|------------------|-----------------------------------------------------------| |
| 142 | +|<code>[Suggestions=<Option 1>|<Option 2>|<Option 3>]</code> | Add suggested action buttons, delimited by <code>|</code> | |
| 143 | +|`[AttachmentLayout=LayoutType]`| Specify how multiple attachments would be displayed. Layout types are `carousel` or `list`| |
| 144 | + |
| 145 | + |
| 146 | +#### Message Cards |
| 147 | +You can add cards using simple commands as well. Currently we support a number of cards: |
| 148 | + |
| 149 | +| description | card name | |
| 150 | +| ----------- | ------------------------------------------------------------ | |
| 151 | +| HeroCard | A simple card with single large image, title, subtitle, text and buttons | |
| 152 | +| ThumbnailCard | Same as herocard, but image is much smaller | |
| 153 | +| AudioCard | send audio card for playing back an audio url | |
| 154 | +| VideoCard | send an video player card for playing back a video file | |
| 155 | +| AnimationCard | send a animated gif card | |
| 156 | +| MediaCard | send arbitrary media with transport control | |
| 157 | +| SigninCard | send a signin card | |
| 158 | +| OauthCard | send an oauth card which uses azure bot service oauth flow |
| 159 | + |
| 160 | +```markdown |
| 161 | +Bot: |
| 162 | +[Herocard |
| 163 | + title=Cheese gromit! |
| 164 | + subtitle=Hero Card |
| 165 | + text=This is some text describing the card, it's cool because it's cool |
| 166 | + image=https://memegenerator.net/img/instances/500x/73055378/cheese-gromit.jpg |
| 167 | + buttons=Option 1| Option 2| Option 3] |
| 168 | + |
| 169 | +Bot: |
| 170 | +[ThumbnailCard |
| 171 | + title=Cheese gromit! |
| 172 | + subtitle=Thumbnail Card |
| 173 | + text=This is some text describing the card, it's cool because it's cool |
| 174 | + image=https://memegenerator.net/img/instances/500x/73055378/cheese-gromit.jpg |
| 175 | + buttons=Option 1| Option 2| Option 3] |
| 176 | +``` |
| 177 | +The properties that are supported are |
| 178 | + |
| 179 | +| property | description | |
| 180 | +|----|----| |
| 181 | +| title | The title of the card| |
| 182 | +| subtitle| a subtitle for the card with less emphasis| |
| 183 | +| text | a generic text property which can contain longer text describing the card| |
| 184 | +| image | image url to use for the card | |
| 185 | +| buttons | a set of button labels separated by `|`| |
| 186 | + |
| 187 | + |
| 188 | +#### Message Attachments |
| 189 | +To add an attachment, you use `[Attachment=path contentPath]`. The path can be a URL or a local path (either absolute or relative to `.chat` file). The content type is optional and if not passed, will be inferred from the file extension. You can also pass it using a shortcut or full mime type. |
| 190 | + |
| 191 | +```markdown |
| 192 | +[Attachment=path contentType] |
| 193 | +``` |
| 194 | + |
| 195 | +The following examples illustrates sending a carousel of photos: |
| 196 | +```markdown |
| 197 | +Enjoy these pictures! |
| 198 | +[AttachmentLayout=carousel] |
| 199 | +[Attachment=http://4.bp.blogspot.com/--cFa6t-x4qY/UAqEgUvPd2I/AAAAAAAANIg/pMLE080Zjh4/s1600/turtle.jpg] |
| 200 | +[Attachment=http://viagemempauta.com.br/wp-content/uploads/2015/09/2_All-Angle-By-Andreza-dos-Santos_FTS_2914-344-620x415.jpg] |
| 201 | +[Attachment=http://images.fineartamerica.com/images-medium-large/good-morning-turtles-freund-gloria.jpg] |
| 202 | +[Attachment=http://4.bp.blogspot.com/--cFa6t-x4qY/UAqEgUvPd2I/AAAAAAAANIg/pMLE080Zjh4/s1600/turtle.jpg] |
| 203 | +[Attachment=image.png] |
| 204 | +``` |
| 205 | + |
| 206 | +This example sends a local adaptive card using a content type shortcut: |
| 207 | +```markdown |
| 208 | +[Attachment=folder/sample.json "adaptivecard"] |
| 209 | +``` |
| 210 | + |
| 211 | +#### Attachment content type shortcuts |
| 212 | +Some of the content types have shortcuts: |
| 213 | + |
| 214 | +| ContentType Shortcuts | Description | |
| 215 | +| ----------------------|--------------------------------------------| |
| 216 | +| animation | `application/vnd.microsoft.card.animation` | |
| 217 | +| audio | `application/vnd.microsoft.card.audio` | |
| 218 | +| hero | `application/vnd.microsoft.card.hero` | |
| 219 | +| receipt | `application/vnd.microsoft.card.receipt` | |
| 220 | +| thumbnail | `application/vnd.microsoft.card.thumbnail` | |
| 221 | +| signin | `application/vnd.microsoft.card.signin` | |
| 222 | +| video | `application/vnd.microsoft.card.video` | |
| 223 | +| adaptivecard | `application/vnd.microsoft.card.adaptive` | |
| 224 | +| *application/custom* | `application/custom` | |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | +## CLI Examples |
| 229 | + |
| 230 | +### Basic usage |
| 231 | +In the simplest form, a chatdown command looks like the following: |
| 232 | +```bash |
| 233 | +bf chatdown sample.chat > sample.transcript |
| 234 | +``` |
| 235 | +This will consume `sample.chat` and output `sample.transcript`. |
| 236 | + |
| 237 | +### Using stdin |
| 238 | +stdin can be used as an alternative to specifying an input file. |
| 239 | +```bash |
| 240 | +(echo user=Joe && echo bot=LulaBot && echo Joe: 'Hi!' && echo LulaBot: 'Hi there!') | bf chatdown > sample.transcript |
| 241 | +``` |
| 242 | + |
| 243 | +### Using stdout |
| 244 | +stdout can be used as an alternative to specifying the output file. |
| 245 | +```bash |
| 246 | +bf chatdown sample.chat |
| 247 | +``` |
| 248 | +or |
| 249 | +```bash |
| 250 | +bf chatdown sample.chat > joe.transcript |
| 251 | +``` |
| 252 | +The transcript will be piped to stdout. |
| 253 | +_See code: [src/commands/chatdown.ts](https://github.com/Microsoft/chatdown/blob/v1.2.3/src/commands/chatdown.ts)_ |
| 254 | +<!-- commandsstop --> |
0 commit comments