-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@microsoft/generator-bot-command-list Yeoman generator (#3200)
* Adding generator-bot-command-list to generator samples. * Moving generators\generator-bot-command-list to experimental\generators. * Updating generator-bot-command-list README.md to include instructions on how to install and use the template.
- Loading branch information
1 parent
1dca44e
commit e8dcee5
Showing
9 changed files
with
431 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
experimental/generators/generator-bot-command-list/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# @microsoft/generator-bot-command-list | ||
|
||
This template creates a bot built around a set of simple commands. It includes cards with ["message back" actions](https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions#messageback) for the commands "hello" and "help." | ||
|
||
## What this template is for | ||
|
||
Use this template if you want to... | ||
|
||
- Create a bot that relies on cards actions and/or regular expressions. | ||
- Build your bot by composing an ad-hoc set of packages. | ||
|
||
## Languages | ||
|
||
- English (en-US) | ||
|
||
## Azure Resource Deployment | ||
|
||
This template does not rely on any additional Azure Resources. | ||
|
||
## Using this template | ||
|
||
This template can be instantiated directly from the command line by cloning this repository to your local environment. | ||
|
||
First, install [Yeoman][yeoman] using [npm][npm] (we assume you have pre-installed [node.js][nodejs]): | ||
|
||
```bash | ||
npm install -g yo | ||
``` | ||
|
||
Next, navigate to the `generator-bot-command-list` directory in your locally cloned repository, and install the package's dependencies using [npm][npm]: | ||
|
||
```bash | ||
cd experimental\generators\generator-bot-command-list | ||
npm install | ||
``` | ||
|
||
Now create the directory where you would like to create your bot project: | ||
|
||
```bash | ||
mkdir CommandList | ||
cd CommandList | ||
``` | ||
|
||
Finally, generate your new bot using [Yeoman][yeoman], taking note of the following: | ||
|
||
- Replace `{REPO_ROOT_PATH}` with the directory that your copy of the repository has been cloned to. | ||
- `--platform` may be one of either `dotnet` or `js`, and will default to `dotnet` if not specified. | ||
- `--integration` may be one of either `webapp` or `functions`, and will default to `webapp` if not specified. | ||
|
||
```bash | ||
yo {REPO_ROOT_PATH}\experimental\generators\generator-bot-command-list\generators\app '{BOT_NAME}' --platform '{dotnet|js}' --integration '{webapp|functions}' | ||
``` | ||
|
||
## Next Steps | ||
|
||
You may now continue further editing your bot using [Bot Framework Composer](https://github.com/microsoft/botframework-composer). After opening your project, Composer will guide you through making customizations to your bot. If you'd like to extend your bot with code, you can open up your bot using your favorite IDE (like Visual Studio) from the directory you created earlier. | ||
|
||
## License | ||
|
||
[MIT License](https://github.com/microsoft/botframework-components/blob/main/LICENSE) | ||
|
||
[npm]: https://npmjs.com | ||
[nodejs]: https://nodejs.org/ | ||
[yeoman]: https://yeoman.io |
22 changes: 22 additions & 0 deletions
22
experimental/generators/generator-bot-command-list/generators/app/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
const { BaseGenerator } = require('@microsoft/generator-bot-adaptive'); | ||
|
||
module.exports = class extends BaseGenerator { | ||
initializing() { | ||
this.composeWith( | ||
require.resolve('@microsoft/generator-bot-adaptive/generators/app'), | ||
Object.assign({}, this.options, { | ||
arguments: this.args, | ||
applicationSettingsDirectory: 'settings', | ||
}) | ||
); | ||
} | ||
|
||
writing() { | ||
this._copyBotTemplateFiles(); | ||
} | ||
}; |
27 changes: 27 additions & 0 deletions
27
...mental/generators/generator-bot-command-list/generators/app/templates/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Welcome to your new bot | ||
|
||
This Bot Project was created using the Command List template. Your bot is an assistant-style bot - it is designed as a base for a bot that will help your users accomplish multiple different tasks. | ||
|
||
## Next steps | ||
|
||
### Start building your bot | ||
|
||
Composer can help guide you through getting started building your bot. From your bot settings page (the wrench icon on the left navigation rail), click on the rocket-ship icon on the top right for some quick navigation links. | ||
|
||
Another great resource if you're just getting started is the **[guided tutorial](https://docs.microsoft.com/en-us/composer/tutorial/tutorial-introduction)** in our documentation. | ||
|
||
### Connect with your users | ||
|
||
Your bot comes pre-configured to connect to our Web Chat and DirectLine channels, but there are many more places you can connect your bot to - including Microsoft Teams, Telephony, DirectLine Speech, Slack, Facebook, Outlook and more. Check out all of the places you can connect to on the bot settings page. | ||
|
||
### Publish your bot to Azure from Composer | ||
|
||
Composer can help you provision the Azure resources necessary for your bot, and publish your bot to them. To get started, create a publishing profile from your bot settings page in Composer (the wrench icon on the left navigation rail). Make sure you only provision the optional Azure resources you need! | ||
|
||
### Extend your bot with packages | ||
|
||
From Package Manager in Composer you can find useful packages to help add additional pre-built functionality you can add to your bot - everything from simple dialogs & custom actions for working with specific scenarios to custom adapters for connecting your bot to users on clients like Facebook or Slack. | ||
|
||
### Extend your bot with code | ||
|
||
You can also extend your bot with code - simply open up the folder that was generated for you in the location you chose during the creation process with your favorite IDE (like Visual Studio). You can do things like create custom actions that can be used during dialog flows, create custom middleware to pre-process (or post-process) messages, and more. See [our documentation](https://aka.ms/bf-extend-with-code) for more information. |
133 changes: 133 additions & 0 deletions
133
experimental/generators/generator-bot-command-list/generators/app/templates/botName.dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
{ | ||
"$kind": "Microsoft.AdaptiveDialog", | ||
"$designer": { | ||
"name": "<%= botName %>", | ||
"description": "", | ||
"id": "g28X3R" | ||
}, | ||
"autoEndDialog": true, | ||
"defaultResultProperty": "dialog.result", | ||
"triggers": [ | ||
{ | ||
"$kind": "Microsoft.OnConversationUpdateActivity", | ||
"$designer": { | ||
"id": "376720" | ||
}, | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.Foreach", | ||
"$designer": { | ||
"id": "518944", | ||
"name": "Loop: for each item" | ||
}, | ||
"itemsProperty": "turn.Activity.membersAdded", | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.IfCondition", | ||
"$designer": { | ||
"id": "641773", | ||
"name": "Branch: if/else" | ||
}, | ||
"condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)", | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "859266", | ||
"name": "Send a response" | ||
}, | ||
"activity": "${SendActivity_Welcome()}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"$kind": "Microsoft.OnIntent", | ||
"$designer": { | ||
"id": "BEyj14", | ||
"name": "Help" | ||
}, | ||
"intent": "Help", | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "3uLweb" | ||
}, | ||
"activity": "${SendActivity_3uLweb()}" | ||
}, | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "SqgATK" | ||
}, | ||
"activity": "${SendActivity_SqgATK()}" | ||
} | ||
] | ||
}, | ||
{ | ||
"$kind": "Microsoft.OnIntent", | ||
"$designer": { | ||
"id": "xU5haJ", | ||
"name": "Hello" | ||
}, | ||
"intent": "Hello", | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "0sM8e1" | ||
}, | ||
"activity": "${SendActivity_0sM8e1()}" | ||
}, | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "5R4USY" | ||
}, | ||
"activity": "${SendActivity_5R4USY()}" | ||
} | ||
] | ||
}, | ||
{ | ||
"$kind": "Microsoft.OnUnknownIntent", | ||
"$designer": { | ||
"id": "aMLM5i" | ||
}, | ||
"actions": [ | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "ufr1Ys" | ||
}, | ||
"activity": "${SendActivity_ufr1Ys()}" | ||
}, | ||
{ | ||
"$kind": "Microsoft.SendActivity", | ||
"$designer": { | ||
"id": "3GRctu" | ||
}, | ||
"activity": "${SendActivity_3GRctu()}" | ||
} | ||
] | ||
} | ||
], | ||
"generator": "<%= botName %>.lg", | ||
"id": "<%= botName %>", | ||
"recognizer": { | ||
"$kind": "Microsoft.RegexRecognizer", | ||
"intents": [ | ||
{ | ||
"intent": "Help", | ||
"pattern": "(?i)help" | ||
}, | ||
{ | ||
"intent": "Hello", | ||
"pattern": "(?i)(?:hello|hi|hey)" | ||
} | ||
] | ||
} | ||
} |
Empty file.
37 changes: 37 additions & 0 deletions
37
...ator-bot-command-list/generators/app/templates/language-generation/en-us/botName.en-us.lg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[import](common.lg) | ||
|
||
# SendActivity_Welcome() | ||
- ${CommandListCard()} | ||
|
||
# SendActivity_3uLweb() | ||
- I'm here to help with simple asks. I'm just a basic bot for now. | ||
- I'm a simple bot, I can help you with minimal requests. | ||
- For now, I can only help you with simple questions. | ||
|
||
# SendActivity_0sM8e1() | ||
- Hi there! | ||
- Hi. | ||
- Hello! | ||
|
||
# TextInput_Prompt_NrzzSX() | ||
[Activity | ||
Attachments = ${json(AdaptiveCardJson())} | ||
] | ||
|
||
# SendActivity_YO9zsV() | ||
- Sure, no worries. | ||
|
||
# SendActivity_ufr1Ys() | ||
- I'm not sure I understand. Can you please try again? | ||
- Hmm, I don't understand. Can you try to ask me in a different way? | ||
- I didn't get that. Would you mind rephrasing and try it again? | ||
- Unfortunately I misunderstood, please try again. | ||
|
||
# SendActivity_SqgATK() | ||
- ${CommandListCard()} | ||
|
||
# SendActivity_3GRctu() | ||
- ${CommandListCard()} | ||
|
||
# SendActivity_5R4USY() | ||
- ${CommandListCard()} |
110 changes: 110 additions & 0 deletions
110
...rator-bot-command-list/generators/app/templates/language-generation/en-us/common.en-us.lg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# CommandListCard | ||
[Activity | ||
Attachments = ${json(CommandListCardJson())} | ||
] | ||
|
||
# CommandListCardJson | ||
- ``` | ||
{ | ||
"type": "AdaptiveCard", | ||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | ||
"version": "1.2", | ||
"body": [ | ||
{ | ||
"type": "Container", | ||
"items": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "Type help or hello, or click the buttons below", | ||
"wrap": true | ||
} | ||
] | ||
} | ||
], | ||
"actions": [ | ||
{ | ||
"type": "Action.Submit", | ||
"title": "Help", | ||
"data": "Help" | ||
}, | ||
{ | ||
"type": "Action.Submit", | ||
"title": "Say hello", | ||
"data": "Hello" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
# AdaptiveCardJson() | ||
-``` | ||
{ | ||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | ||
"version": "1.0", | ||
"type": "AdaptiveCard", | ||
"speak": "", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "${whichOneDidYouMean()}", | ||
"weight": "Bolder" | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "${pickOne()}", | ||
"separator": "true" | ||
}, | ||
{ | ||
"type": "Input.ChoiceSet", | ||
"placeholder": "Placeholder text", | ||
"id": "userChosenIntent", | ||
"choices": [ | ||
{ | ||
"title": "${getIntentReadBack()}", | ||
"value": "luisResult" | ||
}, | ||
{ | ||
"title": "${getAnswerReadBack()}", | ||
"value": "qnaResult" | ||
}, | ||
{ | ||
"title": "None of the above", | ||
"value": "none" | ||
} | ||
], | ||
"style": "expanded", | ||
"value": "luis" | ||
}, | ||
{ | ||
"type": "ActionSet", | ||
"actions": [ | ||
{ | ||
"type": "Action.Submit", | ||
"title": "Submit", | ||
"data": { | ||
"intent": "chooseIntentCardResponse" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
# whichOneDidYouMean() | ||
- I'm not sure which one you mean. | ||
- Hmmm, I find that to be ambiguous. | ||
|
||
# pickOne() | ||
- Can you pick one ? | ||
- Can you help clarify by choosing one ? | ||
|
||
# getAnswerReadBack() | ||
- See an answer from the Knowledge Base | ||
|
||
# getIntentReadBack() | ||
- SWITCH : ${toLower(dialog.luisResult.intent)} | ||
- CASE : ${'GetUserProfile'} | ||
- Start filling in your profile(GetUserProfile intent) | ||
- DEFAULT : | ||
- ${dialog.luisResult.intent} |
Oops, something went wrong.