-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmessages.ts
More file actions
167 lines (139 loc) · 5.11 KB
/
Copy pathmessages.ts
File metadata and controls
167 lines (139 loc) · 5.11 KB
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
import type { ContactCard, Location, Reaction } from "./common.ts";
// ---------------------------------------------------------------------------
// Outbound content sub-types
// ---------------------------------------------------------------------------
export interface TextInput {
readonly body: string;
readonly previewUrl?: boolean;
}
export interface MediaInput {
readonly caption?: string;
readonly filename?: string;
readonly id?: string;
readonly link?: string;
readonly mimeType?: string;
}
export type StickerInput = Pick<MediaInput, "id" | "link">;
export type LocationInput = Location;
export type ReactionInput = Reaction;
// ---------------------------------------------------------------------------
// Interactive input (raw shape accepted by send)
// ---------------------------------------------------------------------------
export interface InteractiveInput {
readonly action?: InteractiveActionInput;
readonly body?: string;
readonly footer?: string;
readonly header?: InteractiveHeaderInput;
readonly type: string;
}
export interface InteractiveHeaderInput {
readonly document?: MediaInput;
readonly image?: MediaInput;
readonly text?: string;
readonly type: string;
readonly video?: MediaInput;
}
export interface InteractiveActionInput {
readonly button?: string;
readonly buttons?: readonly InteractiveButtonInput[];
readonly catalogId?: string;
readonly name?: string;
readonly parameters?: InteractiveFlowParametersInput;
readonly productRetailerId?: string;
readonly sections?: readonly InteractiveSectionInput[];
}
export interface InteractiveButtonInput {
readonly reply: { readonly id: string; readonly title: string };
readonly type: string;
}
export interface InteractiveSectionInput {
readonly productItems?: readonly { readonly productRetailerId: string }[];
readonly rows?: readonly InteractiveSectionRowInput[];
readonly title?: string;
}
export interface InteractiveSectionRowInput {
readonly description?: string;
readonly id: string;
readonly title: string;
}
export interface InteractiveFlowParametersInput {
readonly flowAction?: string;
readonly flowActionPayloadJson?: string;
readonly flowCta: string;
readonly flowId: string;
readonly flowMessageVersion: string;
readonly flowToken: string;
}
// ---------------------------------------------------------------------------
// Template input
// ---------------------------------------------------------------------------
export interface TemplateInput {
readonly components?: readonly TemplateComponentInput[];
readonly languageCode: string;
readonly name: string;
}
export interface TemplateComponentInput {
readonly cards?: readonly TemplateCardInput[];
readonly index?: number;
readonly parameters?: readonly TemplateParameterInput[];
readonly subType?: string;
readonly type: string;
}
export interface TemplateCardInput {
readonly cardIndex: number;
readonly components: readonly TemplateComponentInput[];
}
export interface TemplateParameterInput {
readonly actionJson?: string;
readonly couponCode?: string;
readonly document?: MediaInput;
readonly image?: MediaInput;
readonly location?: LocationInput;
readonly payload?: string;
readonly text?: string;
readonly type: string;
readonly video?: MediaInput;
}
// ---------------------------------------------------------------------------
// Contact card input (outbound)
// ---------------------------------------------------------------------------
export type ContactCardInput = ContactCard;
// ---------------------------------------------------------------------------
// Message content discriminated union
// ---------------------------------------------------------------------------
export type MessageContent =
| { readonly text: string | TextInput }
| { readonly image: MediaInput }
| { readonly video: MediaInput }
| { readonly audio: MediaInput }
| { readonly document: MediaInput }
| { readonly sticker: StickerInput }
| { readonly location: LocationInput }
| { readonly reaction: ReactionInput }
| { readonly interactive: InteractiveInput }
| { readonly template: TemplateInput }
| { readonly contacts: readonly ContactCardInput[] };
// ---------------------------------------------------------------------------
// Send message params & result
// ---------------------------------------------------------------------------
export type SendMessageParams = {
readonly to: string;
readonly replyTo?: string;
readonly bizOpaqueCallbackData?: string;
} & MessageContent;
export interface SendMessageResult {
readonly messageId: string;
readonly messageStatus: string;
}
// ---------------------------------------------------------------------------
// Mark read options
// ---------------------------------------------------------------------------
export interface MarkReadOptions {
/**
* Also display a typing indicator in the chat. Meta dismisses it after
* 25 seconds or when the business sends a message, whichever comes first —
* there is no explicit "stop typing" call. The message being marked read
* must be an inbound message.
*/
readonly typingIndicator?: boolean;
}