types.ts
81.9 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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
import { AxiosRequestConfig } from "axios";
export interface Config {
channelAccessToken?: string;
channelSecret?: string;
}
export interface ClientConfig extends Config {
channelAccessToken: string;
httpConfig?: Partial<AxiosRequestConfig>;
}
export interface MiddlewareConfig extends Config {
channelSecret: string;
}
export type Profile = {
displayName: string;
userId: string;
pictureUrl: string;
statusMessage: string;
language?: string;
};
/**
* Request body which is sent by webhook.
*
* @see [Request body](https://developers.line.biz/en/reference/messaging-api/#request-body)
*/
export type WebhookRequestBody = {
/**
* User ID of a bot that should receive webhook events. The user ID value is a string that matches the regular expression, U[0-9a-f]{32}.
*/
destination: string;
/**
* Information about the event
*/
events: Array<WebhookEvent>;
};
/**
* JSON objects which contain events generated on the LINE Platform.
*
* @see [Webhook event objects](https://developers.line.biz/en/reference/messaging-api/#webhook-event-objects)
*/
export type WebhookEvent =
| MessageEvent
| UnsendEvent
| FollowEvent
| UnfollowEvent
| JoinEvent
| LeaveEvent
| MemberJoinEvent
| MemberLeaveEvent
| PostbackEvent
| VideoPlayCompleteEvent
| BeaconEvent
| AccountLinkEvent
| DeviceLinkEvent
| DeviceUnlinkEvent
| LINEThingsScenarioExecutionEvent;
export type EventBase = {
/**
* Channel state.
*
* `active`: The channel is active. You can send a reply message or push message from the bot server that received this webhook event.
*
* `standby`: The channel is waiting. The bot server that received this webhook event shouldn't send any messages.
*/
mode: "active" | "standby";
/**
* Time of the event in milliseconds
*/
timestamp: number;
/**
* Source user, group, or room object with information about the source of the event.
*/
source: EventSource;
};
export type EventSource = User | Group | Room;
export type User = { type: "user"; userId: string };
export type Group = {
type: "group";
groupId: string;
/**
* ID of the source user.
*
* Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
* Not included if the user has not agreed to the
* [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
*/
userId?: string;
};
export type Room = {
type: "room";
roomId: string;
/**
* ID of the source user.
*
* Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
* Not included if the user has not agreed to the
* [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
*/
userId?: string;
};
export type ReplyableEvent = EventBase & { replyToken: string };
/**
* Webhook event object which contains the sent message.
*
* The `message` property contains a message object which corresponds with the
* message type. You can reply to message events.
*
* @see [Message event](https://developers.line.biz/en/reference/messaging-api/#message-event)
*/
export type MessageEvent = {
type: "message";
message: EventMessage;
} & ReplyableEvent;
/**
* Event object for when the user unsends a message in a [group](https://developers.line.biz/en/docs/messaging-api/group-chats/#group)
* or [room](https://developers.line.biz/en/docs/messaging-api/group-chats/#room).
* [Unsend event](https://developers.line.biz/en/reference/messaging-api/#unsend-event)
*/
export type UnsendEvent = {
type: "unsend";
/**
* The message ID of the unsent message
*/
unsend: { messageId: string };
} & EventBase;
/**
* Event object for when your account is added as a friend (or unblocked).
*/
export type FollowEvent = { type: "follow" } & ReplyableEvent;
/**
* Event object for when your account is blocked.
*/
export type UnfollowEvent = { type: "unfollow" } & EventBase;
/**
* Event object for when your bot joins a group or room. You can reply to join events.
*
* A join event is triggered at different times for groups and rooms.
*
* - For groups: A join event is sent when a user invites your bot.
* - For rooms: A join event is sent when the first event (for example when a
* user sends a message or is added to the room) occurs after your bot is
* added.
*/
export type JoinEvent = { type: "join" } & ReplyableEvent;
/**
* Event object for when a user removes your bot from a group or a room.
*/
export type LeaveEvent = { type: "leave" } & EventBase;
/**
* Event object for when a user joins a [group](https://developers.line.biz/en/docs/messaging-api/group-chats/#group)
* or [room](https://developers.line.biz/en/docs/messaging-api/group-chats/#room) that the bot is in.
*/
export type MemberJoinEvent = {
type: "memberJoined";
/**
* User ID of users who joined
* Array of [source user](https://developers.line.biz/en/reference/messaging-api/#source-user) objects
*/
joined: { members: Array<User> };
} & ReplyableEvent;
/**
* Event object for when a user leaves a [group](https://developers.line.biz/en/docs/messaging-api/group-chats/#group)
* or [room](https://developers.line.biz/en/docs/messaging-api/group-chats/#room) that the bot is in.
*/
export type MemberLeaveEvent = {
type: "memberLeft";
/**
* User ID of users who left
* Array of [source user](https://developers.line.biz/en/reference/messaging-api/#source-user) objects
*/
left: { members: Array<User> };
} & EventBase;
/**
* Event object for when a user performs an action on a
* [template message](https://developers.line.biz/en/reference/messaging-api/#template-messages).
*/
export type PostbackEvent = {
type: "postback";
postback: Postback;
} & ReplyableEvent;
/**
* Event for when a user finishes viewing a video at least once with the specified trackingId sent by the LINE Official Account.
*/
export type VideoPlayCompleteEvent = {
type: "videoPlayComplete";
/**
* ID used to identify a video. Returns the same value as the trackingId assigned to the [video message](https://developers.line.biz/en/reference/messaging-api/#video-message).
* String
*/
videoPlayComplete: { trackingId: string };
} & ReplyableEvent;
/**
* Event object for when a user enters or leaves the range of a
* [LINE Beacon](https://developers.line.biz/en/docs/messaging-api/using-beacons/).
*/
export type BeaconEvent = ReplyableEvent & {
type: "beacon";
beacon: {
/**
* `leave` will be deprecated
*/
type: "enter" | "leave" | "banner" | "stay";
/**
* Hardware ID of the beacon that was detected
*/
hwid: string;
/**
* Device message of beacon that was detected.
*
* This message consists of data generated by the beacon to send notifications to bots.
* Only included in webhooks from devices that support the "device message" property.
* For more information, see the
* [LINE Simple Beacon specification](https://github.com/line/line-simple-beacon/blob/master/README.en.md/#line-simple-beacon-frame).
*/
dm?: string;
};
};
/**
* Event object for when a user has linked his/her LINE account with a provider's service account.
*/
export type AccountLinkEvent = ReplyableEvent & {
type: "accountLink";
link: {
result: "ok" | "failed";
/**
* Specified nonce when verifying the user ID
*/
nonce: string;
};
};
/**
* Indicates that a LINE Things-compatible device has been linked with LINE by a user operation.
* For more information, see [Receiving device link events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#link-event).
*/
export type DeviceLinkEvent = ReplyableEvent & {
type: "things";
things: {
/**
* Device ID of the LINE Things-compatible device that was linked with LINE
*/
deviceId: string;
type: "link";
};
};
/**
* Indicates that a LINE Things-compatible device has been unlinked from LINE by a user operation.
* For more information, see [Receiving device unlink events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#unlink-event).
*/
export type DeviceUnlinkEvent = ReplyableEvent & {
type: "things";
things: {
/**
* Device ID of the LINE Things-compatible device that was unlinked with LINE
*/
deviceId: string;
type: "unlink";
};
};
export type LINEThingsScenarioExecutionEvent = ReplyableEvent & {
type: "things";
things: {
type: "scenarioResult";
/**
* Device ID of the device that executed the scenario
*/
deviceId: string;
result: {
/**
* Scenario ID executed
*/
scenarioId: string;
/**
* Revision number of the scenario set containing the executed scenario
*/
revision: number;
/**
* Timestamp for when execution of scenario action started (milliseconds, LINE app time)
*/
startTime: number;
/**
* Timestamp for when execution of scenario was completed (milliseconds, LINE app time)
*/
endtime: number;
/**
* Scenario execution completion status
* See also [things.resultCode definitions](https://developers.line.biz/en/reference/messaging-api/#things-resultcode).
*/
resultCode: "success" | "gatt_error" | "runtime_error";
/**
* Execution result of individual operations specified in action
* Note that an array of actions specified in a scenario has the following characteristics
* - The actions defined in a scenario are performed sequentially, from top to bottom.
* - Each action produces some result when executed.
* Even actions that do not generate data, such as `SLEEP`, return an execution result of type `void`.
* The number of items in an action array may be 0.
*
* Therefore, things.actionResults has the following properties:
* - The number of items in the array matches the number of actions defined in the scenario.
* - The order of execution results matches the order in which actions are performed.
* That is, in a scenario set with multiple `GATT_READ` actions,
* the results are returned in the order in which each individual `GATT_READ` action was performed.
* - If 0 actions are defined in the scenario, the number of items in things.actionResults will be 0.
*/
actionResults: Array<LINEThingsActionResult>;
/**
* Data contained in notification
* The value is Base64-encoded binary data.
* Only included for scenarios where `trigger.type = BLE_NOTIFICATION`.
*/
bleNotificationPayload?: string;
/**
* Error reason
*/
errorReason?: string;
};
};
};
export type LINEThingsActionResult = {
/**
* `void`, `binary`
* Depends on `type` of the executed action.
* This property is always included if `things.actionResults` is not empty.
*/
type: "void" | "binary";
/**
* Base64-encoded binary data
* This property is always included when `things.actionResults[].type` is `binary`.
*/
data?: string;
};
export type EventMessage =
| TextEventMessage
| ImageEventMessage
| VideoEventMessage
| AudioEventMessage
| LocationEventMessage
| FileEventMessage
| StickerEventMessage;
export type EventMessageBase = { id: string };
/**
* Message object which contains the text sent from the source.
*/
export type TextEventMessage = {
type: "text";
text: string;
/**
* Sendable LINE emojis
*/
emojis?: {
index: number;
length: number;
productId: string;
emojiId: string;
}[];
/**
* Object containing the contents of the mentioned user.
*/
mention?: {
/**
* Mentioned user information.
* Max: 20 mentions
*/
mentionees: {
/**
* Index position of the user mention for a character in `text`,
* with the first character being at position 0.
*/
index: number;
/**
* The length of the text of the mentioned user. For a mention `@example`,
* 8 is the length.
*/
length: number;
userId: string;
}[];
};
} & EventMessageBase;
export type ContentProvider<WithPreview extends boolean = true> =
| {
/**
* The content is provided by LINE.
*
* The data itself can be retrieved from the content API.
*/
type: "line";
}
| {
/**
* The content is provided by a provider other than LINE
*/
type: "external";
/**
* URL of the content. Only included when contentProvider.type is external.
*/
originalContentUrl: string;
/**
* URL of the content preview. Only included when contentProvider.type is external.
*
* For contents without preview (e.g. audio), it's undefined.
*/
previewImageUrl: WithPreview extends true ? string : undefined;
};
/**
* Message object which contains the image content sent from the source.
* The binary image data can be retrieved using Client#getMessageContent.
*/
export type ImageEventMessage = {
type: "image";
contentProvider: ContentProvider;
} & EventMessageBase;
/**
* Message object which contains the video content sent from the source.
* The binary video data can be retrieved using Client#getMessageContent.
*/
export type VideoEventMessage = {
type: "video";
contentProvider: ContentProvider;
} & EventMessageBase;
/**
* Message object which contains the audio content sent from the source.
* The binary audio data can be retrieved using Client#getMessageContent.
*/
export type AudioEventMessage = {
type: "audio";
duration: number;
contentProvider: ContentProvider<false>;
} & EventMessageBase;
/**
* Message object which contains the file sent from the source.
* The binary data can be retrieved using Client#getMessageContent.
*/
export type FileEventMessage = {
type: "file";
fileName: string;
fileSize: string;
} & EventMessageBase;
/**
* Message object which contains the location data sent from the source.
*/
export type LocationEventMessage = {
type: "location";
title: string;
address: string;
latitude: number;
longitude: number;
} & EventMessageBase;
/**
* Message object which contains the sticker data sent from the source.
* For a list of basic LINE stickers and sticker IDs, see
* [sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
export type StickerEventMessage = {
type: "sticker";
packageId: string;
stickerId: string;
stickerResourceType:
| "STATIC"
| "ANIMATION"
| "SOUND"
| "ANIMATION_SOUND"
| "POPUP"
| "POPUP_SOUND"
| "NAME_TEXT"
| "PER_STICKER_TEXT";
keywords: string[];
} & EventMessageBase;
export type Postback = {
data: string;
/**
* Object with the date and time selected by a user through a
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
* Only returned for postback actions via a
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
* The `full-date`, `time-hour`, and `time-minute` formats follow the
* [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt).
*/
params?: {
/**
* Date selected by user. Only included in the `date` mode.
*/
date?: string;
/**
* Time selected by the user. Only included in the `time` mode.
*/
time?: string;
/**
* Date and time selected by the user. Only included in the `datetime` mode.
*/
datetime?: string;
};
};
/**
* JSON object which contains the contents of the message you send.
*
* @see [Message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects)
*/
export type Message =
| TextMessage
| ImageMessage
| VideoMessage
| AudioMessage
| LocationMessage
| StickerMessage
| ImageMapMessage
| TemplateMessage
| FlexMessage;
/**
* @see [Common properties for messages](https://developers.line.biz/en/reference/messaging-api/#common-properties-for-messages)
*/
export type MessageCommon = {
/**
* For the quick reply feature.
* For more information, see [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
*
* If the user receives multiple
* [message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects),
* the quickReply property of the last message object is displayed.
*/
quickReply?: QuickReply;
/**
* [Change icon and display name](https://developers.line.biz/en/docs/messaging-api/icon-nickname-switch/)
*
* When sending a message from the LINE Official Account, you can specify the `sender.name` and the `sender.iconUrl` properties in [Message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects).
*/
sender?: Sender;
};
/**
* @see [Text message](https://developers.line.biz/en/reference/messaging-api/#text-message)
*/
export type TextMessage = MessageCommon & {
type: "text";
/**
* Message text. You can include the following emoji:
*
* - Unicode emoji
* - LINE original emoji
* ([Unicode codepoint table for LINE original emoji](https://developers.line.biz/media/messaging-api/emoji-list.pdf))
*
* Max: 2000 characters
*/
text: string;
};
/**
* @see [Image message](https://developers.line.biz/en/reference/messaging-api/#image-message)
*/
export type ImageMessage = MessageCommon & {
type: "image";
/**
* Image URL (Max: 1000 characters)
*
* - **HTTPS**
* - JPEG
* - Max: 1024 x 1024
* - Max: 1 MB
*/
originalContentUrl: string;
/**
* Preview image URL (Max: 1000 characters)
*
* - **HTTPS**
* - JPEG
* - Max: 240 x 240
* - Max: 1 MB
*/
previewImageUrl: string;
};
/**
* @see [Video message](https://developers.line.biz/en/reference/messaging-api/#video-message)
*/
export type VideoMessage = MessageCommon & {
type: "video";
/**
* URL of video file (Max: 1000 characters)
*
* - **HTTPS**
* - mp4
* - Max: 1 minute
* - Max: 10 MB
*
* A very wide or tall video may be cropped when played in some environments.
*/
originalContentUrl: string;
/**
* URL of preview image (Max: 1000 characters)
*
* - **HTTPS**
* - JPEG
* - Max: 240 x 240
* - Max: 1 MB
*/
previewImageUrl: string;
};
/**
* @see [Audio message](https://developers.line.biz/en/reference/messaging-api/#audio-message)
*/
export type AudioMessage = MessageCommon & {
type: "audio";
/**
* URL of audio file (Max: 1000 characters)
*
* - **HTTPS**
* - m4a
* - Max: 1 minute
* - Max: 10 MB
*/
originalContentUrl: string;
/**
* Length of audio file (milliseconds)
*/
duration: number;
};
/**
* @see [Location message](https://developers.line.biz/en/reference/messaging-api/#location-message)
*/
export type LocationMessage = MessageCommon & {
type: "location";
/**
* Title (Max: 100 characters)
*/
title: string;
/**
* Address (Max: 100 characters)
*/
address: string;
latitude: number;
longitude: number;
};
/**
* @see [Sticker message](https://developers.line.biz/en/reference/messaging-api/#sticker-message)
*/
export type StickerMessage = MessageCommon & {
type: "sticker";
/**
* Package ID for a set of stickers.
* For information on package IDs, see the
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
packageId: string;
/**
* Sticker ID.
* For a list of sticker IDs for stickers that can be sent with the Messaging
* API, see the
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
stickerId: string;
};
/**
* @see [Imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)
*/
export type ImageMapMessage = MessageCommon & {
type: "imagemap";
/**
* [Base URL](https://developers.line.biz/en/reference/messaging-api/#base-url) of image
* (Max: 1000 characters, **HTTPS**)
*/
baseUrl: string;
/**
* Alternative text (Max: 400 characters)
*/
altText: string;
baseSize: Size;
/**
* Video to play inside a image map messages
*/
video?: {
/**
* URL of video file (Max: 1000 characters)
*
* - **HTTPS**
* - mp4
* - Max: 1 minute
* - Max: 10 MB
*
* A very wide or tall video may be cropped when played in some environments.
*/
originalContentUrl: string;
/**
* URL of preview image (Max: 1000 characters)
*
* - **HTTPS**
* - JPEG
* - Max: 240 x 240
* - Max: 1 MB
*/
previewImageUrl: string;
area: Area;
/**
* External link to be displayed after a video is played
* This property is required if you set a video to play and a label to display after the video on the imagemap
*/
externalLink?: {
linkUri: string;
label: string;
};
};
/**
* Action when tapped (Max: 50)
*/
actions: ImageMapAction[];
};
/**
* Template messages are messages with predefined layouts which you can
* customize. For more information, see
* [template messages](https://developers.line.biz/en/docs/messaging-api/message-types/#template-messages).
*
* The following template types are available:
*
* - [Buttons](https://developers.line.biz/en/reference/messaging-api/#buttons)
* - [Confirm](https://developers.line.biz/en/reference/messaging-api/#confirm)
* - [Carousel](https://developers.line.biz/en/reference/messaging-api/#carousel)
* - [Image carousel](https://developers.line.biz/en/reference/messaging-api/#image-carousel)
*
* @see [Template messages](https://developers.line.biz/en/reference/messaging-api/#template-messages)
*/
export type TemplateMessage = MessageCommon & {
type: "template";
/**
* Alternative text (Max: 400 characters)
*/
altText: string;
/**
* Carousel template content
*/
template: TemplateContent;
};
/**
* Flex Messages are messages with a customizable layout.
* You can customize the layout freely by combining multiple elements.
* For more information, see
* [Using Flex Messages](https://developers.line.biz/en/docs/messaging-api/using-flex-messages/).
*
* @see [Flex messages](https://developers.line.biz/en/reference/messaging-api/#flex-message)
*/
export type FlexMessage = MessageCommon & {
type: "flex";
altText: string;
contents: FlexContainer;
};
/**
* Object which specifies the actions and tappable regions of an imagemap.
*
* When a region is tapped, the user is redirected to the URI specified in
* `uri` and the message specified in `message` is sent.
*
* @see [Imagemap action objects](https://developers.line.biz/en/reference/messaging-api/#imagemap-action-objects)
*/
export type ImageMapAction = ImageMapURIAction | ImageMapMessageAction;
export type ImageMapActionBase = {
/**
* Spoken when the accessibility feature is enabled on the client device. (Max: 50 characters)
* Supported on LINE 8.2.0 and later for iOS.
*/
label?: string;
/** Defined tappable area */
area: Area;
};
export type ImageMapURIAction = {
type: "uri";
/**
* Webpage URL (Max: 1000 characters)
*/
linkUri: string;
} & ImageMapActionBase;
export type ImageMapMessageAction = {
type: "message";
/**
* Message to send (Max: 400 characters)
*/
text: string;
} & ImageMapActionBase;
export type Area = {
/**
* Horizontal position relative to the top-left corner of the area
*/
x: number;
/**
* Vertical position relative to the top-left corner of the area
*/
y: number;
/**
* Width of the tappable area
*/
width: number;
/**
* Height of the tappable area
*/
height: number;
};
/**
* A container is the top-level structure of a Flex Message. Here are the types of containers available.
*
* - [Bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
* - [Carousel](https://developers.line.biz/en/reference/messaging-api/#f-carousel)
*
* See [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
* for the containers' JSON data samples and usage.
*/
export type FlexContainer = FlexBubble | FlexCarousel;
/**
* This is a container that contains one message bubble. It can contain four
* blocks: header, hero, body, and footer.
*
* For more information about using each block, see
* [Block](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/#block).
*/
export type FlexBubble = {
type: "bubble";
size?: "nano" | "micro" | "kilo" | "mega" | "giga";
/**
* Text directionality and the order of components in horizontal boxes in the
* container. Specify one of the following values:
*
* - `ltr`: Left to right
* - `rtl`: Right to left
*
* The default value is `ltr`.
*/
direction?: "ltr" | "rtl";
header?: FlexBox;
hero?: FlexBox | FlexImage;
body?: FlexBox;
footer?: FlexBox;
styles?: FlexBubbleStyle;
action?: Action;
};
export type FlexBubbleStyle = {
header?: FlexBlockStyle;
hero?: FlexBlockStyle;
body?: FlexBlockStyle;
footer?: FlexBlockStyle;
};
export type FlexBlockStyle = {
/**
* Background color of the block. Use a hexadecimal color code.
*/
backgroundColor?: string;
/**
* - `true` to place a separator above the block.
* - `true` will be ignored for the first block in a container because you
* cannot place a separator above the first block.
* - The default value is `false`.
*/
separator?: boolean;
/**
* Color of the separator. Use a hexadecimal color code.
*/
separatorColor?: string;
};
export type FlexCarousel = {
type: "carousel";
/**
* (Max: 12 bubbles)
*/
contents: FlexBubble[];
};
/**
* Components are objects that compose a Flex Message container. Here are the
* types of components available:
*
* - [Box](https://developers.line.biz/en/reference/messaging-api/#box)
* - [Button](https://developers.line.biz/en/reference/messaging-api/#button)
* - [Image](https://developers.line.biz/en/reference/messaging-api/#f-image)
* - [Icon](https://developers.line.biz/en/reference/messaging-api/#icon)
* - [Text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* - [Span](https://developers.line.biz/en/reference/messaging-api/#span)
* - [Separator](https://developers.line.biz/en/reference/messaging-api/#separator)
* - [Filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* - [Spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
*
* See the followings for the components' JSON data samples and usage.
*
* - [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
* - [Flex Message layout](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/)
*/
export type FlexComponent =
| FlexBox
| FlexButton
| FlexImage
| FlexIcon
| FlexText
| FlexSpan
| FlexSeparator
| FlexFiller
| FlexSpacer;
/**
* This is a component that defines the layout of child components.
* You can also include a box in a box.
*/
export type FlexBox = {
type: "box";
/**
* The placement style of components in this box. Specify one of the following values:
*
* - `horizontal`: Components are placed horizontally. The `direction`
* property of the [bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
* container specifies the order.
* - `vertical`: Components are placed vertically from top to bottom.
* - `baseline`: Components are placed in the same way as `horizontal` is
* specified except the baselines of the components are aligned.
*
* For more information, see
* [Types of box layouts](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-layout-types).
*/
layout: "horizontal" | "vertical" | "baseline";
/**
* Components in this box. Here are the types of components available:
*
* - When the `layout` property is `horizontal` or `vertical`:
* + [Box](https://developers.line.biz/en/reference/messaging-api/#box)
* + [button](https://developers.line.biz/en/reference/messaging-api/#button)
* + [image](https://developers.line.biz/en/reference/messaging-api/#f-image)
* + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* + [separator](https://developers.line.biz/en/reference/messaging-api/#separator)
* + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
* - When the `layout` property is `baseline`:
* + [icon](https://developers.line.biz/en/reference/messaging-api/#icon)
* + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
*/
contents: FlexComponent[];
/**
* Background color of the block. In addition to the RGB color, an alpha
* channel (transparency) can also be set. Use a hexadecimal color code.
* (Example:#RRGGBBAA) The default value is `#00000000`.
*/
backgroundColor?: string;
/**
* Color of box border. Use a hexadecimal color code.
*/
borderColor?: string;
/**
* Width of box border. You can specify a value in pixels or any one of none,
* light, normal, medium, semi-bold, or bold. none does not render a border
* while the others become wider in the order of listing.
*/
borderWidth?:
| string
| "none"
| "light"
| "normal"
| "medium"
| "semi-bold"
| "bold";
/**
* Radius at the time of rounding the corners of the border. You can specify a
* value in pixels or any one of `none`, `xs`, `sm`, `md`, `lg`, `xl`, or `xxl`. none does not
* round the corner while the others increase in radius in the order of listing. The default value is none.
*/
cornerRadius?: string | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Width of the box. For more information, see [Width of a box](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-width) in the API documentation.
*/
width?: string;
/**
* Height of the box. For more information, see [Height of a box](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-height) in the API documentation.
*/
height?: string;
/**
* The ratio of the width or height of this box within the parent box. The
* default value for the horizontal parent box is `1`, and the default value
* for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
* Minimum space between components in this box.
*
* - `none` does not set a space while the other values set a space whose
* size increases in the order of listing.
* - The default value is `none`.
* - To override this setting for a specific component, set the `margin`
* property of that component.
*/
spacing?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Minimum space between this box and the previous component in the parent box.
*
* - `none` does not set a space while the other values set a space whose
* size increases in the order of listing.
* - The default value is the value of the `spacing` property of the parent
* box.
* - If this box is the first component in the parent box, the `margin`
* property will be ignored.
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Free space between the borders of this box and the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingAll?: string;
/**
* Free space between the border at the upper end of this box and the upper end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingTop?: string;
/**
* Free space between the border at the lower end of this box and the lower end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingBottom?: string;
/**
* Free space between the border at the left end of this box and the left end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingStart?: string;
/**
* Free space between the border at the right end of this box and the right end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingEnd?: string;
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
/**
* How child elements are aligned along the main axis of the parent element. If the
* parent element is a horizontal box, this only takes effect when its child elements have
* their `flex` property set equal to 0. For more information, see [Arranging a box's child elements and free space](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#justify-property)
* in the Messaging API documentation.
*/
justifyContent?:
| "flex-start"
| "center"
| "flex-end"
| "space-between"
| "space-around"
| "space-evenly";
/**
* How child elements are aligned along the cross axis of the parent element. For more
* information, see [Arranging a box's child elements and free space](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#justify-property) in the Messaging API documentation.
*/
alignItems?: "flex-start" | "center" | "flex-end";
background?: Background;
} & Offset;
export type Offset = {
/**
* Reference position for placing this box. Specify one of the following values:
* - `relative`: Use the previous box as reference.
* - `absolute`: Use the top left of parent element as reference.
*
* The default value is relative.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
position?: "relative" | "absolute";
/**
* The top offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetTop?: string;
/**
* The bottom offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetBottom?: string;
/**
* The left offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetStart?: string;
/**
* The right offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetEnd?: string;
};
export type Background = {
/**
* The type of background used. Specify these values:
* - `linearGradient`: Linear gradient. For more information, see [Linear gradient backgrounds](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#linear-gradient-bg) in the Messaging API documentation.
*/
type: "linearGradient";
/**
* The angle at which a linear gradient moves. Specify the angle using an integer value
* like `90deg` (90 degrees) or a decimal number like `23.5deg` (23.5 degrees) in the
* half-open interval [0, 360). The direction of the linear gradient rotates clockwise as the
* angle increases. Given a value of `0deg`, the gradient starts at the bottom and ends at
* the top; given a value of `45deg`, the gradient starts at the bottom-left corner and ends
* at the top-right corner; given a value of 90deg, the gradient starts at the left and ends
* at the right; and given a value of `180deg`, the gradient starts at the top and ends at
* the bottom. For more information, see [Direction (angle) of linear gradient backgrounds](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#linear-gradient-bg-angle) in the Messaging API documentation.
*/
angle: string;
/**
* The color at the gradient's starting point. Use a hexadecimal color code in the
* `#RRGGBB` or `#RRGGBBAA` format.
*/
startColor: string;
/**
* The color at the gradient's ending point. Use a hexadecimal color code in the
* `#RRGGBB` or `#RRGGBBAA` format.
*/
endColor: string;
/**
* The color in the middle of the gradient. Use a hexadecimal color code in the `#RRGGBB`
* or `#RRGGBBAA` format. Specify a value for the `background.centerColor` property to
* create a gradient that has three colors. For more information, see [Intermediate color stops for linear gradients](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#linear-gradient-bg-center-color) in the
* Messaging API documentation.
*/
centerColor?: string;
/**
* The position of the intermediate color stop. Specify an integer or decimal value
* between `0%` (the starting point) and `100%` (the ending point). This is `50%` by
* default. For more information, see [Intermediate color stops for linear gradients](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#linear-gradient-bg-center-color) in the
* Messaging API documentation.
*/
centerPosition?: string;
};
/**
* This component draws a button.
*
* When the user taps a button, a specified action is performed.
*/
export type FlexButton = {
type: "button";
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action: Action;
/**
* The ratio of the width or height of this box within the parent box.
*
* The default value for the horizontal parent box is `1`, and the default
* value for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
* Minimum space between this box and the previous component in the parent box.
*
* - `none` does not set a space while the other values set a space whose
* size increases in the order of listing.
* - The default value is the value of the `spacing` property of the parent
* box.
* - If this box is the first component in the parent box, the `margin`
* property will be ignored.
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Height of the button. The default value is `md`.
*/
height?: "sm" | "md";
/**
* Style of the button. Specify one of the following values:
*
* - `link`: HTML link style
* - `primary`: Style for dark color buttons
* - `secondary`: Style for light color buttons
*
* The default value is `link`.
*/
style?: "link" | "primary" | "secondary";
/**
* Use a hexadecimal color code.
*
* - Character color when the `style` property is `link`.
* - Background color when the `style` property is `primary` or `secondary`.
*/
color?: string;
/**
* Vertical alignment style. Specify one of the following values:
*
* - `top`: Top-aligned
* - `bottom`: Bottom-aligned
* - `center`: Center-aligned
*
* The default value is `top`.
*
* If the `layout` property of the parent box is `baseline`, the `gravity`
* property will be ignored.
*/
gravity?: "top" | "bottom" | "center";
/**
* The method by which to adjust the text font size. Specify this value:
*
* - `shrink-to-fit`: Automatically shrink the font
* size to fit the width of the component. This
* property takes a "best-effort" approach that may
* work differently—or not at all!—on some platforms.
* For more information, see [Automatically shrink fonts to fit](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#adjusts-fontsize-to-fit)
* in the Messaging API documentation.
* - LINE 10.13.0 or later for iOS and Android
*/
adjustMode?: "shrink-to-fit";
} & Offset;
/**
* This is an invisible component to fill extra space between components.
*
* - The filler's `flex` property is fixed to 1.
* - The `spacing` property of the parent box will be ignored for fillers.
*/
export type FlexFiller = {
type: "filler";
/**
* The ratio of the width or height of this component within the parent box. For more information, see [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
};
/**
* This component draws an icon.
*/
export type FlexIcon = {
type: "icon";
/**
* Image URL
*
* Protocol: HTTPS
* Image format: JPEG or PNG
* Maximum image size: 240×240 pixels
* Maximum data size: 1 MB
*/
url: string;
/**
* Minimum space between this box and the previous component in the parent
* box.
*
* - `none` does not set a space while the other values set a space whose
* size increases in the order of listing.
* - The default value is the value of the `spacing` property of the parent
* box.
* - If this box is the first component in the parent box, the `margin`
* property will be ignored.
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Maximum size of the icon width.
* The size increases in the order of listing.
* The default value is `md`.
* For more information, see [Icon, text, and span size](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#other-component-size) in the Messaging API documentation.
*/
size?:
| string
| "xxs"
| "xs"
| "sm"
| "md"
| "lg"
| "xl"
| "xxl"
| "3xl"
| "4xl"
| "5xl";
/**
* Aspect ratio of the icon. `{width}:{height}` format.
* The values of `{width}` and `{height}` must be in the range 1–100000.
* `{height}` can't be more than three times the value of `{width}`.
* The default value is `1:1`.
*/
aspectRatio?: string;
} & Offset;
/**
* This component draws an image.
*/
export type FlexImage = {
type: "image";
/**
* Image URL
*
* - Protocol: HTTPS
* - Image format: JPEG or PNG
* - Maximum image size: 1024×1024 pixels
* - Maximum data size: 1 MB
*/
url: string;
/**
* The ratio of the width or height of this box within the parent box.
*
* The default value for the horizontal parent box is `1`, and the default
* value for the vertical parent box is `0`.
*
* - For more information, see
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
* Minimum space between this box and the previous component in the parent
* box.
*
* - `none` does not set a space while the other values set a space whose
* size increases in the order of listing.
* - The default value is the value of the `spacing` property of the parent
* box.
* - If this box is the first component in the parent box, the `margin`
* property will be ignored.
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Horizontal alignment style. Specify one of the following values:
*
* - `start`: Left-aligned
* - `end`: Right-aligned
* - `center`: Center-aligned
*
* The default value is `center`.
*/
align?: "start" | "end" | "center";
/**
* Vertical alignment style. Specify one of the following values:
*
* - `top`: Top-aligned
* - `bottom`: Bottom-aligned
* - `center`: Center-aligned
*
* The default value is `top`.
*
* If the `layout` property of the parent box is `baseline`, the `gravity` property will be ignored.
*/
gravity?: "top" | "bottom" | "center";
/**
* Maximum size of the image width.
* The size increases in the order of listing.
* The default value is `md`.
* For more information, see [Image size](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#image-size) in the Messaging API documentation.
*/
size?:
| string
| "xxs"
| "xs"
| "sm"
| "md"
| "lg"
| "xl"
| "xxl"
| "3xl"
| "4xl"
| "5xl"
| "full";
/**
* Aspect ratio of the image. `{width}:{height}` format.
* Specify the value of `{width}` and `{height}` in the range from 1 to 100000. However,
* you cannot set `{height}` to a value that is more than three times the value of `{width}`.
* The default value is `1:1`.
*/
aspectRatio?: string;
/**
* Style of the image. Specify one of the following values:
*
* - `cover`: The image fills the entire drawing area. Parts of the image
* that do not fit in the drawing area are not displayed.
* - `fit`: The entire image is displayed in the drawing area. The background
* is displayed in the unused areas to the left and right of vertical images
* and in the areas above and below horizontal images.
*
* The default value is `fit`.
*/
aspectMode?: "cover" | "fit";
/**
* Background color of the image. Use a hexadecimal color code.
*/
backgroundColor?: string;
/**
* Action performed when this button is tapped.
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
/**
* When this is `true`, an animated image (APNG) plays.
* You can specify a value of `true` up to three times in a single message.
* You can't send messages that exceed this limit.
* This is `false` by default.
* Animated images larger than 300 KB aren't played back.
*/
animated?: Boolean;
} & Offset;
/**
* This component draws a separator between components in the parent box.
*/
export type FlexSeparator = {
type: "separator";
/**
* Minimum space between this box and the previous component in the parent
* box.
*
* - `none` does not set a space while the other values set a space whose
* size increases in the order of listing.
* - The default value is the value of the `spacing` property of the parent
* box.
* - If this box is the first component in the parent box, the `margin`
* property will be ignored.
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Color of the separator. Use a hexadecimal color code.
*/
color?: string;
};
/**
* This is an invisible component that places a fixed-size space at the
* beginning or end of the box.
* @deprecated
*/
export type FlexSpacer = {
type: "spacer";
/**
* Size of the space.
* The size increases in the order of listing.
* The default value is `md`.
*/
size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
};
export type FlexText = {
type: "text";
text: string;
/**
* Array of spans. Be sure to set either one of the `text` property or `contents` property. If you set the `contents` property, `text` is ignored.
*/
contents?: FlexSpan[];
/**
* The method by which to adjust the text font size. Specify this value:
*
* - `shrink-to-fit`: Automatically shrink the font
* size to fit the width of the component. This
* property takes a "best-effort" approach that may
* work differently—or not at all!—on some platforms.
* For more information, see [Automatically shrink fonts to fit](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#adjusts-fontsize-to-fit)
* in the Messaging API documentation.
* - LINE 10.13.0 or later for iOS and Android
*/
adjustMode?: "shrink-to-fit";
/**
* The ratio of the width or height of this box within the parent box.
*
* The default value for the horizontal parent box is `1`, and the default
* value for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
* Minimum space between this box and the previous component in the parent
* box.
*
* - `none` does not set a space while the other values set a space whose
* size increases in the order of listing.
* - The default value is the value of the `spacing` property of the parent
* box.
* - If this box is the first component in the parent box, the `margin`
* property will be ignored.
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Font size.
* The size increases in the order of listing.
* The default value is `md`.
* For more information, see [Icon, text, and span size](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#other-component-size) in the Messaging API documentation.
*/
size?:
| string
| "xxs"
| "xs"
| "sm"
| "md"
| "lg"
| "xl"
| "xxl"
| "3xl"
| "4xl"
| "5xl";
/**
* Horizontal alignment style. Specify one of the following values:
*
* - `start`: Left-aligned
* - `end`: Right-aligned
* - `center`: Center-aligned
*
* The default value is `start`.
*/
align?: "start" | "end" | "center";
/**
* Vertical alignment style. Specify one of the following values:
*
* - `top`: Top-aligned
* - `bottom`: Bottom-aligned
* - `center`: Center-aligned
*
* The default value is `top`.
*
* If the `layout` property of the parent box is `baseline`, the `gravity`
* property will be ignored.
*/
gravity?: "top" | "bottom" | "center";
/**
* `true` to wrap text.
*
* The default value is `false`.
*
* If set to `true`, you can use a new line character (\n) to begin on a new
* line.
*/
wrap?: boolean;
/**
* Max number of lines. If the text does not fit in the specified number of
* lines, an ellipsis (…) is displayed at the end of the last line. If set to
* 0, all the text is displayed. The default value is 0.
*/
maxLines?: number;
/**
* Font weight.
* Specifying `bold`makes the font bold.
* The default value is `regular`.
*/
weight?: "regular" | "bold";
/**
* Font color. Use a hexadecimal color code.
*/
color?: string;
/**
* Action performed when this text is tapped.
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
/**
* Style of the text. Specify one of the following values:
* - `normal`: Normal
* - `italic`: Italic
*
* The default value is `normal`.
*/
style?: string;
/**
* Decoration of the text. Specify one of the following values:
* `none`: No decoration
* `underline`: Underline
* `line-through`: Strikethrough
*
* The default value is `none`.
*/
decoration?: string;
} & Offset;
/**
* This component renders multiple text strings with different designs in one row. You can specify the color, size, weight, and decoration for the font. Span is set to `contents` property in [Text](https://developers.line.biz/en/reference/messaging-api/#f-text).
*/
export type FlexSpan = {
type: "span";
/**
* Text. If the `wrap` property of the parent text is set to `true`, you can use a new line character (`\n`) to begin on a new line.
*/
text: string;
/**
* Font color. Use a hexadecimal color code.
*/
color?: string;
/**
* Font size. You can specify one of the following values: `xxs`, `xs`, `sm`, `md`, `lg`, `xl`, `xxl`, `3xl`, `4xl`, or `5xl`. The size increases in the order of listing. The default value is `md`.
* For more information, see [Icon, text, and span size](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#other-component-size) in the Messaging API documentation.
*/
size?:
| string
| "xxs"
| "xs"
| "sm"
| "md"
| "lg"
| "xl"
| "xxl"
| "3xl"
| "4xl"
| "5xl";
/**
* Font weight. You can specify one of the following values: `regular` or `bold`. Specifying `bold` makes the font bold. The default value is `regular`.
*/
weight?: string;
/**
* Style of the text. Specify one of the following values:
* - `normal`: Normal
* - `italic`: Italic
*
* The default value is `normal`.
*/
style?: string;
/**
* Decoration of the text. Specify one of the following values:
* `none`: No decoration
* `underline`: Underline
* `line-through`: Strikethrough
*
* The default value is `none`.
*
* Note: The decoration set in the `decoration` property of the [text](https://developers.line.biz/en/reference/messaging-api/#f-text) cannot be overwritten by the `decoration` property of the span.
*/
decoration?: string;
};
export type TemplateContent =
| TemplateButtons
| TemplateConfirm
| TemplateCarousel
| TemplateImageCarousel;
/**
* Template with an image, title, text, and multiple action buttons.
*
* Because of the height limitation for buttons template messages, the lower
* part of the text display area will get cut off if the height limitation is
* exceeded. For this reason, depending on the character width, the message
* text may not be fully displayed even when it is within the character limits.
*/
export type TemplateButtons = {
type: "buttons";
/**
* Image URL (Max: 1000 characters)
*
* - HTTPS
* - JPEG or PNG
* - Max width: 1024px
* - Max: 1 MB
*/
thumbnailImageUrl?: string;
/**
* Aspect ratio of the image. Specify one of the following values:
*
* - `rectangle`: 1.51:1
* - `square`: 1:1
*
* The default value is `rectangle`
*/
imageAspectRatio?: "rectangle" | "square";
/**
* Size of the image. Specify one of the following values:
*
* - `cover`: The image fills the entire image area. Parts of the image that
* do not fit in the area are not displayed.
* - `contain`: The entire image is displayed in the image area. A background
* is displayed in the unused areas to the left and right of vertical images
* and in the areas above and below horizontal images.
*
* The default value is `cover`.
*/
imageSize?: "cover" | "contain";
/**
* Background color of image. Specify a RGB color value.
* The default value is `#FFFFFF` (white).
*/
imageBackgroundColor?: string;
/**
* Title (Max: 40 characters)
*/
title?: string;
/**
* Message text
*
* - Max: 160 characters (no image or title)
* - Max: 60 characters (message with an image or title)
*/
text: string;
/**
* Action when tapped (Max: 4)
*/
actions: Action[];
};
/**
* Template with two action buttons.
*
* Because of the height limitation for confirm template messages, the lower
* part of the `text` display area will get cut off if the height limitation is
* exceeded. For this reason, depending on the character width, the message
* text may not be fully displayed even when it is within the character limits.
*/
export type TemplateConfirm = {
type: "confirm";
/**
* Message text (Max: 240 characters)
*/
text: string;
/**
* Action when tapped. Set 2 actions for the 2 buttons
*/
actions: Action[];
};
/**
* Template with multiple columns which can be cycled like a carousel.
* The columns will be shown in order by scrolling horizontally.
*
* Because of the height limitation for carousel template messages, the lower
* part of the `text` display area will get cut off if the height limitation is
* exceeded. For this reason, depending on the character width, the message
* text may not be fully displayed even when it is within the character limits.
*
* Keep the number of actions consistent for all columns. If you use an image
* or title for a column, make sure to do the same for all other columns.
*/
export type TemplateCarousel = {
type: "carousel";
/**
* Array of columns (Max: 10)
*/
columns: TemplateColumn[];
/**
* Aspect ratio of the image. Specify one of the following values:
*
* - `rectangle`: 1.51:1
* - `square`: 1:1
*
* Applies to all columns. The default value is `rectangle`.
*/
imageAspectRatio?: "rectangle" | "square";
/**
* Size of the image. Specify one of the following values:
*
* - `cover`: The image fills the entire image area. Parts of the image that
* do not fit in the area are not displayed.
* - `contain`: The entire image is displayed in the image area. A background
* is displayed in the unused areas to the left and right of vertical images
* and in the areas above and below horizontal images.
*
* Applies to all columns. The default value is `cover`.
*/
imageSize?: "cover" | "contain";
};
export type TemplateColumn = {
/**
* Image URL (Max: 1000 characters)
*
* - HTTPS
* - JPEG or PNG
* - Aspect ratio: 1:1.51
* - Max width: 1024px
* - Max: 1 MB
*/
thumbnailImageUrl?: string;
/**
* Background color of image. Specify a RGB color value.
* The default value is `#FFFFFF` (white).
*/
imageBackgroundColor?: string;
/**
* Title (Max: 40 characters)
*/
title?: string;
/**
* Message text
*
* - Max: 120 characters (no image or title)
* - Max: 60 characters (message with an image or title)
*/
text: string;
/**
* Action when image is tapped; set for the entire image, title, and text area
*/
defaultAction?: Action;
/**
* Action when tapped (Max: 3)
*/
actions: Action[];
};
/**
* Template with multiple images which can be cycled like a carousel.
* The images will be shown in order by scrolling horizontally.
*/
export type TemplateImageCarousel = {
type: "image_carousel";
/**
* Array of columns (Max: 10)
*/
columns: TemplateImageColumn[];
};
export type TemplateImageColumn = {
/**
* Image URL (Max: 1000 characters)
*
* - HTTPS
* - JPEG or PNG
* - Aspect ratio: 1:1
* - Max width: 1024px
* - Max: 1 MB
*/
imageUrl: string;
/**
* Action when image is tapped
*/
action: Action<{ label?: string }>;
};
/**
* These properties are used for the quick reply.
*
* For more information, see
* [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
*/
export type QuickReply = {
/**
* This is a container that contains
* [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
*
* Array of objects (Max: 13)
*/
items: QuickReplyItem[];
};
/**
* This is a quick reply option that is displayed as a button.
*
* For more information, see
* [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
*/
export type QuickReplyItem = {
type: "action";
/**
* URL of the icon that is displayed at the beginning of the button (Max: 1000 characters)
*
* - URL scheme: https
* - Image format: PNG
* - Aspect ratio: 1:1
* - Data size: Up to 1 MB
*
* There is no limit on the image size. If the `action` property has the
* following actions with empty `imageUrl`:
*
* - [camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*
* the default icon is displayed.
*/
imageUrl?: string;
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*
* The following is a list of the available actions:
*
* - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
* - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*/
action: Action;
};
export type Sender = {
/**
* Display name
*
* - Max character limit: 20
* - Certain words such as `LINE` may not be used.
*/
name?: string;
/**
* Icon image URL
*
* - Max character limit: 1000
* - URL scheme: https
*/
iconUrl?: string;
};
/**
* These are types of actions for your bot to take when a user taps a button or an image in a message.
*
* - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
* - [URI action](https://developers.line.biz/en/reference/messaging-api/#uri-action)
* - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*/
export type Action<ExtraFields = { label: string }> = (
| PostbackAction
| MessageAction
| URIAction
| DatetimePickerAction
| { type: "camera" }
| { type: "cameraRoll" }
| { type: "location" }
) &
ExtraFields;
/**
* When a control associated with this action is tapped, a postback event is
* returned via webhook with the specified string in the data property.
*/
export type PostbackAction = {
type: "postback";
/**
* String returned via webhook in the `postback.data` property of the
* postback event (Max: 300 characters)
*/
data: string;
/**
* Text displayed in the chat as a message sent by the user when the action
* is performed. Returned from the server through a webhook.
*
* - This property cannot be used with quick reply buttons. (Max: 300 characters)
* - The `displayText` and `text` properties cannot both be used at the same time.
* @deprecated
*/
text?: string;
/**
* Text displayed in the chat as a message sent by the user when the action is performed.
*
* - Required for quick reply buttons.
* - Optional for the other message types.
*
* Max: 300 characters
*
* The `displayText` and `text` properties cannot both be used at the same time.
*/
displayText?: string;
};
/**
* When a control associated with this action is tapped, the string in the text
* property is sent as a message from the user.
*/
export type MessageAction = {
type: "message";
/**
* Text sent when the action is performed (Max: 300 characters)
*/
text: string;
};
/**
* When a control associated with this action is tapped, the URI specified in
* the `uri` property is opened.
*/
export type URIAction = {
type: "uri";
/**
* URI opened when the action is performed (Max: 1000 characters).
* Must start with `http`, `https`, or `tel`.
*/
uri: string;
altUri?: AltURI;
};
/**
* URI opened on LINE for macOS and Windows when the action is performed (Max: 1000 characters)
* If the altUri.desktop property is set, the uri property is ignored on LINE for macOS and Windows.
* The available schemes are http, https, line, and tel.
* For more information about the LINE URL scheme, see Using the LINE URL scheme.
* This property is supported on the following version of LINE.
*
* LINE 5.12.0 or later for macOS and Windows
* Note: The altUri.desktop property is supported only when you set URI actions in Flex Messages.
*/
export type AltURI = {
desktop: string;
};
/**
* When a control associated with this action is tapped, a
* [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event)
* is returned via webhook with the date and time selected by the user from the
* date and time selection dialog.
*
* The datetime picker action does not support time zones.
*
* #### Date and time format
*
* The date and time formats for the `initial`, `max`, and `min` values are
* shown below. The `full-date`, `time-hour`, and `time-minute` formats follow
* the [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) protocol.
*
* | Mode | Format | Example |
* | -------- | ------------------------------------------------------------ | -------------------------------- |
* | date | `full-date` (Max: 2100-12-31; Min: 1900-01-01) | 2017-06-18 |
* | time | `time-hour`:`time-minute` (Max: 23:59; Min: 00:00) | 00:0006:1523:59 |
* | datetime | `full-date`T`time-hour`:`time-minute` or `full-date`t`time-hour`:`time-minute` (Max: 2100-12-31T23:59; Min: 1900-01-01T00:00) | 2017-06-18T06:152017-06-18t06:15 |
*/
export type DatetimePickerAction = {
type: "datetimepicker";
/**
* String returned via webhook in the `postback.data` property of the
* postback event (Max: 300 characters)
*/
data: string;
mode: "date" | "time" | "datetime";
/**
* Initial value of date or time
*/
initial?: string;
/**
* Largest date or time value that can be selected. Must be greater than the
* `min` value.
*/
max?: string;
/**
* Smallest date or time value that can be selected. Must be less than the
* `max` value.
*/
min?: string;
};
export type Size = {
width: number;
height: number;
};
/**
* Rich menus consist of either of these objects.
*
* - [Rich menu object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-object)
* without the rich menu ID. Use this object when you
* [create a rich menu](https://developers.line.biz/en/reference/messaging-api/#create-rich-menu).
* - [Rich menu response object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-response-object)
* with the rich menu ID. This object is returned when you
* [get a rich menu](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu)
* or [get a list of rich menus](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list).
*
* [Area objects](https://developers.line.biz/en/reference/messaging-api/#area-object) and
* [action objects](https://developers.line.biz/en/reference/messaging-api/#action-objects)
* are included in these objects.
*/
export type RichMenu = {
/**
* [`size` object](https://developers.line.biz/en/reference/messaging-api/#size-object)
* which contains the width and height of the rich menu displayed in the chat.
* Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px.
*/
size: Size;
/**
* `true` to display the rich menu by default. Otherwise, `false`.
*/
selected: boolean;
/**
* Name of the rich menu.
*
* This value can be used to help manage your rich menus and is not displayed
* to users.
*
* (Max: 300 characters)
*/
name: string;
/**
* Text displayed in the chat bar (Max: 14 characters)
*/
chatBarText: string;
/**
* Array of [area objects](https://developers.line.biz/en/reference/messaging-api/#area-object)
* which define the coordinates and size of tappable areas
* (Max: 20 area objects)
*/
areas: Array<{ bounds: Area; action: Action<{ label?: string }> }>;
};
export type RichMenuResponse = { richMenuId: string } & RichMenu;
export type NumberOfMessagesSentResponse = InsightStatisticsResponse & {
/**
* The number of messages sent with the Messaging API on the date specified in date.
* The response has this property only when the value of status is `ready`.
*/
success?: number;
};
export type TargetLimitForAdditionalMessages = {
/**
* One of the following values to indicate whether a target limit is set or not.
* - `none`: This indicates that a target limit is not set.
* - `limited`: This indicates that a target limit is set.
*/
type: "none" | "limited";
/**
* The target limit for additional messages in the current month.
* This property is returned when the `type` property has a value of `limited`.
*/
value?: number;
};
export type NumberOfMessagesSentThisMonth = {
/**
* The number of sent messages in the current month
*/
totalUsage: number;
};
export const LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
export type MessageAPIResponseBase = {
[LINE_REQUEST_ID_HTTP_HEADER_NAME]?: string;
};
export const LINE_SIGNATURE_HTTP_HEADER_NAME = "x-line-signature";
export type InsightStatisticsResponse = {
/**
* Calculation status. One of:
* - `ready`: Calculation has finished; the numbers are up-to-date.
* - `unready`: We haven't finished calculating the number of sent messages for the specified `date`. Calculation usually takes about a day. Please try again later.
* - `out_of_service`: The specified `date` is earlier than the date on which we first started calculating sent messages. Different APIs have different date. Check them at the [document](https://developers.line.biz/en/reference/messaging-api/).
*/
status: "ready" | "unready" | "out_of_service";
};
export type NumberOfMessageDeliveries = InsightStatisticsResponse & {
/**
* Number of push messages sent to **all** of this LINE official account's friends (broadcast messages).
*/
broadcast: number;
/**
* Number of push messages sent to **some** of this LINE official account's friends, based on specific attributes (targeted/segmented messages).
*/
targeting: number;
/**
* Number of auto-response messages sent.
*/
autoResponse: number;
/**
* Number of greeting messages sent.
*/
welcomeResponse: number;
/**
* Number of messages sent from LINE Official Account Manager [Chat screen](https://www.linebiz.com/jp-en/manual/OfficialAccountManager/chats/screens/).
*/
chat: number;
/**
* Number of broadcast messages sent with the [Send broadcast message](https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message) Messaging API operation.
*/
apiBroadcast: number;
/**
* Number of push messages sent with the [Send push message](https://developers.line.biz/en/reference/messaging-api/#send-push-message) Messaging API operation.
*/
apiPush: number;
/**
* Number of multicast messages sent with the [Send multicast message](https://developers.line.biz/en/reference/messaging-api/#send-multicast-message) Messaging API operation.
*/
apiMulticast: number;
/**
* Number of replies sent with the [Send reply message](https://developers.line.biz/en/reference/messaging-api/#send-reply-message) Messaging API operation.
*/
apiReply: number;
};
export type NumberOfFollowers = InsightStatisticsResponse & {
/**
* The number of times, as of the specified `date`, that a user added this LINE official account as a friend. The number doesn't decrease when a user blocks the account after adding it, or when they delete their own account.
*/
followers: Number;
/**
* The number of users, as of the specified `date`, that the official account can reach with messages targeted by gender, age, or area. This number includes users for whom we estimated demographic attributes based on their activity in LINE and LINE-connected services.
*/
targetedReaches: Number;
/**
* The number of users blocking the account as of the specified `date`. The number decreases when a user unblocks the account.
*/
blocks: Number;
};
export type NumberOfMessageDeliveriesResponse =
| InsightStatisticsResponse
| NumberOfMessageDeliveries;
export type NumberOfFollowersResponse =
| InsightStatisticsResponse
| NumberOfFollowers;
type PercentageAble = {
percentage: number;
};
export type FriendDemographics = {
/**
* `true` if friend demographic information is available.
*/
available: boolean;
/**
* Percentage per gender
*/
genders?: Array<
{
/**
* Gender
*/
gender: "unknown" | "male" | "female";
} & PercentageAble
>;
/**
* Percentage per age group
*/
ages?: Array<
{
/**
* Age group
*/
age: string;
} & PercentageAble
>;
/**
* Percentage per area
*/
areas?: Array<
{
area: string;
} & PercentageAble
>;
/**
* Percentage by OS
*/
appTypes?: Array<
{
appType: "ios" | "android" | "others";
} & PercentageAble
>;
/**
* Percentage per friendship duration
*/
subscriptionPeriods?: Array<
{
/**
* Friendship duration
*/
subscriptionPeriod:
| "over365days"
| "within365days"
| "within180days"
| "within90days"
| "within30days"
| "within7days"
// in case for some rare cases(almost no)
| "unknown";
} & PercentageAble
>;
};
type UserInteractionStatisticsOfEachMessage = {
seq: number;
impression: number;
mediaPlayed: number;
mediaPlayed25Percent: number;
mediaPlayed50Percent: number;
mediaPlayed75Percent: number;
mediaPlayed100Percent: number;
uniqueMediaPlayed: number;
uniqueMediaPlayed25Percent: number;
uniqueMediaPlayed50Percent: number;
uniqueMediaPlayed75Percent: number;
uniqueMediaPlayed100Percent: number;
};
type UserInteractionStatisticsOfEachURL = {
seq: number;
url: number;
click: number;
uniqueClick: number;
uniqueClickOfRequest: number;
};
/**
* https://developers.line.biz/en/reference/messaging-api/#get-message-event
*/
export type UserInteractionStatistics = {
overview: {
requestId: string;
timestamp: number;
delivered: number;
uniqueImpression: number;
uniqueClick: number;
uniqueMediaPlayed: number;
uniqueMediaPlayed100Percent: number;
};
messages: UserInteractionStatisticsOfEachMessage[];
clicks: UserInteractionStatisticsOfEachURL[];
};
type FilterOperatorObject<T> = {
type: "operator";
} & (
| {
and: (T | FilterOperatorObject<T>)[];
}
| {
or: (T | FilterOperatorObject<T>)[];
}
| {
not: T | (T | FilterOperatorObject<T>)[];
}
);
type AudienceObject = {
type: "audience";
audienceGroupId: number;
};
export type ReceieptObject =
| AudienceObject
| FilterOperatorObject<AudienceObject>;
type DemographicAge =
| "age_15"
| "age_20"
| "age_25"
| "age_30"
| "age_35"
| "age_40"
| "age_45"
| "age_50";
type DemographicSubscriptionPeriod =
| "day_7"
| "day_30"
| "day_90"
| "day_180"
| "day_365";
type DemographicArea =
| "jp_01"
| "jp_02"
| "jp_03"
| "jp_04"
| "jp_05"
| "jp_06"
| "jp_07"
| "jp_08"
| "jp_09"
| "jp_10"
| "jp_11"
| "jp_12"
| "jp_13"
| "jp_14"
| "jp_15"
| "jp_16"
| "jp_17"
| "jp_18"
| "jp_19"
| "jp_20"
| "jp_21"
| "jp_22"
| "jp_23"
| "jp_24"
| "jp_25"
| "jp_26"
| "jp_27"
| "jp_28"
| "jp_29"
| "jp_30"
| "jp_31"
| "jp_32"
| "jp_33"
| "jp_34"
| "jp_35"
| "jp_36"
| "jp_37"
| "jp_38"
| "jp_39"
| "jp_40"
| "jp_41"
| "jp_42"
| "jp_43"
| "jp_44"
| "jp_45"
| "jp_46"
| "jp_47"
| "tw_01"
| "tw_02"
| "tw_03"
| "tw_04"
| "tw_05"
| "tw_06"
| "tw_07"
| "tw_08"
| "tw_09"
| "tw_10"
| "tw_11"
| "tw_12"
| "tw_13"
| "tw_14"
| "tw_15"
| "tw_16"
| "tw_17"
| "tw_18"
| "tw_19"
| "tw_20"
| "tw_21"
| "tw_22"
| "th_01"
| "th_02"
| "th_03"
| "th_04"
| "th_05"
| "th_06"
| "th_07"
| "th_08"
| "id_01"
| "id_02"
| "id_03"
| "id_04"
| "id_06"
| "id_07"
| "id_08"
| "id_09"
| "id_10"
| "id_11"
| "id_12"
| "id_05";
type DemographicObject =
| {
type: "gender";
oneOf: ("male" | "female")[];
}
| {
type: "age";
gte?: DemographicAge;
lt?: DemographicAge;
}
| {
type: "appType";
oneOf: ("ios" | "android")[];
}
| {
type: "area";
oneOf: DemographicArea[];
}
| {
type: "subscriptionPeriod";
gte?: DemographicSubscriptionPeriod;
lt?: DemographicSubscriptionPeriod;
};
export type DemographicFilterObject =
| DemographicObject
| FilterOperatorObject<DemographicObject>;
export type NarrowcastProgressResponse = (
| {
phase: "waiting";
}
| ((
| {
phase: "sending" | "succeeded";
}
| {
phase: "failed";
failedDescription: string;
}
) & {
successCount: number;
failureCount: number;
targetCount: string;
acceptedTime: string;
completedTime: string;
})
) & {
errorCode?: 1 | 2;
};
type AudienceGroupJob = {
audienceGroupJobId: number;
audienceGroupId: number;
description: string;
type: "DIFF_ADD";
audienceCount: number;
created: number;
} & (
| {
jobStatus: "QUEUED" | "WORKING" | "FINISHED";
}
| {
jobStatus: "FAILED";
failedType: "INTERNAL_ERROR";
}
);
export type AudienceGroupStatus =
| "IN_PROGRESS"
| "READY"
| "EXPIRED"
| "FAILED";
export type AudienceGroupCreateRoute = "OA_MANAGER" | "MESSAGING_API";
type _AudienceGroup = {
audienceGroupId: number;
description: string;
audienceCount: number;
created: number;
isIfaAudience: boolean;
permission: "READ" | "READ_WRITE";
createRoute: AudienceGroupCreateRoute;
} & (
| {
status: Exclude<AudienceGroupStatus, "FAILED">;
}
| {
status: "FAILED";
failedType: "AUDIENCE_GROUP_AUDIENCE_INSUFFICIENT" | "INTERNAL_ERROR";
}
) &
(
| {
type: "UPLOAD";
}
| {
type: "CLICK";
clickUrl: string;
}
| {
type: "IMP";
requestId: string;
}
);
export type AudienceGroup = _AudienceGroup & {
jobs: AudienceGroupJob[];
};
export type AudienceGroups = _AudienceGroup[];
export type AudienceGroupAuthorityLevel = "PUBLIC" | "PRIVATE";
export type ChannelAccessToken = {
access_token: string;
expires_in: number;
token_type: "Bearer";
key_id?: string;
};
/**
* Response body of get group summary.
*
* @see [Get group summary](https://developers.line.biz/ja/reference/messaging-api/#get-group-summary)
*/
export type GroupSummaryResponse = {
groupId: string;
groupName: string;
pictureUrl: string;
};
/**
* Response body of get members in group count and get members in room count.
*
* @see [Get members in group count](https://developers.line.biz/en/reference/messaging-api/#get-members-group-count)
* @see [Get members in room count](https://developers.line.biz/en/reference/messaging-api/#get-members-room-count)
*/
export type MembersCountResponse = {
count: number;
};
/**
* Response body of get bot info.
*
* @see [Get bot info](https://developers.line.biz/en/reference/messaging-api/#get-bot-info)
*/
export type BotInfoResponse = {
userId: string;
basicId: string;
premiumId?: string;
displayName: string;
pictureUrl?: string;
chatMode: "chat" | "bot";
markAsReadMode: "auto" | "manual";
};
/**
* Response body of get webhook endpoint info.
*
* @see [Get get webhook endpoint info](https://developers.line.biz/en/reference/messaging-api/#get-webhook-endpoint-information)
*/
export type WebhookEndpointInfoResponse = {
endpoint: string;
active: boolean;
};
/**
* Response body of test webhook endpoint.
*
* @see [Test webhook endpoint](https://developers.line.biz/en/reference/messaging-api/#test-webhook-endpoint)
*/
export type TestWebhookEndpointResponse = {
success: boolean;
timestamp: string;
statusCode: number;
reason: string;
detail: string;
};