1 | import { Callback, Handler } from "../handler";
|
2 |
|
3 | export type LexHandler = Handler<LexEvent, LexResult>;
|
4 | export type LexCallback = Callback<LexResult>;
|
5 |
|
6 | export interface LexEventSlots {
|
7 | [name: string]: string | undefined | null;
|
8 | }
|
9 |
|
10 | export interface LexEventSessionAttributes {
|
11 | [key: string]: string | undefined;
|
12 | }
|
13 |
|
14 | export interface LexEventRequestAttributes {
|
15 | [key: string]: string | undefined;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 | export interface LexEvent {
|
21 | currentIntent: {
|
22 | name: string;
|
23 | slots: LexEventSlots;
|
24 | slotDetails: LexSlotDetails;
|
25 | confirmationStatus: "None" | "Confirmed" | "Denied";
|
26 | };
|
27 | bot: {
|
28 | name: string;
|
29 | alias: string;
|
30 | version: string;
|
31 | };
|
32 | userId: string;
|
33 | inputTranscript: string;
|
34 | invocationSource: "DialogCodeHook" | "FulfillmentCodeHook";
|
35 | outputDialogMode: "Text" | "Voice";
|
36 | messageVersion: "1.0";
|
37 | sessionAttributes: LexEventSessionAttributes;
|
38 | requestAttributes: LexEventRequestAttributes | null;
|
39 | }
|
40 |
|
41 | export interface LexSlotResolution {
|
42 | value: string;
|
43 | }
|
44 |
|
45 | export interface LexSlotDetail {
|
46 |
|
47 | resolutions: [LexSlotResolution, LexSlotResolution?, LexSlotResolution?, LexSlotResolution?, LexSlotResolution?];
|
48 | originalValue: string;
|
49 | }
|
50 |
|
51 | export interface LexSlotDetails {
|
52 | [name: string]: LexSlotDetail;
|
53 | }
|
54 |
|
55 | export interface LexGenericAttachment {
|
56 | title: string;
|
57 | subTitle: string;
|
58 | imageUrl: string;
|
59 | attachmentLinkUrl: string;
|
60 | buttons: Array<{
|
61 | text: string;
|
62 | value: string;
|
63 | }>;
|
64 | }
|
65 |
|
66 | export interface LexDialogActionBase {
|
67 | type: "Close" | "ElicitIntent" | "ElicitSlot" | "ConfirmIntent";
|
68 | message?:
|
69 | | {
|
70 | contentType: "PlainText" | "SSML" | "CustomPayload";
|
71 | content: string;
|
72 | }
|
73 | | undefined;
|
74 | responseCard?:
|
75 | | {
|
76 | version: number;
|
77 | contentType: "application/vnd.amazonaws.card.generic";
|
78 | genericAttachments: LexGenericAttachment[];
|
79 | }
|
80 | | undefined;
|
81 | }
|
82 |
|
83 | export interface LexDialogActionClose extends LexDialogActionBase {
|
84 | type: "Close";
|
85 | fulfillmentState: "Fulfilled" | "Failed";
|
86 | }
|
87 |
|
88 | export interface LexDialogActionElicitIntent extends LexDialogActionBase {
|
89 | type: "ElicitIntent";
|
90 | }
|
91 |
|
92 | export interface LexDialogActionElicitSlot extends LexDialogActionBase {
|
93 | type: "ElicitSlot";
|
94 | intentName: string;
|
95 | slots: { [name: string]: string | null };
|
96 | slotToElicit: string;
|
97 | }
|
98 |
|
99 | export interface LexDialogActionConfirmIntent extends LexDialogActionBase {
|
100 | type: "ConfirmIntent";
|
101 | intentName: string;
|
102 | slots: { [name: string]: string | null };
|
103 | }
|
104 |
|
105 | export interface LexDialogActionDelegate {
|
106 | type: "Delegate";
|
107 | slots: { [name: string]: string | null };
|
108 | }
|
109 |
|
110 | export type LexDialogAction =
|
111 | | LexDialogActionClose
|
112 | | LexDialogActionElicitIntent
|
113 | | LexDialogActionElicitSlot
|
114 | | LexDialogActionConfirmIntent
|
115 | | LexDialogActionDelegate;
|
116 |
|
117 | export interface LexResult {
|
118 | sessionAttributes?: { [key: string]: string } | undefined;
|
119 | dialogAction: LexDialogAction;
|
120 | }
|