botbuilder-formflow
Version:
Form flow with subdialogs
184 lines (166 loc) • 3.9 kB
Plain Text
Version 1.0
Requirements:
- getParent support in formFlow
- formFlow should pass incoming arguments into actual values
- formFlow should allow to access original list of arguments
- every option could be:
-- value
-- callback (Promise based, mandatory arguments: session )
- autoloading of custom dialogs
- Messaging:
-- message
-- typing
-- attachments
- Session Management
- Routing to another dialog:
-- based on string (dialogId)
-- function
-- array (Waterfall)
- Custom step, a step with user specific logic
- Prompts:
-- suggested actions support for
-- list of prompts
--- text
--- number
--- email
--- confirm
--- time
--- url
--- choices
--- attachment
-- [TO ANALYZE] prompt options support
- New Custom Dialogs:
-- MenuDialog
-- TimedDialog
- Examples:
-- Messaging
-- Registration form
-- Custom validator for a prompt
-- Form with a subform
-- MenuDialog
- rich cards
- attachment support
- search support (. and * supported)
- post message (recognizer 0.9)
-
Changes:
- Removed `response` attribute
(session, args, resolve, reject) => {
}
Message samples
{ dialog : '/go/to/somewhere' },
{ typing : true},
{ endConversation : },
{
session : (session, flow, resolve, reject) => {
resolve();
}
}
{
session : {
userData : {
personal : {
"name" : "Gisma",
"email" : "some@email.com"
}
}
}
}
{ message : "Hello world!"},
{
message : "Select new action",
suggestedActions : [],
},
{
message : "Hello, ${session.userData.name}!"
}
{
message : (session, flow, resolve, reject) => {
resolve('Some message!');
}
}
{
type : "choice",
model : "my-choice",
message : "Please select your life's time choice"
choices : "power|money|beauty",
},
{
type : "confirm|email|number|text|time",
model : "confirm-result",
message : "Do you like me?",
validation : "Answer now! Yes or Now?"
},
{
type : "number",
model : "something-complex",
message : "Please, enter an amount to exchange (103.45 USD or 0.05 BTC)",
validation : (session, response, resolve, reject) => {
let values = response.response.trim().split(' ');
if ( 2 !== values.length ) {
reject('Invalid format (Exaples: 103.45 USD or 0.05 BTC)');
}
let correctCurrency = ['USD', 'BTC'].lastIndexOf(values[1].toUpperCase()) > -1;
if ( !correctCurrency ) {
reject('Wrong currency name (USD or BTC allowed)')
}
let value = parseFloat(values[0]);
if ( Number.isNaN(value) ) {
reject('I can't recognize a number')
}
https.get(url, function (res) {
res.on('data', (d) => {
if ( d.amount < value ) {
reject('Not enough money for exchange')
} else {
resolve(value);
}
});
});
}
},
{
type : "menu-dialog",
message : "Please, select an option"
suggestedActions : [
{
title : "Menu #1",
message : "menu1",
dialog : "/go/to/somewhere"
},
{
title : "Menu #2",
message : "menu1",
dialog : {
message : "You selected dialog!"
}
},
{
title : "Menu #3",
message : "menu1",
dialog : [
...
...
]
},
{
title : "Exit",
message : "menu1",
dialog : {endDialog : true}
}
]
},
{
type : "paging",
dataSource : "my-items" | function(session, flow, resolve , reject),
prevTitle : 'Prev',
nextTitle : 'Next',
exitTitle : '',
limit : 6
}
data : [
],
paging : {
current : 0
total : X
}