-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
botbuilder.d.ts
4470 lines (3710 loc) · 216 KB
/
botbuilder.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//=============================================================================
//
// TYPES
//
//=============================================================================
/**
* Text based prompts that can be sent to a user.
* * _{string}_ - A simple message to send the user.
* * _{string[]}_ - Array of possible messages to send the user. One will be chosen at random.
*/
export type TextType = string | string[];
/**
* Message based prompts that can be sent to a user.
* * _{IMessage}_ - Message to send the user expressed using JSON. The message can contain attachments and suggested actions. Not all channels natively support all message properties but most channels will down render unsupported fields.
* * _{IIsMessage}_ - An instance of the [Message](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.message.html) builder class. This class helps to localize your messages and provides helpers to aid with formatting the text portions of your message.
*/
export type MessageType = IMessage | IIsMessage;
/**
* Flexible range of possible prompts that can be sent to a user.
* * _{string}_ - A simple message to send the user.
* * _{string[]}_ - Array of possible messages to send the user. One will be chosen at random.
* * _{IMessage}_ - Message to send the user expressed using JSON. The message can contain attachments and suggested actions. Not all channels natively support all message properties but most channels will down render unsupported fields.
* * _{IIsMessage}_ - An instance of the [Message](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.message.html) builder class. This class helps to localize your messages and provides helpers to aid with formatting the text portions of your message.
*/
export type TextOrMessageType = string | string[] | IMessage | IIsMessage;
/**
* Some methods can take either an `IAttachment` in JSON form or one the various card builder classes
* that implement `IIsAttachment`.
*/
export type AttachmentType = IAttachment | IIsAttachment;
/**
* Supported rules for matching a users utterance.
* * _{RegExp}_ - A regular expression will be used to match the users utterance.
* * _{string}_ - A named intent returned from a recognizer will be used to match the users utterance.
* * _{(RegExp|string)[]}_ - An array of either regular expressions or named intents can be passed to match the users utterance in a number of possible ways. The rule generating the highest score (best match) will be used for scoring purposes.
*/
export type MatchType = RegExp | string | (RegExp | string)[];
/**
* List of text values. The values can be expressed as a pipe delimited string like "value1|value2|value3"
* or simple array of values.
*/
export type ValueListType = string | string[];
//=============================================================================
//
// INTERFACES
//
//=============================================================================
/**
* An event received from or being sent to a source.
* @example
* <pre><code>
* session.send({ type: 'typing' });
* </code></pre>
*/
export interface IEvent {
/** Defines type of event. Should be 'message' for an IMessage. */
type: string;
/** SDK thats processing the event. Will always be 'botbuilder'. */
agent: string;
/** The original source of the event (i.e. 'facebook', 'skype', 'slack', etc.) */
source: string;
/** The original event in the sources native schema. For outgoing messages can be used to pass source specific event data like custom attachments. */
sourceEvent: any;
/** Address routing information for the event. Save this field to external storage somewhere to later compose a proactive message to the user. */
address: IAddress;
/**
* For incoming messages this is the user that sent the message. By default this is a copy of [address.user](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.iaddress.html#user) but you can configure your bot with a
* [lookupUser](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.iuniversalbotsettings.html#lookupuser) function that lets map the incoming user to an internal user id.
*/
user: IIdentity;
/** The ID of the event this update is related to. */
replyToId?: string;
}
/**
* The Properties of a conversation have changed.
* @example
* <pre><code>
* bot.on('conversationUpdate', function (update) {
* // ... process update ...
* });
* </code></pre>
*/
export interface IConversationUpdate extends IEvent {
/** Array of members added to the conversation. */
membersAdded?: IIdentity[];
/** Array of members removed from the conversation. */
membersRemoved?: IIdentity[];
/** Array of reactions added to an activity. */
reactionsAdded?: IMessageReaction[];
/** Array of reactions removed from an activity. */
reactionsRemoved?: IMessageReaction[];
/** The conversations new topic name. */
topicName?: string;
/** If true then history was disclosed. */
historyDisclosed?: boolean;
}
/**
* The Properties of a message have changed.
* @example
* <pre><code>
* bot.on('messageReaction', function (update) {
* // ... process update ...
* });
* </code></pre>
*/
export interface IMessageUpdate extends IEvent {
/** Array of reactions added to an activity. */
reactionsAdded?: IMessageReaction[];
/** Array of reactions removed from an activity. */
reactionsRemoved?: IMessageReaction[];
}
/** Message reaction object. */
export interface IMessageReaction {
/** Message reaction type. */
type: string;
}
/**
* A user has updated their contact list.
/**
* A user has updated their contact list.
* @example
* <pre><code>
* bot.on('contactRelationUpdate', function (update) {
* // ... process update ...
* });
* </code></pre>
*/
export interface IContactRelationUpdate extends IEvent {
/** The action taken. Valid values are "add" or "remove". */
action: string;
}
/**
* A chat message sent between a User and a Bot. Messages from the bot to the user come in two flavors:
*
* * __reactive messages__ are messages sent from the Bot to the User as a reply to an incoming message from the user.
* * __proactive messages__ are messages sent from the Bot to the User in response to some external event like an alarm triggering.
*
* In the reactive case the you should copy the [address](#address) field from the incoming message to the outgoing message (if you use the [Message]( /en-us/node/builder/chat-reference/classes/_botbuilder_d_.message.html) builder class and initialize it with the
* [session](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.session.html) this will happen automatically) and then set the [text](#text) or [attachments](#attachments). For proactive messages you’ll need save the [address](#address) from the incoming message to
* an external storage somewhere. You can then later pass this in to [UniversalBot.beginDialog()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.universalbot.html#begindialog) or copy it to an outgoing message passed to
* [UniversalBot.send()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.universalbot.html#send).
*
* Composing a message to the user using the incoming address object will by default send a reply to the user in the context of the current conversation. Some channels allow for the starting of new conversations with the user. To start a new proactive conversation with the user simply delete
* the [conversation](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.iaddress.html#conversation) field from the address object before composing the outgoing message.
* @example
* <pre><code>
* session.send({
* type: 'message',
* text: "Hello World!"
* });
* </code></pre>
*/
export interface IMessage extends IEvent {
/** UTC Time when message was sent (set by service.) */
timestamp?: string;
/** Local time when message was sent (set by client or bot, Ex: 2016-09-23T13:07:49.4714686-07:00.) */
localTimestamp?: string;
/** Text to be displayed by as fall-back and as short description of the message content in e.g. list of recent conversations. */
summary?: string;
/** Spoken message as [Speech Synthesis Markup Language](https://msdn.microsoft.com/en-us/library/hh378377(v=office.14).aspx). */
speak?: string;
/** Message text. */
text?: string;
/** Identified language of the message text if known. */
textLocale?: string;
/** For incoming messages contains attachments like images sent from the user. For outgoing messages contains objects like cards or images to send to the user. */
attachments?: IAttachment[];
/** Structured objects passed to the bot or user. */
entities?: any[];
/** Format of text fields. The default value is 'markdown'. */
textFormat?: string;
/** Hint for how clients should layout multiple attachments. The default value is 'list'. */
attachmentLayout?: string;
/** Hint for clients letting them know if the bot is expecting further input or not. The built-in prompts will automatically populate this value for outgoing messages. */
inputHint?: string;
/** Open-ended value. */
value?: any;
/** Name of the operation to invoke or the name of the event. */
name?: string;
/** Reference to another conversation or message. */
relatesTo?: IAddress;
/** Code indicating why the conversation has ended. */
code?: string;
}
/**
* Implemented by classes that can be converted into an IMessage, like the [Message](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.message) builder class.
* @example
* <pre><code>
* var msg = new builder.Message(session)
* .text("Hello World!");
* session.send(msg);
* </code></pre>
*/
export interface IIsMessage {
/** Returns the JSON object for the message. */
toMessage(): IMessage;
}
/**
* Optional message properties that can be sent to things like prompts or [session.say()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.session#say).
* @example
* <pre><code>
* session.say("Please wait...", "<speak>Please wait</speak>", {
* inputHint: builder.InputHint.ignoringInput
* });
* </code></pre>
*/
export interface IMessageOptions {
/** For incoming messages contains attachments like images sent from the user. For outgoing messages contains objects like cards or images to send to the user. */
attachments?: IAttachment[];
/** Structured objects passed to the bot or user. */
entities?: any[];
/** Format of text fields. The default value is 'markdown'. */
textFormat?: string;
/** Hint for how clients should layout multiple attachments. The default value is 'list'. */
attachmentLayout?: string;
/** Hint for clients letting them know if the bot is expecting further input or not. The built-in prompts will automatically populate this value for outgoing messages. */
inputHint?: string;
}
/** Represents a user, bot, or conversation. */
export interface IIdentity {
/** Channel specific ID for this identity. */
id: string;
/** Friendly name for this identity. */
name?: string;
/** If true the identity is a group. Typically only found on conversation identities. */
isGroup?: boolean;
/** Indicates the type of the conversation in channels that distinguish. */
conversationType?: string;
}
/** List of members within a conversation. */
export interface IConversationMembers {
/** Conversation ID. */
id: string;
/** List of members in this conversation. */
members: IIdentity[];
}
/** Result object returned from `ChatConnector.getConversations()`. */
export interface IConversationsResult {
/** Paging token. */
continuationToken: string;
/** List of conversations. */
conversations: IConversationMembers[];
}
/** Result object returned from `ChatConnector.getConversationPagedMembers()`. */
export interface IPagedMembersResult {
/** Paging token. */
continuationToken: string;
/** List of members in this conversation. */
members: IIdentity[];
}
/**
* An interface representing TokenResponse.
* A response that includes a user token
*
*/
export interface ITokenResponse {
/**
* The connection name
*/
connectionName: string;
/**
* The user token
*/
token: string;
/**
* Expiration for the token, in ISO 8601 format
* (e.g. "2007-04-05T14:30Z")
*/
expiration: string;
}
/** Exported bot state data. */
export interface IBotStateData {
/** ID of the conversation the data is for (if relevant.) */
conversationId?: string;
/** ID of the user the data is for (if relevant.) */
userId?: string;
/** Exported data. */
data: string;
/** Timestamp of when the data was last modified. */
lastModified: string;
}
/** Result object returned from `ChatConnector.exportBotStateData()`. */
export interface IBotStateDataResult {
/** Paging token. */
continuationToken: string;
/** Exported bot state records. */
botStateData: IBotStateData[];
}
/**
* Address routing information for an [event](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ievent.html#address).
* Addresses are bidirectional meaning they can be used to address both incoming and outgoing events.
* They're also connector specific meaning that [connectors](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.iconnector.html)
* are free to add their own fields to the address.
*
* To send a __proactive message__ to a user bots should save the address from a received [message](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.imessage).
* Depending on the channel addresses can change, so bots should periodically update the address stored for a given
* user.
*/
export interface IAddress {
/** Unique identifier for channel. */
channelId: string;
/** User that sent or should receive the message. */
user: IIdentity;
/** Bot that either received or is sending the message. */
bot: IIdentity;
/**
* Represents the current conversation and tracks where replies should be routed to.
* Can be deleted to start a new conversation with a [user](#user) on channels that support new conversations.
*/
conversation?: IIdentity;
}
/** [ChatConnector](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.chatconnector) specific address. */
export interface IChatConnectorAddress extends IAddress {
/** Incoming Message ID. */
id?: string;
/** Specifies the URL to post messages back. */
serviceUrl?: string;
}
/** Additional properties that can be passed in with the address to [UniversalBot.beginDialog()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.universalbot#begindialog). */
export interface IStartConversationAddress extends IChatConnectorAddress {
/** (Optional) when creating a new conversation, use this activity as the initial message to the conversation. */
activity?: any;
/** (Optional) channel specific payload for creating the conversation. */
channelData?: any;
/** (Optional) if true the conversation should be a group conversation. */
isGroup?: boolean;
/** (Optional) members to add to the conversation. If missing, the conversation will be started with the [user](#user). */
members?: IIdentity[];
/** (Optional) topic of the conversation (if supported by the channel) */
topicName?: string;
}
/**
* Many messaging channels provide the ability to attach richer objects. Bot Builder lets you express these attachments in a cross channel way and [connectors](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.iconnector.html) will do their best to render the
* attachments using the channels native constructs. If you desire more control over the channels rendering of a message you can use [IEvent.sourceEvent](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ievent.html#sourceevent) to provide attachments using
* the channels native schema. The types of attachments that can be sent varies by channel but these are the basic types:
*
* * __Media and Files:__ Basic files can be sent by setting [contentType](#contenttype) to the MIME type of the file and then passing a link to the file in [contentUrl](#contenturl).
* * __Cards:__ A rich set of visual cards can by setting [contentType](#contenttype) to the cards type and then passing the JSON for the card in [content](#content). If you use one of the rich card builder classes like
* [HeroCard](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.herocard.html) the attachment will automatically filled in for you.
*/
export interface IAttachment {
/** MIME type string which describes type of attachment. */
contentType: string;
/** (Optional) object structure of attachment. */
content?: any;
/** (Optional) reference to location of attachment content. */
contentUrl?: string;
/** (Optional) name of the attachment. */
name?: string;
/** (Optional) link to the attachments thumbnail. */
thumbnailUrl?: string;
}
/** Implemented by classes that can be converted into an attachment. */
export interface IIsAttachment {
/** Returns the JSON object for the attachment. */
toAttachment(): IAttachment;
}
/** Displays a signin card and button to the user. Some channels may choose to render this as a text prompt and link to click. */
export interface ISigninCard {
/** Title of the Card. */
title: string;
/** Sign in action. */
buttons: ICardAction[];
}
/**
* An interface representing OAuthCard.
* A card representing a request to peform a sign in via OAuth
*
*/
export interface IOAuthCard {
/**
* Text for signin request
*/
text: string;
/**
* The name of the registered connection
*/
connectionName: string;
/**
* Action to use to perform signin
*/
buttons: ICardAction[];
}
/**
* Displays a card to the user using either a smaller thumbnail layout or larger hero layout (the attachments [contentType](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.iattachment.html#contenttype) determines which).
* All of the cards fields are optional so this card can be used to specify things like a keyboard on certain channels. Some channels may choose to render a lower fidelity version of the card or use an alternate representation.
*/
export interface IThumbnailCard {
/** Title of the Card. */
title?: string;
/** Subtitle appears just below Title field, differs from Title in font styling only. */
subtitle?: string;
/** Text field appears just below subtitle, differs from Subtitle in font styling only. */
text?: string;
/** Messaging supports all media formats: audio, video, images and thumbnails as well to optimize content download. */
images?: ICardImage[];
/** This action will be activated when user taps on the card. Not all channels support tap actions and some channels may choose to render the tap action as the titles link. */
tap?: ICardAction;
/** Set of actions applicable to the current card. Not all channels support buttons or cards with buttons. Some channels may choose to render the buttons using a custom keyboard. */
buttons?: ICardAction[];
}
/** Displays a rich receipt to a user for something they've either bought or are planning to buy. */
export interface IReceiptCard {
/** Title of the Card. */
title: string;
/** Array of receipt items. */
items: IReceiptItem[];
/** Array of additional facts to display to user (shipping charges and such.) Not all facts will be displayed on all channels. */
facts: IFact[];
/** This action will be activated when user taps on the card. Not all channels support tap actions. */
tap: ICardAction;
/** Total amount of money paid (or should be paid.) */
total: string;
/** Total amount of TAX paid (or should be paid.) */
tax: string;
/** Total amount of VAT paid (or should be paid.) */
vat: string;
/** Set of actions applicable to the current card. Not all channels support buttons and the number of allowed buttons varies by channel. */
buttons: ICardAction[];
}
/** An individual item within a [receipt](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ireceiptcard.html). */
export interface IReceiptItem {
/** Title of the item. */
title: string;
/** Subtitle appears just below Title field, differs from Title in font styling only. On some channels may be combined with the [title](#title) or [text](#text). */
subtitle: string;
/** Text field appears just below subtitle, differs from Subtitle in font styling only. */
text: string;
/** Image to display on the card. Some channels may either send the image as a separate message or simply include a link to the image. */
image: ICardImage;
/** Amount with currency. */
price: string;
/** Number of items of given kind. */
quantity: string;
/** This action will be activated when user taps on the Item bubble. Not all channels support tap actions. */
tap: ICardAction;
}
/** Implemented by classes that can be converted into a receipt item. */
export interface IIsReceiptItem {
/** Returns the JSON object for the receipt item. */
toItem(): IReceiptItem;
}
/** The action that should be performed when a card, button, or image is tapped. */
export interface ICardAction {
/** Defines the type of action implemented by this button. Not all action types are supported by all channels. */
type: string;
/** Text description for button actions. */
title?: string;
/** Parameter for Action. Content of this property depends on Action type. */
value: string;
/** (Optional) Picture to display for button actions. Not all channels support button images. */
image?: string;
/** (Optional) Text for this action. */
text?: string;
/** (Optional) text to display in the chat feed if the button is clicked. */
displayText?: string;
}
/** Implemented by classes that can be converted into a card action. */
export interface IIsCardAction {
/** Returns the JSON object for the card attachment. */
toAction(): ICardAction;
}
/** Suggested actions to send to the user and displayed as quick replies. Suggested actions will be displayed only on the channels that support suggested actions. */
export interface ISuggestedActions {
/** Optional recipients of the suggested actions. Not supported in all channels. */
to?: string[];
/** Quick reply actions that can be suggested as part of the message. */
actions: ICardAction[];
}
/** Implemented by classes that can be converted into suggested actions */
export interface IIsSuggestedActions {
/** Returns the JSON object for the suggested actions */
toSuggestedActions(): ISuggestedActions;
}
/** An image on a card. */
export interface ICardImage {
/** Thumbnail image for major content property. */
url: string;
/** Image description intended for screen readers. Not all channels will support alt text. */
alt: string;
/** Action assigned to specific Attachment. E.g. navigate to specific URL or play/open media content. Not all channels will support tap actions. */
tap: ICardAction;
}
/** Implemented by classes that can be converted into a card image. */
export interface IIsCardImage {
/** Returns the JSON object for the card image. */
toImage(): ICardImage;
}
/** A fact displayed on a card like a [receipt](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.ireceiptcard.html). */
export interface IFact {
/** Display name of the fact. */
key: string;
/** Display value of the fact. */
value: string;
}
/** Implemented by classes that can be converted into a fact. */
export interface IIsFact {
/** Returns the JSON object for the fact. */
toFact(): IFact;
}
/** Settings used to initialize an ILocalizer implementation. */
interface IDefaultLocalizerSettings {
/** The path to the parent of the bots locale directory */
botLocalePath?: string;
/** The default locale of the bot */
defaultLocale?: string;
}
/** Plugin for localizing messages sent to the user by a bot. */
export interface ILocalizer {
/**
* Loads the localized table for the supplied locale, and call's the supplied callback once the load is complete.
* @param locale The locale to load.
* @param callback callback that is called once the supplied locale has been loaded, or an error if the load fails.
*/
load(locale: string, callback: (err: Error) => void): void;
/**
* Loads a localized string for the specified language.
* @param locale Desired locale of the string to return.
* @param msgid String to use as a key in the localized string table. Typically this will just be the english version of the string.
* @param namespace (Optional) namespace for the msgid keys.
*/
trygettext(locale: string, msgid: string, namespace?: string): string;
/**
* Loads a localized string for the specified language.
* @param locale Desired locale of the string to return.
* @param msgid String to use as a key in the localized string table. Typically this will just be the english version of the string.
* @param namespace (Optional) namespace for the msgid keys.
*/
gettext(locale: string, msgid: string, namespace?: string): string;
/**
* Loads the plural form of a localized string for the specified language.
* @param locale Desired locale of the string to return.
* @param msgid Singular form of the string to use as a key in the localized string table.
* @param msgid_plural Plural form of the string to use as a key in the localized string table.
* @param count Count to use when determining whether the singular or plural form of the string should be used.
* @param namespace (Optional) namespace for the msgid and msgid_plural keys.
*/
ngettext(locale: string, msgid: string, msgid_plural: string, count: number, namespace?: string): string;
}
/** Persisted session state used to track a conversations dialog stack. */
export interface ISessionState {
/** Dialog stack for the current session. */
callstack: IDialogState[];
/** Timestamp of when the session was last accessed. */
lastAccess: number;
/** Version number of the current callstack. */
version: number;
}
/** An entry on the sessions dialog stack. */
export interface IDialogState {
/** ID of the dialog. */
id: string;
/** Persisted state for the dialog. */
state: any;
}
/**
* Results returned by a child dialog to its parent via a call to session.endDialog().
*/
export interface IDialogResult<T> {
/** The reason why the current dialog is being resumed. Defaults to [ResumeReason.completed](/en-us/node/builder/chat-reference/enums/_botbuilder_d_.resumereason#completed). */
resumed?: ResumeReason;
/** ID of the child dialog thats ending. */
childId?: string;
/** If an error occurred the child dialog can return the error to the parent. */
error?: Error;
/** The users response. */
response?: T;
}
/** Context of the received message passed to various recognition methods. */
export interface IRecognizeContext {
/** The message received from the user. For bot originated messages this may only contain the "to" & "from" fields. */
message: IMessage;
/** Data for the user that's persisted across all conversations with the bot. */
userData: any;
/** Shared conversation data that's visible to all members of the conversation. */
conversationData: any;
/** Private conversation data that's only visible to the user. */
privateConversationData: any;
/** Data for the active dialog. */
dialogData: any;
/** The localizer for the session. */
localizer: ILocalizer;
/** The current session logger. */
logger: SessionLogger;
/** Returns the users preferred locale. */
preferredLocale(): string;
/**
* Loads a localized string for the messages language. If arguments are passed the localized string
* will be treated as a template and formatted using [sprintf-js](https://github.com/alexei/sprintf.js) (see their docs for details.)
* @param msgid String to use as a key in the localized string table. Typically this will just be the english version of the string.
* @param args (Optional) arguments used to format the final output string.
*/
gettext(msgid: string, ...args: any[]): string;
/**
* Loads the plural form of a localized string for the messages language. The output string will be formatted to
* include the count by replacing %d in the string with the count.
* @param msgid Singular form of the string to use as a key in the localized string table. Use %d to specify where the count should go.
* @param msgid_plural Plural form of the string to use as a key in the localized string table. Use %d to specify where the count should go.
* @param count Count to use when determining whether the singular or plural form of the string should be used.
*/
ngettext(msgid: string, msgid_plural: string, count: number): string;
/** Returns a copy of the current dialog stack for the session. */
dialogStack(): IDialogState[];
/** (Optional) The top intent identified for the message. */
intent?: IIntentRecognizerResult;
/** (Optional) The name of the library passing the context is from. */
libraryName?: string;
/** __DEPRECATED__ use [preferredLocale()](#preferredlocale) instead. */
locale: string;
}
/** Context passed to `Dialog.recognize()`. */
export interface IRecognizeDialogContext extends IRecognizeContext {
/** If true the Dialog is the active dialog on the dialog stack. */
activeDialog: boolean;
/** Data persisted for the current dialog . */
dialogData: any;
}
/** Context passed to `ActionSet.findActionRoutes()`. */
export interface IFindActionRouteContext extends IRecognizeContext {
/** The type of route being searched for. */
routeType: string;
}
/** Options passed when defining a dialog action. */
export interface IDialogActionOptions {
/**
* (Optional) intent(s) used to trigger the action. Either a regular expression or a named
* intent can be provided and multiple intents can be specified. When a named intent is
* provided the action will be matched using the recognizers assigned to the library/bot using
* [Library.recognizer()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.library#recognizer).
*
* If a matches option isn't provided then the action can only be matched if an [onFindAction](#onfindaction)
* handler is provided.
*/
matches?: MatchType;
/** (Optional) minimum score needed to trigger the action using the value of [matches](#matches). The default value is 0.1. */
intentThreshold?: number;
/**
* (Optional) custom handler that's invoked whenever the action is being checked to see if it
* should be triggered. The handler is passed a context object containing the received message
* and any intents detected. The handler should return a confidence score for 0.0 to 1.0 and
* routeData that should be passed in during the `selectActionRoute` call.
*/
onFindAction?: (context: IFindActionRouteContext, callback: (err: Error, score: number, routeData?: IActionRouteData) => void) => void;
/**
* (Optional) custom handler that's invoked whenever the action is triggered. This lets you
* customize the behavior of an action. For instance you could clear the dialog stack before
* the new dialog is started, changing the default behavior which is to just push the new
* dialog onto the end of the stack.
*
* It's important to note that this is not a waterfall and you should call `next()` if you
* would like the actions default behavior to run.
*/
onSelectAction?: (session: Session, args?: IActionRouteData, next?: Function) => void;
}
/** Options passed when defining a `beginDialogAction()`. */
export interface IBeginDialogActionOptions extends IDialogActionOptions {
/** (Optional) arguments to pass to the dialog spawned when the action is triggered. */
dialogArgs?: any;
}
/** Options passed when defining a `triggerAction()`. */
export interface ITriggerActionOptions extends IBeginDialogActionOptions {
/**
* If specified the user will be asked to confirm that they are ok canceling the current
* uncompleted task.
*/
confirmPrompt?: TextOrMessageType;
/**
* (Optional) custom handler called when a root dialog is being interrupted by another root
* dialog. This gives the dialog an opportunity to perform custom cleanup logic or to prompt
* the user to confirm the interruption was intended.
*
* It's important to note that this is not a waterfall and you should call `next()` if you
* would like the actions default behavior to run.
*/
onInterrupted?: (session: Session, dialogId: string, dialogArgs?: any, next?: Function) => void;
}
/** Options passed when defining a `cancelAction()`. */
export interface ICancelActionOptions extends IDialogActionOptions {
/**
* If specified the user will be asked to confirm that they truly would like to cancel an
* action when triggered.
*/
confirmPrompt?: TextOrMessageType;
}
/** Arguments passed to a triggered action. */
export interface IActionRouteData {
/** Named dialog action that was matched. */
action?: string;
/** Intent that triggered the action. */
intent?: IIntentRecognizerResult;
/** Optional data passed as part of the action binding. */
data?: string;
/** ID of the dialog the action is bound to. */
dialogId?: string;
/** Index on the dialog stack of the dialog the action is bound to. */
dialogIndex?: number;
}
/**
* A choice that can be passed to [Prompts.choice()](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.__global.iprompts#choice)
* or [PromptRecognizers.recognizeChoices()][/en-us/node/builder/chat-reference/classes/_botbuilder_d_.promptrecognizers#recognizechoices].
*/
export interface IChoice {
/** Value to return when selected. */
value: string;
/** (Optional) action to use when rendering the choice as a suggested action. */
action?: ICardAction;
/** (Optional) list of synonyms to recognize in addition to the value. */
synonyms?: ValueListType;
}
/** Options passed to [PromptRecognizers.recognizeNumbers()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.promptrecognizers#recognizenumbers). */
export interface IPromptRecognizeNumbersOptions {
/** (Optional) minimum value allowed. */
minValue?: number;
/** (Optional) maximum value allowed. */
maxValue?: number;
/** (Optional) if true, then only integers will be recognized. */
integerOnly?: boolean;
}
/** Options passed to [PromptRecognizers.recognizeTimes()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.promptrecognizers#recognizetimes). */
export interface IPromptRecognizeTimesOptions {
/** (Optional) Reference date for relative times. */
refDate?: number;
}
/** Options passed to [PromptRecognizers.recognizeValues()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.promptrecognizers#recognizevalues). */
export interface IPromptRecognizeValuesOptions {
/**
* (Optional) if true, then only some of the tokens in a value need to exist to be considered
* a match. The default value is "false".
*/
allowPartialMatches?: boolean;
/**
* (Optional) maximum tokens allowed between two matched tokens in the utterance. So with
* a max distance of 2 the value "second last" would match the utterance "second from the last"
* but it wouldn't match "Wait a second. That's not the last one is it?".
* The default value is "2".
*/
maxTokenDistance?: number;
}
/** Options passed to [PromptRecognizers.recognizeChoices()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.promptrecognizers#recognizechoices). */
export interface IPromptRecognizeChoicesOptions extends IPromptRecognizeValuesOptions {
/** (Optional) If true, the choices value will NOT be recognized over. */
excludeValue?: boolean;
/** (Optional) If true, the choices action will NOT be recognized over. */
excludeAction?: boolean;
}
/** Options passed to the [built-in prompts](/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.__global.iprompts). */
export interface IPromptOptions extends IMessageOptions {
/**
* (Optional) Initial prompt to send the user. This is typically populated by the `Prompts.xxx()` function.
*/
prompt?: TextOrMessageType;
/** (Optional) SSML to send with the initial `prompt`. If the prompt is of type `IMessage` or `IIsMessage`, this value will be ignored. If this value is an array a response will be chosen at random. */
speak?: TextType;
/**
* (Optional) retry prompt to send if the users response isn't understood. Default is to just
* re-prompt with a customizable system prompt.
*/
retryPrompt?: TextOrMessageType;
/** (Optional) SSML to send with the `retryPrompt`. If the retryPrompt is of type `IMessage` or `IIsMessage`, this value will be ignored. If this value is an array a response will be chosen at random. */
retrySpeak?: TextType;
/** (Optional) maximum number of times to re-prompt the user. By default the user will be re-prompted indefinitely. */
maxRetries?: number;
/** (Optional) flag used to control the re-prompting of a user after a dialog started by an action ends. The default value is true. */
promptAfterAction?: boolean;
/** (Optional) type of list to render for PromptType.choice. Default value is ListStyle.auto. */
listStyle?: ListStyle;
/** (Optional) reference date when recognizing times. Date expressed in ticks using Date.getTime(). */
refDate?: number;
/** (Optional) namespace to use for localization and other purposes. This defaults to the callers namespace. */
libraryNamespace?: string;
/** __DEPRECATED__ use [libraryNamespace](#librarynamespace) instead. */
localizationNamespace?: string;
}
/**
* Contextual information tracked for a [Prompt](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.prompt). This information can be accessed
* within a prompt through [session.dialogData](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.session#dialogdata).
*/
export interface IPromptContext {
/** Options that the prompt was called with. */
options: IPromptOptions;
/**
* Number of times the user has interacted with the prompt. The first message sent to the user
* is turn-0, the users first reply is turn-1, and so forth.
*/
turns: number;
/** Timestamp of the last turn. */
lastTurn: number;
/**
* If true, we're returning from an unexpected interruption and should send the initial turn-0
* prompt again.
*/
isReprompt: boolean;
/**
* Used to track which [Prompt.matches()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.prompt#matches) handler is active. This is
* used internally to move the handlers waterfall to the next step.
*/
activeIntent: string;
}
/** Optional features that should be enabled/disabled when creating a custom [Prompt](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.prompt) */
export interface IPromptFeatures {
/** If true, then the prompt should not execute it's own recognition logic. The default is "false". */
disableRecognizer?: boolean;
/** The default retryPrompt to send should the caller not provide one. */