@@ -407,8 +407,14 @@ export interface IRecognizeContext {
407
407
/** Private conversation data that's only visible to the user. */
408
408
privateConversationData : any ;
409
409
410
+ /** Data for the active dialog. */
411
+ dialogData : any ;
412
+
410
413
/** The localizer for the session. */
411
- localizer : ILocalizer ;
414
+ localizer : ILocalizer ;
415
+
416
+ /** The current session logger. */
417
+ logger : SessionLogger ;
412
418
413
419
/** Returns the users preferred locale. */
414
420
preferredLocale ( ) : string ;
@@ -1071,6 +1077,11 @@ export interface IRouteResult {
1071
1077
routeData ?: any ;
1072
1078
}
1073
1079
1080
+ /** Function for retrieving the value of a watched variable. Passed to [Session.watchable()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.session#watchable). */
1081
+ export interface IWatchableHandler {
1082
+ ( context : IRecognizeContext , callback : ( err : Error , value : any ) => void ) : void ;
1083
+ }
1084
+
1074
1085
/** Custom route searching logic passed to [Library.onFindRoutes()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.library#onfindroutes). */
1075
1086
export interface IFindRoutesHandler {
1076
1087
( context : IRecognizeContext , callback : ( err : Error , routes : IRouteResult [ ] ) => void ) : void ;
@@ -1528,8 +1539,92 @@ export class Session {
1528
1539
* @param root The root of the library hierarchy, typically the bot.
1529
1540
*/
1530
1541
static validateDialogStack ( stack : IDialogState [ ] , root : Library ) : boolean ;
1542
+
1543
+ /**
1544
+ * Enables/disables a watch for the current session.
1545
+ * @param variable Name of the variable to watch/unwatch.
1546
+ * @param enable (Optional) If true the variable will be watched, otherwise it will be unwatched. The default value is true.
1547
+ */
1548
+ watch ( variable : string , enable ?: boolean ) : Session ;
1549
+
1550
+ /**
1551
+ * Returns the current list of watched variables for the session.
1552
+ */
1553
+ watchList ( ) : string [ ] ;
1554
+
1555
+ /**
1556
+ * Adds or retrieves a variable that can be watched.
1557
+ * @param variable Name of the variable that can be watched. Case is used for display only.
1558
+ * @param handler (Optional) Function used to retrieve the variables current value. If specified a new handler will be registered, otherwise the existing handler will be retrieved.
1559
+ */
1560
+ static watchable ( variable : string , handler ?: IWatchableHandler ) : IWatchableHandler ;
1561
+
1562
+ /**
1563
+ * Returns a list of watchable variables.
1564
+ */
1565
+ static watchableList ( ) : string [ ] ;
1531
1566
}
1532
-
1567
+
1568
+ /**
1569
+ * Default session logger used to log session activity to the console.
1570
+ */
1571
+ export class SessionLogger {
1572
+ /** If true the logger is enabled and will log the sessions activity. */
1573
+ isEnabled : boolean ;
1574
+
1575
+ /**
1576
+ * Logs the state of a variable to the output.
1577
+ * @param name Name of the variable being logged.
1578
+ * @param value Variables current state.
1579
+ */
1580
+ dump ( name : string , value : any ) : void ;
1581
+
1582
+ /**
1583
+ * Logs an informational level message to the output.
1584
+ * @param dialogStack (Optional) dialog stack for the session. This is used to provide context for where the event occured.
1585
+ * @param msg Message to log.
1586
+ * @param args (Optional) arguments to log with the message.
1587
+ */
1588
+ log ( dialogStack : IDialogState [ ] , msg : string , ...args : any [ ] ) : void ;
1589
+
1590
+ /**
1591
+ * Logs a warning to the output.
1592
+ * @param dialogStack (Optional) dialog stack for the session. This is used to provide context for where the event occured.
1593
+ * @param msg Message to log.
1594
+ * @param args (Optional) arguments to log with the message.
1595
+ */
1596
+ warn ( dialogStack : IDialogState [ ] , msg : string , ...args : any [ ] ) : void ;
1597
+
1598
+ /**
1599
+ * Logs an error to the output.
1600
+ * @param dialogStack (Optional) dialog stack for the session. This is used to provide context for where the event occured.
1601
+ * @param err Error object to log. The errors message plus stack trace will be logged.
1602
+ */
1603
+ error ( dialogStack : IDialogState [ ] , err : Error ) : void ;
1604
+
1605
+ /**
1606
+ * Flushes any buffered entries to the output.
1607
+ * @param callback Function to call when the operation is completed.
1608
+ */
1609
+ flush ( callback : ( err : Error ) => void ) : void ;
1610
+ }
1611
+
1612
+ /**
1613
+ * Logs session activity to a remote endpoint using debug events. The remote debugger
1614
+ * is automatically used when the emulator connects to your bot. Non-emulator channels
1615
+ * can stream their activity to the emulator by saving the address of the emulator
1616
+ * session to `session.privateConversationData["BotBuilder.Data.DebugSession"]`.
1617
+ */
1618
+ export class RemoteSessionLogger extends SessionLogger {
1619
+ /**
1620
+ * Creates an instance of the remote session logger.
1621
+ * @param connector Connector used to communicate with the remote endpoint.
1622
+ * @param address Address to deliver debug events to.
1623
+ * @param relatesTo Address of the conversation the debug events are for.
1624
+ */
1625
+ constructor ( connector : IConnector , address : IAddress , relatesTo : IAddress ) ;
1626
+ }
1627
+
1533
1628
/**
1534
1629
* Message builder class that simplifies building complex messages with attachments.
1535
1630
*/
0 commit comments