@@ -417,6 +417,37 @@ export interface IPromptsOptions {
417
417
defaultRetryPrompt ?: string ;
418
418
}
419
419
420
+ /** Context information passed to field related handlers. */
421
+ export interface IFieldConext {
422
+ userData : any ;
423
+ form : any ;
424
+ field : string ;
425
+ }
426
+
427
+ /**
428
+ * Handler that gets called anytime a field is about to invoke a prompt.
429
+ */
430
+ export interface IFieldPromptHandler {
431
+ /**
432
+ * @param context Contextual information related to the current field.
433
+ * @param next Function to call to continue execution of the prompt.
434
+ * Passing _true_ for __skip__ will cause the current field to be skipped.
435
+ */
436
+ ( context : IFieldConext , next : ( skip : boolean ) => void ) : void ;
437
+ }
438
+
439
+ /** Options passed to form fields. */
440
+ export interface IFieldOptions extends IPromptOptions {
441
+ /**
442
+ * Called anytime a given field is about to invoke the prompt. This function lets the
443
+ * developer progromatically determine if a prompt should be skipped or not.
444
+ *
445
+ * The handler can also manipulate the forms current values. For instance a fields value
446
+ * could be pulled from context.userData if not already specified on the form.
447
+ */
448
+ onPrompt ?: IFieldPromptHandler ;
449
+ }
450
+
420
451
/** A recognized intent. */
421
452
export interface IIntent {
422
453
/** Intent that was recognized. */
@@ -1318,7 +1349,7 @@ export class Prompts extends Dialog {
1318
1349
* * __prompt:__ _{string}_ - Initial message to send the user.
1319
1350
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1320
1351
* * __prompt:__ _{IMessage}_ - Initial message to send the user. Message can contain attachments.
1321
- * @param options Optional flags parameters to control the behaviour of the prompt.
1352
+ * @param options Optional parameters to control the behaviour of the prompt.
1322
1353
*/
1323
1354
static number ( session : Session , prompt : string | string [ ] | IMessage , options ?: IPromptOptions ) : void ;
1324
1355
@@ -1329,7 +1360,7 @@ export class Prompts extends Dialog {
1329
1360
* * __prompt:__ _{string}_ - Initial message to send the user.
1330
1361
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1331
1362
* * __prompt:__ _{IMessage}_ - Initial message to send the user. Message can contain attachments.
1332
- * @param options Optional flags parameters to control the behaviour of the prompt.
1363
+ * @param options Optional parameters to control the behaviour of the prompt.
1333
1364
*/
1334
1365
static confirm ( session : Session , prompt : string | string [ ] | IMessage , options ?: IPromptOptions ) : void ;
1335
1366
@@ -1344,7 +1375,7 @@ export class Prompts extends Dialog {
1344
1375
* * __choices:__ _{string}_ - List of choices as a pipe ('|') delimted string.
1345
1376
* * __choices:__ _{Object}_ - List of choices expressed as an Object map. The objects field names will be used to build the list of values.
1346
1377
* * __choices:__ _{string[]}_ - List of choices as an array of strings.
1347
- * @param options Optional flags parameters to control the behaviour of the prompt.
1378
+ * @param options Optional parameters to control the behaviour of the prompt.
1348
1379
*/
1349
1380
static choice ( session : Session , prompt : string | string [ ] | IMessage , choices : string | Object | string [ ] , options ?: IPromptOptions ) : void ;
1350
1381
@@ -1355,11 +1386,89 @@ export class Prompts extends Dialog {
1355
1386
* * __prompt:__ _{string}_ - Initial message to send the user.
1356
1387
* * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1357
1388
* * __prompt:__ _{IMessage}_ - Initial message to send the user. Message can contain attachments.
1358
- * @param options Optional flags parameters to control the behaviour of the prompt.
1389
+ * @param options Optional parameters to control the behaviour of the prompt.
1359
1390
*/
1360
1391
static time ( session : Session , prompt : string | string [ ] | IMessage , options ?: IPromptOptions ) : void ;
1361
1392
}
1362
1393
1394
+ /**
1395
+ *
1396
+ */
1397
+ export class Fields {
1398
+ /**
1399
+ * Captures from the user a raw string of text and saves it to a field on a form.
1400
+ * @param field Name of the field to save the users response to.
1401
+ * @param prompt
1402
+ * * __prompt:__ _{string}_ - Initial message to send the user.
1403
+ * * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1404
+ * @param options Optional parameters to control the behaviour of the field.
1405
+ */
1406
+ static text ( field : string , prompt : string | string [ ] , options ?: IFieldOptions ) : IDialogWaterfallStep ;
1407
+
1408
+ /**
1409
+ * Prompts the user to enter a number and saves it to a field on a form.
1410
+ * @param field Name of the field to save the users response to.
1411
+ * @param prompt
1412
+ * * __prompt:__ _{string}_ - Initial message to send the user.
1413
+ * * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1414
+ * @param options Optional parameters to control the behaviour of the field.
1415
+ */
1416
+ static number ( field : string , prompt : string | string [ ] , options ?: IFieldOptions ) : IDialogWaterfallStep ;
1417
+
1418
+ /**
1419
+ * Prompts the user to enter a boolean yes/no response and saves their answer to a field on a form.
1420
+ * @param field Name of the field to save the users response to.
1421
+ * @param prompt
1422
+ * * __prompt:__ _{string}_ - Initial message to send the user.
1423
+ * * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1424
+ * @param options Optional parameters to control the behaviour of the field.
1425
+ */
1426
+ static confirm ( field : string , prompt : string | string [ ] , options ?: IFieldOptions ) : IDialogWaterfallStep ;
1427
+
1428
+ /**
1429
+ * Prompts the user to choose from a list of options and saves their selection to a field on a form.
1430
+ * @param field Name of the field to save the users response to.
1431
+ * @param prompt
1432
+ * * __prompt:__ _{string}_ - Initial message to send the user.
1433
+ * * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1434
+ * @param choices
1435
+ * * __choices:__ _{string}_ - List of choices as a pipe ('|') delimted string.
1436
+ * * __choices:__ _{Object}_ - List of choices expressed as an Object map. The objects field names will be used to build the list of values.
1437
+ * * __choices:__ _{string[]}_ - List of choices as an array of strings.
1438
+ * @param options Optional parameters to control the behaviour of the field.
1439
+ */
1440
+ static choice ( field : string , prompt : string | string [ ] , choices : string | Object | string [ ] , options ?: IFieldOptions ) : IDialogWaterfallStep ;
1441
+
1442
+ /**
1443
+ * Prompts the user to enter a time saves it to a field on a form as a timestamp.
1444
+ * @param field Name of the field to save the users response to.
1445
+ * @param prompt
1446
+ * * __prompt:__ _{string}_ - Initial message to send the user.
1447
+ * * __prompt:__ _{string[]}_ - Array of possible messages to send user. One will be chosen at random.
1448
+ * @param options Optional parameters to control the behaviour of the field.
1449
+ */
1450
+ static time ( field : string , prompt : string | string [ ] , options ?: IPromptOptions ) : IDialogWaterfallStep ;
1451
+
1452
+ /**
1453
+ * Finalizes the form by saving the response from the last prompt and then passes the completed
1454
+ * form to the next step of the waterfall for processing.
1455
+ */
1456
+ static endForm ( ) : IDialogWaterfallStep ;
1457
+
1458
+ /**
1459
+ * Finalizes the form by saving the response from the last prompt and then returns the completed
1460
+ * form to the parent dialog by calling [endDialog()](http://docs.botframework.com/sdkreference/nodejs/classes/_botbuilder_d_.session.html#enddialog).
1461
+ */
1462
+ static returnForm ( ) : IDialogWaterfallStep ;
1463
+
1464
+ /**
1465
+ * Handler for IFieldOptions.onPrompt that will copy a default value from Session.userData if
1466
+ * a field is empty. The default value must be in a property with the same name as the field.
1467
+ * If successfully copied the prompt will be skipped.
1468
+ */
1469
+ static onPromptUseDefault ( ) : IFieldPromptHandler
1470
+ }
1471
+
1363
1472
/**
1364
1473
* Implements a simple pattern based recognizer for parsing the built-in prompts. Derived classes can
1365
1474
* inherit from SimplePromptRecognizer and override the recognize() method to change the recognition
0 commit comments