@warriorteam/messenger-sdk 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -34,23 +34,23 @@ interface Recipient {
34
34
  last_name: string;
35
35
  };
36
36
  }
37
- interface QuickReply {
37
+ interface QuickReply$1 {
38
38
  content_type: 'text' | 'user_phone_number' | 'user_email';
39
39
  title?: string;
40
40
  payload?: string;
41
41
  image_url?: string;
42
42
  }
43
- interface Message {
43
+ interface Message$1 {
44
44
  text?: string;
45
45
  attachment?: Attachment;
46
- quick_replies?: QuickReply[];
46
+ quick_replies?: QuickReply$1[];
47
47
  metadata?: string;
48
48
  }
49
49
  interface Attachment {
50
50
  type: 'image' | 'audio' | 'video' | 'file' | 'template';
51
- payload: AttachmentPayload | TemplatePayload;
51
+ payload: AttachmentPayload$1 | TemplatePayload;
52
52
  }
53
- interface AttachmentPayload {
53
+ interface AttachmentPayload$1 {
54
54
  url?: string;
55
55
  attachment_id?: string;
56
56
  is_reusable?: boolean;
@@ -66,7 +66,7 @@ type MessagingType = 'RESPONSE' | 'UPDATE' | 'MESSAGE_TAG';
66
66
  interface SendMessageRequest {
67
67
  recipient: Recipient;
68
68
  messaging_type: MessagingType;
69
- message?: Message;
69
+ message?: Message$1;
70
70
  sender_action?: SenderAction;
71
71
  notification_type?: 'REGULAR' | 'SILENT_PUSH' | 'NO_PUSH';
72
72
  tag?: string;
@@ -88,9 +88,9 @@ interface ErrorResponse {
88
88
  error: MessengerError;
89
89
  }
90
90
 
91
- type AttachmentType = 'image' | 'audio' | 'video' | 'file';
91
+ type AttachmentType$1 = 'image' | 'audio' | 'video' | 'file';
92
92
  interface AttachmentUploadRequest {
93
- type: AttachmentType;
93
+ type: AttachmentType$1;
94
94
  url: string;
95
95
  is_reusable?: boolean;
96
96
  }
@@ -111,7 +111,7 @@ declare class SendAPI {
111
111
  */
112
112
  attachment(options: {
113
113
  recipient: Recipient;
114
- type: AttachmentType;
114
+ type: AttachmentType$1;
115
115
  attachment_id: string;
116
116
  messaging_type?: 'RESPONSE' | 'UPDATE' | 'MESSAGE_TAG';
117
117
  }, apiOptions?: APIOptions): Promise<SendMessageResponse>;
@@ -120,7 +120,7 @@ declare class SendAPI {
120
120
  */
121
121
  attachmentFromUrl(options: {
122
122
  recipient: Recipient;
123
- type: AttachmentType;
123
+ type: AttachmentType$1;
124
124
  url: string;
125
125
  messaging_type?: 'RESPONSE' | 'UPDATE' | 'MESSAGE_TAG';
126
126
  }, apiOptions?: APIOptions): Promise<SendMessageResponse>;
@@ -335,6 +335,1727 @@ declare class Messenger {
335
335
  private validateConfig;
336
336
  }
337
337
 
338
+ /**
339
+ * Facebook Messenger Platform - Base Webhook Types
340
+ *
341
+ * This file contains the common base types and interfaces shared across
342
+ * all webhook event types. It provides the foundation for a properly
343
+ * structured type system with inheritance and discriminated unions.
344
+ *
345
+ * @module webhooks/base-types
346
+ */
347
+ /**
348
+ * Common sender interface for all webhook events.
349
+ * Represents the user who initiated the action.
350
+ */
351
+ interface WebhookSender {
352
+ /**
353
+ * Page-scoped ID (PSID) of the user.
354
+ * This is the unique identifier for the user within the context of your page.
355
+ */
356
+ id: string;
357
+ /**
358
+ * User reference provided by the chat plugin, if applicable.
359
+ * Only present for chat plugin events where the user hasn't been identified yet.
360
+ */
361
+ user_ref?: string;
362
+ }
363
+ /**
364
+ * Common recipient interface for all webhook events.
365
+ * Represents the Facebook Page that received the event.
366
+ */
367
+ interface WebhookRecipient {
368
+ /** Facebook Page ID that received the event */
369
+ id: string;
370
+ }
371
+ /**
372
+ * Base interface for all webhook events.
373
+ * Contains the common properties shared by all event types.
374
+ */
375
+ interface BaseWebhookEvent {
376
+ /** Information about the user who initiated the event */
377
+ sender: WebhookSender;
378
+ /** Information about the page that received the event */
379
+ recipient: WebhookRecipient;
380
+ /**
381
+ * Unix timestamp when the event occurred (in milliseconds since epoch).
382
+ * Represents when the action was performed, not when the webhook was sent.
383
+ */
384
+ timestamp: number;
385
+ }
386
+ /**
387
+ * Webhook event types enum with discriminator values.
388
+ * Used for type narrowing in discriminated unions.
389
+ */
390
+ declare enum WebhookEventType {
391
+ MESSAGE = "message",
392
+ MESSAGE_EDIT = "message_edit",
393
+ MESSAGE_REACTION = "reaction",
394
+ MESSAGE_READ = "read",
395
+ MESSAGING_FEEDBACK = "messaging_feedback",
396
+ MESSAGING_POSTBACK = "postback"
397
+ }
398
+ /**
399
+ * Generic webhook entry structure.
400
+ * Represents a single entry in the webhook payload.
401
+ */
402
+ interface WebhookEntry<T extends BaseWebhookEvent = BaseWebhookEvent> {
403
+ /** Unique ID of the page */
404
+ id: string;
405
+ /** Time of update (epoch time in milliseconds) */
406
+ time: number;
407
+ /** Array of messaging events */
408
+ messaging: T[];
409
+ }
410
+ /**
411
+ * Generic webhook payload structure.
412
+ * This is the top-level structure received from Facebook webhooks.
413
+ */
414
+ interface WebhookPayload<T extends BaseWebhookEvent = BaseWebhookEvent> {
415
+ /** Always 'page' for Messenger webhooks */
416
+ object: 'page';
417
+ /** Array of entry objects containing the actual events */
418
+ entry: WebhookEntry<T>[];
419
+ }
420
+ /**
421
+ * Common processing context for all webhook events
422
+ */
423
+ interface BaseProcessingContext {
424
+ /** The user who initiated the event (PSID or user_ref) */
425
+ senderId?: string;
426
+ /** User reference for anonymous users */
427
+ userRef?: string;
428
+ /** The page that received the event */
429
+ recipientId: string;
430
+ /** When the event occurred */
431
+ timestamp: number;
432
+ /** Whether the sender is identified (has PSID) */
433
+ isIdentifiedUser: boolean;
434
+ /** Human-readable datetime for the event timestamp */
435
+ eventDate: Date;
436
+ }
437
+
438
+ /**
439
+ * Facebook Messenger Platform - Message Edits Webhook Types
440
+ *
441
+ * These types represent the webhook event structure for message_edits events.
442
+ * Triggered when a user edits a previously sent message.
443
+ *
444
+ * @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/message-edits/
445
+ */
446
+
447
+ /**
448
+ * Represents the edited message information
449
+ */
450
+ interface MessageEdit {
451
+ /**
452
+ * Unique message identifier for the edited message
453
+ */
454
+ mid: string;
455
+ /**
456
+ * New message content after the edit.
457
+ * Contains the updated text of the message.
458
+ */
459
+ text: string;
460
+ /**
461
+ * Number of times the message has been edited.
462
+ * Maximum value is 5 (client-side constraint).
463
+ */
464
+ num_edit: number;
465
+ }
466
+ /**
467
+ * Main webhook event structure for message edits with discriminator
468
+ *
469
+ * This event is triggered when a user edits a previously sent message.
470
+ * The webhook provides the updated message content and edit count.
471
+ *
472
+ * @example
473
+ * ```json
474
+ * {
475
+ * "type": "message_edit",
476
+ * "sender": {
477
+ * "id": "1234567890123456"
478
+ * },
479
+ * "recipient": {
480
+ * "id": "9876543210987654"
481
+ * },
482
+ * "timestamp": 1458668856463,
483
+ * "message_edit": {
484
+ * "mid": "mid.1458668856218:ed81099e15d3f4f233",
485
+ * "text": "This is the updated message content",
486
+ * "num_edit": 2
487
+ * }
488
+ * }
489
+ * ```
490
+ */
491
+ interface MessageEditWebhookEvent extends BaseWebhookEvent {
492
+ /** Discriminator for type narrowing */
493
+ type: WebhookEventType.MESSAGE_EDIT;
494
+ /** Details about the edited message */
495
+ message_edit: MessageEdit;
496
+ }
497
+ /**
498
+ * Complete webhook payload structure that includes the message edit event
499
+ * along with other webhook metadata
500
+ */
501
+ interface MessageEditWebhookPayload extends WebhookPayload<MessageEditWebhookEvent> {
502
+ }
503
+ /**
504
+ * Type guard to check if a webhook event is a message edit event
505
+ *
506
+ * @param event - The webhook event to check
507
+ * @returns True if the event contains a message_edit property
508
+ *
509
+ * @example
510
+ * ```typescript
511
+ * if (isMessageEditEvent(event)) {
512
+ * // TypeScript now knows event has message_edit property
513
+ * console.log(`Message edited ${event.message_edit.num_edit} times`);
514
+ * }
515
+ * ```
516
+ */
517
+ declare function isMessageEditEvent(event: any): event is MessageEditWebhookEvent;
518
+ /**
519
+ * Utility type for common message edit properties that might be used in processing
520
+ */
521
+ interface MessageEditProcessingContext extends BaseProcessingContext {
522
+ /** The edited message ID */
523
+ messageId: string;
524
+ /** Updated message content */
525
+ updatedText: string;
526
+ /** Number of edits made */
527
+ editCount: number;
528
+ }
529
+ /**
530
+ * Helper function to extract processing context from a message edit event
531
+ *
532
+ * @param event - The message edit webhook event
533
+ * @returns Simplified processing context
534
+ *
535
+ * @example
536
+ * ```typescript
537
+ * const context = extractMessageEditContext(webhookEvent);
538
+ * console.log(`User ${context.senderId} edited message to: "${context.updatedText}"`);
539
+ * ```
540
+ */
541
+ declare function extractMessageEditContext(event: MessageEditWebhookEvent): MessageEditProcessingContext;
542
+ /**
543
+ * Constants related to message editing limits and constraints
544
+ */
545
+ declare const MESSAGE_EDIT_CONSTANTS: {
546
+ /** Maximum number of edits allowed per message */
547
+ readonly MAX_EDITS: 5;
548
+ /** Webhook event type identifier */
549
+ readonly EVENT_TYPE: "message_edit";
550
+ };
551
+
552
+ /**
553
+ * Facebook Messenger Platform Message Reactions Webhook Types
554
+ *
555
+ * These types define the structure of webhook events received when users
556
+ * react to messages in Messenger conversations.
557
+ *
558
+ * @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/message-reactions
559
+ */
560
+
561
+ /**
562
+ * Types of reactions that can be applied to messages in Messenger.
563
+ * These are the predefined reaction types supported by Facebook.
564
+ */
565
+ declare enum MessageReactionType {
566
+ /** Standard like reaction */
567
+ LIKE = "like",
568
+ /** Dislike reaction */
569
+ DISLIKE = "dislike",
570
+ /** Love reaction (heart) */
571
+ LOVE = "love",
572
+ /** Sad reaction */
573
+ SAD = "sad",
574
+ /** Angry reaction */
575
+ ANGRY = "angry",
576
+ /** Wow/surprised reaction */
577
+ WOW = "wow",
578
+ /** Smile/laugh reaction */
579
+ SMILE = "smile",
580
+ /** Other/unrecognized emoji reactions */
581
+ OTHER = "other"
582
+ }
583
+ /**
584
+ * Actions that can be performed on message reactions.
585
+ */
586
+ declare enum MessageReactionAction {
587
+ /** Adding a reaction to a message */
588
+ REACT = "react",
589
+ /** Removing a reaction from a message */
590
+ UNREACT = "unreact"
591
+ }
592
+
593
+ /**
594
+ * Contains the detailed information about the reaction.
595
+ */
596
+ interface MessageReactionData {
597
+ /**
598
+ * The type of reaction applied to the message.
599
+ * Can be one of the predefined types or "other" for unrecognized emojis.
600
+ */
601
+ reaction: MessageReactionType;
602
+ /**
603
+ * The UTF-8 emoji representation of the reaction (optional).
604
+ * Example: "\u{2764}\u{FE0F}" for heart emoji
605
+ */
606
+ emoji?: string;
607
+ /**
608
+ * The action performed - either adding or removing the reaction.
609
+ */
610
+ action: MessageReactionAction;
611
+ /**
612
+ * The message ID that the reaction was applied to.
613
+ * This corresponds to the 'mid' field of the original message.
614
+ */
615
+ mid: string;
616
+ }
617
+ /**
618
+ * Complete webhook event structure for message reactions with discriminator.
619
+ * This is the main payload received when a user reacts to a message.
620
+ */
621
+ interface MessageReactionWebhookEvent extends BaseWebhookEvent {
622
+ /** Discriminator for type narrowing */
623
+ type: WebhookEventType.MESSAGE_REACTION;
624
+ /** Detailed information about the reaction */
625
+ reaction: MessageReactionData;
626
+ }
627
+ /**
628
+ * The complete webhook payload containing the message reaction event.
629
+ * This matches the structure of the webhook POST request body.
630
+ */
631
+ interface MessageReactionWebhookPayload extends WebhookPayload<MessageReactionWebhookEvent> {
632
+ }
633
+ /**
634
+ * Context object for processing message reaction webhooks.
635
+ * Useful for handlers that need additional processing information.
636
+ */
637
+ interface MessageReactionProcessingContext {
638
+ /** The original webhook event */
639
+ event: MessageReactionWebhookEvent;
640
+ /** Page ID that received the reaction */
641
+ pageId: string;
642
+ /** User ID who performed the reaction */
643
+ userId: string;
644
+ /** ID of the message that was reacted to */
645
+ messageId: string;
646
+ /** Whether this is a new reaction (true) or removal (false) */
647
+ isReactionAdded: boolean;
648
+ /** The type of reaction */
649
+ reactionType: MessageReactionType;
650
+ /** Raw emoji string if available */
651
+ emoji?: string;
652
+ /** Timestamp when the reaction occurred */
653
+ timestamp: Date;
654
+ }
655
+ /**
656
+ * Helper type for reaction statistics and aggregation.
657
+ * Useful for tracking reaction counts on messages.
658
+ */
659
+ interface MessageReactionStats {
660
+ /** The message ID these stats apply to */
661
+ messageId: string;
662
+ /** Count of each reaction type */
663
+ reactions: {
664
+ [K in MessageReactionType]?: number;
665
+ };
666
+ /** Total number of reactions */
667
+ totalReactions: number;
668
+ /** Last updated timestamp */
669
+ lastUpdated: Date;
670
+ }
671
+ /**
672
+ * Configuration options for handling message reaction webhooks.
673
+ */
674
+ interface MessageReactionWebhookConfig {
675
+ /** Whether to track reaction statistics */
676
+ enableStats?: boolean;
677
+ /** Whether to handle emoji reactions beyond predefined types */
678
+ handleCustomEmojis?: boolean;
679
+ /** Maximum age of reactions to process (in milliseconds) */
680
+ maxReactionAge?: number;
681
+ /** Whether to validate webhook signatures */
682
+ validateSignature?: boolean;
683
+ }
684
+
685
+ /**
686
+ * Facebook Messenger Platform - Message Reads Webhook Types
687
+ *
688
+ * These types represent the webhook event structure for message_reads events.
689
+ * Triggered when a user reads messages sent by a Page.
690
+ *
691
+ * The message_reads webhook event indicates that all messages up to a certain
692
+ * watermark timestamp have been read by the recipient.
693
+ *
694
+ * @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/message-reads/
695
+ */
696
+
697
+ /**
698
+ * Represents the read receipt information
699
+ */
700
+ interface MessageRead {
701
+ /**
702
+ * Watermark timestamp indicating all messages up to this point have been read.
703
+ * This is a Unix timestamp in milliseconds.
704
+ * All messages with a timestamp less than or equal to this value have been read.
705
+ */
706
+ watermark: number;
707
+ }
708
+ /**
709
+ * Main webhook event structure for message reads with discriminator
710
+ *
711
+ * This event is triggered when a user reads messages sent by a Page.
712
+ * The watermark indicates the timestamp up to which all messages have been read.
713
+ *
714
+ * @example
715
+ * ```json
716
+ * {
717
+ * "type": "read",
718
+ * "sender": {
719
+ * "id": "1234567890123456"
720
+ * },
721
+ * "recipient": {
722
+ * "id": "9876543210987654"
723
+ * },
724
+ * "timestamp": 1458668856463,
725
+ * "read": {
726
+ * "watermark": 1458668856253
727
+ * }
728
+ * }
729
+ * ```
730
+ */
731
+ interface MessageReadsWebhookEvent extends BaseWebhookEvent {
732
+ /** Discriminator for type narrowing */
733
+ type: WebhookEventType.MESSAGE_READ;
734
+ /** Read receipt information containing the watermark */
735
+ read: MessageRead;
736
+ }
737
+ /**
738
+ * Complete webhook payload structure that includes the message reads event
739
+ * along with other webhook metadata
740
+ */
741
+ interface MessageReadsWebhookPayload extends WebhookPayload<MessageReadsWebhookEvent> {
742
+ }
743
+ /**
744
+ * Type guard to check if a webhook event is a message reads event
745
+ *
746
+ * @param event - The webhook event to check
747
+ * @returns True if the event contains a read property
748
+ *
749
+ * @example
750
+ * ```typescript
751
+ * if (isMessageReadsEvent(event)) {
752
+ * // TypeScript now knows event has read property
753
+ * console.log(`Messages read up to timestamp: ${event.read.watermark}`);
754
+ * }
755
+ * ```
756
+ */
757
+ declare function isMessageReadsEvent(event: any): event is MessageReadsWebhookEvent;
758
+ /**
759
+ * Utility type for extracting just the read data from a webhook event
760
+ */
761
+ type MessageReadData = MessageRead;
762
+ /**
763
+ * Utility type for common message reads properties that might be used in processing
764
+ */
765
+ interface MessageReadsProcessingContext {
766
+ /** The user who read the messages */
767
+ senderId: string;
768
+ /** The page that sent the messages */
769
+ recipientId: string;
770
+ /** Timestamp up to which all messages have been read */
771
+ watermarkTimestamp: number;
772
+ /** When the read event occurred */
773
+ readTimestamp: number;
774
+ /**
775
+ * Human-readable datetime for the watermark timestamp.
776
+ * Useful for logging and debugging.
777
+ */
778
+ watermarkDate: Date;
779
+ /**
780
+ * Human-readable datetime for the read event timestamp.
781
+ * Useful for logging and debugging.
782
+ */
783
+ readDate: Date;
784
+ }
785
+ /**
786
+ * Helper function to extract processing context from a message reads event
787
+ *
788
+ * @param event - The message reads webhook event
789
+ * @returns Simplified processing context with additional computed fields
790
+ *
791
+ * @example
792
+ * ```typescript
793
+ * const context = extractMessageReadsContext(webhookEvent);
794
+ * console.log(`User ${context.senderId} read messages up to ${context.watermarkDate.toISOString()}`);
795
+ * ```
796
+ */
797
+ declare function extractMessageReadsContext(event: MessageReadsWebhookEvent): MessageReadsProcessingContext;
798
+ /**
799
+ * Helper function to check if a specific message timestamp was read
800
+ *
801
+ * @param messageTimestamp - The timestamp of the message to check
802
+ * @param watermark - The watermark timestamp from the read event
803
+ * @returns True if the message with the given timestamp has been read
804
+ *
805
+ * @example
806
+ * ```typescript
807
+ * const messageTime = 1458668855000;
808
+ * const watermark = 1458668856253;
809
+ *
810
+ * if (isMessageRead(messageTime, watermark)) {
811
+ * console.log('This message has been read');
812
+ * }
813
+ * ```
814
+ */
815
+ declare function isMessageRead(messageTimestamp: number, watermark: number): boolean;
816
+ /**
817
+ * Helper function to determine which messages in a list have been read
818
+ *
819
+ * @param messages - Array of messages with timestamp property
820
+ * @param watermark - The watermark timestamp from the read event
821
+ * @returns Array of messages that have been read
822
+ *
823
+ * @example
824
+ * ```typescript
825
+ * const messages = [
826
+ * { id: '1', timestamp: 1458668855000, text: 'Hello' },
827
+ * { id: '2', timestamp: 1458668857000, text: 'World' }
828
+ * ];
829
+ * const watermark = 1458668856253;
830
+ *
831
+ * const readMessages = getReadMessages(messages, watermark);
832
+ * // Returns only the first message as it's before the watermark
833
+ * ```
834
+ */
835
+ declare function getReadMessages<T extends {
836
+ timestamp: number;
837
+ }>(messages: T[], watermark: number): T[];
838
+ /**
839
+ * Helper function to get the count of read messages from a list
840
+ *
841
+ * @param messages - Array of messages with timestamp property
842
+ * @param watermark - The watermark timestamp from the read event
843
+ * @returns Number of messages that have been read
844
+ *
845
+ * @example
846
+ * ```typescript
847
+ * const messages = [
848
+ * { id: '1', timestamp: 1458668855000 },
849
+ * { id: '2', timestamp: 1458668857000 }
850
+ * ];
851
+ * const watermark = 1458668856253;
852
+ *
853
+ * const readCount = getReadMessageCount(messages, watermark);
854
+ * // Returns 1
855
+ * ```
856
+ */
857
+ declare function getReadMessageCount<T extends {
858
+ timestamp: number;
859
+ }>(messages: T[], watermark: number): number;
860
+ /**
861
+ * Constants related to message reads functionality
862
+ */
863
+ declare const MESSAGE_READS_CONSTANTS: {
864
+ /** Webhook event type identifier */
865
+ readonly EVENT_TYPE: "message_reads";
866
+ /**
867
+ * Property name in the webhook event that contains read data.
868
+ * Used for type guards and event identification.
869
+ */
870
+ readonly READ_PROPERTY: "read";
871
+ };
872
+ /**
873
+ * Type for the watermark timestamp
874
+ * Represents a Unix timestamp in milliseconds indicating read status
875
+ */
876
+ type WatermarkTimestamp = number;
877
+
878
+ /**
879
+ * Facebook Messenger Platform - Messaging Postbacks Webhook Types
880
+ *
881
+ * These types represent the webhook event structure for messaging_postbacks events.
882
+ * Triggered when a user clicks on a postback button, Get Started button, or persistent menu item.
883
+ *
884
+ * @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_postbacks
885
+ */
886
+
887
+ /**
888
+ * Represents referral information for postbacks that originated from external sources
889
+ *
890
+ * This object is included when a postback is triggered as part of a conversation
891
+ * that was started via m.me links, Click to Messenger ads, Messenger QR codes,
892
+ * or the Welcome Screen.
893
+ */
894
+ interface PostbackReferral {
895
+ /**
896
+ * Arbitrary data that was included in the original referral.
897
+ * This is the custom parameter you set when creating the referral link.
898
+ */
899
+ ref?: string;
900
+ /**
901
+ * Source of the referral. Indicates how the conversation was initiated.
902
+ * Common values include:
903
+ * - "SHORTLINK" - from m.me links
904
+ * - "ADS" - from Click to Messenger ads
905
+ * - "MESSENGER_CODE" - from Messenger QR codes
906
+ */
907
+ source?: string;
908
+ /**
909
+ * Type of referral action that initiated the conversation.
910
+ * Common value is "OPEN_THREAD" for most referral types.
911
+ */
912
+ type?: string;
913
+ }
914
+ /**
915
+ * Represents the postback data in a messaging postback webhook event
916
+ */
917
+ interface PostbackData {
918
+ /**
919
+ * Message ID associated with the postback.
920
+ * Unique identifier for the message that contained the postback button.
921
+ */
922
+ mid?: string;
923
+ /**
924
+ * Title of the postback button that was clicked.
925
+ * This is the user-visible text that was displayed on the button.
926
+ */
927
+ title?: string;
928
+ /**
929
+ * Developer-defined payload that was associated with the postback button.
930
+ * This contains the custom data you specified when creating the button.
931
+ * Maximum length is 1000 characters.
932
+ */
933
+ payload: string;
934
+ /**
935
+ * Referral information if the postback is part of a referred conversation.
936
+ * Only present when the conversation was initiated through external sources
937
+ * like m.me links, ads, QR codes, or Welcome Screen.
938
+ */
939
+ referral?: PostbackReferral;
940
+ }
941
+ /**
942
+ * Main webhook event structure for messaging postbacks with discriminator
943
+ *
944
+ * This event is triggered when a user interacts with postback buttons,
945
+ * including regular postback buttons, Get Started button, and persistent menu items.
946
+ *
947
+ * @example
948
+ * Basic postback from a button click:
949
+ * ```json
950
+ * {
951
+ * "type": "postback",
952
+ * "sender": {
953
+ * "id": "1234567890123456"
954
+ * },
955
+ * "recipient": {
956
+ * "id": "9876543210987654"
957
+ * },
958
+ * "timestamp": 1527459824,
959
+ * "postback": {
960
+ * "mid": "m_AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdHtHaW",
961
+ * "title": "Get Started",
962
+ * "payload": "GET_STARTED_PAYLOAD"
963
+ * }
964
+ * }
965
+ * ```
966
+ *
967
+ * @example
968
+ * Postback with referral data from m.me link:
969
+ * ```json
970
+ * {
971
+ * "type": "postback",
972
+ * "sender": {
973
+ * "user_ref": "unique_ref_param"
974
+ * },
975
+ * "recipient": {
976
+ * "id": "9876543210987654"
977
+ * },
978
+ * "timestamp": 1527459824,
979
+ * "postback": {
980
+ * "title": "Contact Sales",
981
+ * "payload": "CONTACT_SALES",
982
+ * "referral": {
983
+ * "ref": "landing_page_ad_campaign",
984
+ * "source": "SHORTLINK",
985
+ * "type": "OPEN_THREAD"
986
+ * }
987
+ * }
988
+ * }
989
+ * ```
990
+ */
991
+ interface MessagingPostbackWebhookEvent extends BaseWebhookEvent {
992
+ /** Discriminator for type narrowing */
993
+ type: WebhookEventType.MESSAGING_POSTBACK;
994
+ /** Details about the postback that was triggered */
995
+ postback: PostbackData;
996
+ }
997
+ /**
998
+ * Complete webhook payload structure that includes the messaging postback event
999
+ * along with other webhook metadata
1000
+ */
1001
+ interface MessagingPostbackWebhookPayload extends WebhookPayload<MessagingPostbackWebhookEvent> {
1002
+ }
1003
+ /**
1004
+ * Type guard to check if a webhook event is a messaging postback event
1005
+ *
1006
+ * @param event - The webhook event to check
1007
+ * @returns True if the event contains a postback property
1008
+ *
1009
+ * @example
1010
+ * ```typescript
1011
+ * if (isMessagingPostbackEvent(event)) {
1012
+ * // TypeScript now knows event has postback property
1013
+ * console.log(`User clicked: ${event.postback.title}`);
1014
+ * console.log(`Payload: ${event.postback.payload}`);
1015
+ * }
1016
+ * ```
1017
+ */
1018
+ declare function isMessagingPostbackEvent(event: any): event is MessagingPostbackWebhookEvent;
1019
+ /**
1020
+ * Type guard to check if a postback event includes referral data
1021
+ *
1022
+ * @param event - The messaging postback event to check
1023
+ * @returns True if the event contains referral information
1024
+ *
1025
+ * @example
1026
+ * ```typescript
1027
+ * if (hasReferralData(event)) {
1028
+ * // Handle referred conversation
1029
+ * console.log(`Referred from: ${event.postback.referral.source}`);
1030
+ * console.log(`Ref parameter: ${event.postback.referral.ref}`);
1031
+ * }
1032
+ * ```
1033
+ */
1034
+ declare function hasReferralData(event: MessagingPostbackWebhookEvent): event is MessagingPostbackWebhookEvent & {
1035
+ postback: PostbackData & {
1036
+ referral: PostbackReferral;
1037
+ };
1038
+ };
1039
+ /**
1040
+ * Type guard to check if sender is identified (has PSID) vs anonymous (has user_ref)
1041
+ *
1042
+ * @param sender - The sender object to check
1043
+ * @returns True if sender has a PSID (is identified)
1044
+ *
1045
+ * @example
1046
+ * ```typescript
1047
+ * if (isIdentifiedSender(event.sender)) {
1048
+ * // User has been identified and has a PSID
1049
+ * console.log(`User PSID: ${event.sender.id}`);
1050
+ * } else {
1051
+ * // Anonymous user with user_ref (likely from chat plugin)
1052
+ * console.log(`Anonymous user ref: ${event.sender.user_ref}`);
1053
+ * }
1054
+ * ```
1055
+ */
1056
+ declare function isIdentifiedSender(sender: WebhookSender): sender is WebhookSender & {
1057
+ id: string;
1058
+ };
1059
+ /**
1060
+ * Utility type for extracting just the postback data from a webhook event
1061
+ */
1062
+ type PostbackEventData = PostbackData;
1063
+ /**
1064
+ * Utility type for common postback properties that might be used in processing
1065
+ */
1066
+ interface PostbackProcessingContext {
1067
+ /** The postback payload data */
1068
+ payload: string;
1069
+ /** The user who triggered the postback (PSID or user_ref) */
1070
+ senderId?: string;
1071
+ /** User reference for anonymous users */
1072
+ userRef?: string;
1073
+ /** The page that received the postback */
1074
+ recipientId: string;
1075
+ /** Button title if available */
1076
+ buttonTitle?: string;
1077
+ /** Message ID if available */
1078
+ messageId?: string;
1079
+ /** When the postback occurred */
1080
+ timestamp: number;
1081
+ /** Referral context if present */
1082
+ referralContext?: {
1083
+ ref?: string;
1084
+ source?: string;
1085
+ type?: string;
1086
+ };
1087
+ /** Whether this is from a referred conversation */
1088
+ isReferred: boolean;
1089
+ /** Whether the sender is identified (has PSID) */
1090
+ isIdentifiedUser: boolean;
1091
+ }
1092
+ /**
1093
+ * Helper function to extract processing context from a messaging postback event
1094
+ *
1095
+ * @param event - The messaging postback webhook event
1096
+ * @returns Simplified processing context with all relevant data
1097
+ *
1098
+ * @example
1099
+ * ```typescript
1100
+ * const context = extractPostbackContext(webhookEvent);
1101
+ *
1102
+ * if (context.isReferred) {
1103
+ * console.log(`New conversation from ${context.referralContext?.source}`);
1104
+ * }
1105
+ *
1106
+ * if (context.isIdentifiedUser) {
1107
+ * console.log(`Known user ${context.senderId} clicked: ${context.payload}`);
1108
+ * } else {
1109
+ * console.log(`Anonymous user ${context.userRef} clicked: ${context.payload}`);
1110
+ * }
1111
+ * ```
1112
+ */
1113
+ declare function extractPostbackContext(event: MessagingPostbackWebhookEvent): PostbackProcessingContext;
1114
+ /**
1115
+ * Common postback payload patterns used in Messenger bots
1116
+ */
1117
+ declare const COMMON_POSTBACK_PAYLOADS: {
1118
+ /** Get Started button payload */
1119
+ readonly GET_STARTED: "GET_STARTED";
1120
+ /** Main menu navigation */
1121
+ readonly MAIN_MENU: "MAIN_MENU";
1122
+ /** Help/Support options */
1123
+ readonly HELP: "HELP";
1124
+ readonly SUPPORT: "SUPPORT";
1125
+ /** Contact information */
1126
+ readonly CONTACT: "CONTACT";
1127
+ readonly CONTACT_SALES: "CONTACT_SALES";
1128
+ readonly CONTACT_SUPPORT: "CONTACT_SUPPORT";
1129
+ /** Navigation actions */
1130
+ readonly BACK: "BACK";
1131
+ readonly NEXT: "NEXT";
1132
+ readonly CANCEL: "CANCEL";
1133
+ /** User preferences */
1134
+ readonly SETTINGS: "SETTINGS";
1135
+ readonly PREFERENCES: "PREFERENCES";
1136
+ };
1137
+ /**
1138
+ * Constants related to postback events and constraints
1139
+ */
1140
+ declare const POSTBACK_CONSTANTS: {
1141
+ /** Maximum payload length in characters */
1142
+ readonly MAX_PAYLOAD_LENGTH: 1000;
1143
+ /** Webhook event type identifier */
1144
+ readonly EVENT_TYPE: "postback";
1145
+ /** Common referral sources */
1146
+ readonly REFERRAL_SOURCES: {
1147
+ readonly SHORTLINK: "SHORTLINK";
1148
+ readonly ADS: "ADS";
1149
+ readonly MESSENGER_CODE: "MESSENGER_CODE";
1150
+ };
1151
+ /** Common referral types */
1152
+ readonly REFERRAL_TYPES: {
1153
+ readonly OPEN_THREAD: "OPEN_THREAD";
1154
+ };
1155
+ };
1156
+ /**
1157
+ * Type for postback payload values - can be custom strings or common patterns
1158
+ */
1159
+ type PostbackPayload = string | typeof COMMON_POSTBACK_PAYLOADS[keyof typeof COMMON_POSTBACK_PAYLOADS];
1160
+ /**
1161
+ * Type for referral sources
1162
+ */
1163
+ type ReferralSource$1 = typeof POSTBACK_CONSTANTS.REFERRAL_SOURCES[keyof typeof POSTBACK_CONSTANTS.REFERRAL_SOURCES] | string;
1164
+ /**
1165
+ * Type for referral types
1166
+ */
1167
+ type ReferralType$1 = typeof POSTBACK_CONSTANTS.REFERRAL_TYPES[keyof typeof POSTBACK_CONSTANTS.REFERRAL_TYPES] | string;
1168
+
1169
+ /**
1170
+ * Facebook Messenger Platform - Customer Feedback Webhook Types
1171
+ *
1172
+ * These types represent the webhook event structure for messaging_feedback events.
1173
+ * Triggered when a user submits feedback through a Customer Feedback Template.
1174
+ *
1175
+ * @see https://developers.facebook.com/docs/messenger-platform/send-messages/templates/customer-feedback-template
1176
+ */
1177
+
1178
+ /**
1179
+ * Available feedback types for customer feedback templates
1180
+ */
1181
+ declare enum FeedbackType {
1182
+ /** Customer Satisfaction - Score range 1-5 */
1183
+ CSAT = "csat",
1184
+ /** Net Promoter Score - Score range 0-10 */
1185
+ NPS = "nps",
1186
+ /** Customer Effort Score - Score range 1-7 */
1187
+ CES = "ces"
1188
+ }
1189
+ /**
1190
+ * Available display options for CSAT feedback type
1191
+ */
1192
+ declare enum CSATDisplayOption {
1193
+ /** Numeric scale from 1 to 5 */
1194
+ ONE_TO_FIVE = "one_to_five",
1195
+ /** Five star rating display */
1196
+ FIVE_STARS = "five_stars",
1197
+ /** Five emoji rating display */
1198
+ FIVE_EMOJIS = "five_emojis"
1199
+ }
1200
+ /**
1201
+ * Available display options for NPS feedback type
1202
+ */
1203
+ declare enum NPSDisplayOption {
1204
+ /** Numeric scale from 0 to 10 */
1205
+ ZERO_TO_TEN = "zero_to_ten"
1206
+ }
1207
+ /**
1208
+ * Available display options for CES feedback type
1209
+ */
1210
+ declare enum CESDisplayOption {
1211
+ /** Numeric scale from 1 to 7 */
1212
+ ONE_TO_SEVEN = "one_to_seven"
1213
+ }
1214
+ /**
1215
+ * Follow-up feedback type for optional text input
1216
+ */
1217
+ declare enum FollowUpType {
1218
+ /** Free-form text input (max 400 characters) */
1219
+ FREE_FORM = "free_form"
1220
+ }
1221
+
1222
+ /**
1223
+ * Represents optional follow-up feedback data
1224
+ */
1225
+ interface FeedbackFollowUp {
1226
+ /** Type of follow-up feedback - currently only supports free_form */
1227
+ type: FollowUpType.FREE_FORM;
1228
+ /**
1229
+ * User-provided text feedback.
1230
+ * Limited to 400 characters maximum.
1231
+ */
1232
+ payload: string;
1233
+ }
1234
+ /**
1235
+ * Represents individual question feedback data within a screen
1236
+ */
1237
+ interface FeedbackQuestion {
1238
+ /**
1239
+ * Type of feedback question (CSAT, NPS, or CES).
1240
+ * Determines the scoring range and display format.
1241
+ */
1242
+ type: FeedbackType;
1243
+ /**
1244
+ * Numeric score provided by the user.
1245
+ * Range depends on feedback type:
1246
+ * - CSAT: 1-5
1247
+ * - NPS: 0-10
1248
+ * - CES: 1-7
1249
+ */
1250
+ payload: string;
1251
+ /**
1252
+ * Optional follow-up text feedback from the user.
1253
+ * Only present if the template included a text input field.
1254
+ */
1255
+ follow_up?: FeedbackFollowUp;
1256
+ }
1257
+ /**
1258
+ * Represents a feedback screen containing questions and responses
1259
+ */
1260
+ interface FeedbackScreen {
1261
+ /**
1262
+ * Screen identifier within the feedback template.
1263
+ * Typically 0 for single-screen templates.
1264
+ */
1265
+ screen_id: number;
1266
+ /**
1267
+ * Map of question IDs to their corresponding feedback responses.
1268
+ * Question IDs are defined when creating the feedback template.
1269
+ */
1270
+ questions: Record<string, FeedbackQuestion>;
1271
+ }
1272
+ /**
1273
+ * Main messaging feedback data structure
1274
+ */
1275
+ interface MessagingFeedbackData {
1276
+ /**
1277
+ * Array of feedback screens with user responses.
1278
+ * Each screen contains questions and their answers.
1279
+ */
1280
+ feedback_screens: FeedbackScreen[];
1281
+ }
1282
+ /**
1283
+ * Main webhook event structure for messaging feedback with discriminator
1284
+ *
1285
+ * This event is triggered when a user submits feedback through a
1286
+ * Customer Feedback Template. The webhook provides the user's
1287
+ * scores and optional text feedback.
1288
+ *
1289
+ * @example
1290
+ * ```json
1291
+ * {
1292
+ * "type": "messaging_feedback",
1293
+ * "sender": {
1294
+ * "id": "1234567890123456"
1295
+ * },
1296
+ * "recipient": {
1297
+ * "id": "9876543210987654"
1298
+ * },
1299
+ * "timestamp": 1458668856463,
1300
+ * "messaging_feedback": {
1301
+ * "feedback_screens": [{
1302
+ * "screen_id": 0,
1303
+ * "questions": {
1304
+ * "satisfaction_q1": {
1305
+ * "type": "csat",
1306
+ * "payload": "4",
1307
+ * "follow_up": {
1308
+ * "type": "free_form",
1309
+ * "payload": "Good service overall!"
1310
+ * }
1311
+ * }
1312
+ * }
1313
+ * }]
1314
+ * }
1315
+ * }
1316
+ * ```
1317
+ */
1318
+ interface MessagingFeedbackWebhookEvent extends BaseWebhookEvent {
1319
+ /** Discriminator for type narrowing */
1320
+ type: WebhookEventType.MESSAGING_FEEDBACK;
1321
+ /** The actual feedback data containing user responses */
1322
+ messaging_feedback: MessagingFeedbackData;
1323
+ }
1324
+ /**
1325
+ * Complete webhook payload structure that includes the messaging feedback event
1326
+ * along with other webhook metadata
1327
+ */
1328
+ interface MessagingFeedbackWebhookPayload extends WebhookPayload<MessagingFeedbackWebhookEvent> {
1329
+ }
1330
+ /**
1331
+ * Type guard to check if a webhook event is a messaging feedback event
1332
+ *
1333
+ * @param event - The webhook event to check
1334
+ * @returns True if the event contains a messaging_feedback property
1335
+ *
1336
+ * @example
1337
+ * ```typescript
1338
+ * if (isMessagingFeedbackEvent(event)) {
1339
+ * // TypeScript now knows event has messaging_feedback property
1340
+ * console.log(`Received feedback with ${event.messaging_feedback.feedback_screens.length} screens`);
1341
+ * }
1342
+ * ```
1343
+ */
1344
+ declare function isMessagingFeedbackEvent(event: any): event is MessagingFeedbackWebhookEvent;
1345
+ /**
1346
+ * Utility type for common feedback properties that might be used in processing
1347
+ */
1348
+ interface MessagingFeedbackProcessingContext {
1349
+ /** The user who submitted the feedback */
1350
+ senderId: string;
1351
+ /** The page that received the feedback */
1352
+ recipientId: string;
1353
+ /** When the feedback was submitted */
1354
+ submissionTimestamp: number;
1355
+ /** Total number of feedback screens */
1356
+ screenCount: number;
1357
+ /** All question responses flattened from all screens */
1358
+ allResponses: Array<{
1359
+ questionId: string;
1360
+ feedbackType: FeedbackType;
1361
+ score: number;
1362
+ textFeedback?: string;
1363
+ screenId: number;
1364
+ }>;
1365
+ }
1366
+ /**
1367
+ * Helper function to extract processing context from a messaging feedback event
1368
+ *
1369
+ * @param event - The messaging feedback webhook event
1370
+ * @returns Simplified processing context with flattened responses
1371
+ *
1372
+ * @example
1373
+ * ```typescript
1374
+ * const context = extractMessagingFeedbackContext(webhookEvent);
1375
+ * console.log(`User ${context.senderId} submitted ${context.allResponses.length} feedback responses`);
1376
+ * context.allResponses.forEach(response => {
1377
+ * console.log(`${response.questionId}: ${response.score}/10 (${response.feedbackType})`);
1378
+ * });
1379
+ * ```
1380
+ */
1381
+ declare function extractMessagingFeedbackContext(event: MessagingFeedbackWebhookEvent): MessagingFeedbackProcessingContext;
1382
+ /**
1383
+ * Helper function to get feedback scores by type from an event
1384
+ *
1385
+ * @param event - The messaging feedback webhook event
1386
+ * @returns Map of feedback types to their scores
1387
+ *
1388
+ * @example
1389
+ * ```typescript
1390
+ * const scores = getFeedbackScoresByType(webhookEvent);
1391
+ * const csatScore = scores.get(FeedbackType.CSAT); // number | undefined
1392
+ * const npsScore = scores.get(FeedbackType.NPS); // number | undefined
1393
+ * ```
1394
+ */
1395
+ declare function getFeedbackScoresByType(event: MessagingFeedbackWebhookEvent): Map<FeedbackType, number[]>;
1396
+ /**
1397
+ * Helper function to extract all text feedback from an event
1398
+ *
1399
+ * @param event - The messaging feedback webhook event
1400
+ * @returns Array of text feedback strings
1401
+ *
1402
+ * @example
1403
+ * ```typescript
1404
+ * const textFeedback = extractTextFeedback(webhookEvent);
1405
+ * textFeedback.forEach(feedback => {
1406
+ * console.log(`User comment: "${feedback}"`);
1407
+ * });
1408
+ * ```
1409
+ */
1410
+ declare function extractTextFeedback(event: MessagingFeedbackWebhookEvent): string[];
1411
+ /**
1412
+ * Constants related to customer feedback constraints and limits
1413
+ */
1414
+ declare const MESSAGING_FEEDBACK_CONSTANTS: {
1415
+ /** Maximum characters allowed in free-form text feedback */
1416
+ readonly MAX_TEXT_FEEDBACK_LENGTH: 400;
1417
+ /** Score ranges for different feedback types */
1418
+ readonly SCORE_RANGES: {
1419
+ readonly csat: {
1420
+ readonly min: 1;
1421
+ readonly max: 5;
1422
+ };
1423
+ readonly nps: {
1424
+ readonly min: 0;
1425
+ readonly max: 10;
1426
+ };
1427
+ readonly ces: {
1428
+ readonly min: 1;
1429
+ readonly max: 7;
1430
+ };
1431
+ };
1432
+ /** Template expiry constraints */
1433
+ readonly TEMPLATE_EXPIRY: {
1434
+ /** Minimum expiry days */
1435
+ readonly MIN_DAYS: 1;
1436
+ /** Maximum expiry days */
1437
+ readonly MAX_DAYS: 7;
1438
+ /** Default expiry days */
1439
+ readonly DEFAULT_DAYS: 1;
1440
+ };
1441
+ /** Question ID constraints */
1442
+ readonly QUESTION_ID: {
1443
+ /** Maximum length for question IDs */
1444
+ readonly MAX_LENGTH: 80;
1445
+ /** Valid characters pattern (alphanumeric) */
1446
+ readonly VALID_PATTERN: RegExp;
1447
+ };
1448
+ /** Template limits */
1449
+ readonly TEMPLATE_LIMITS: {
1450
+ /** Maximum number of titles per template */
1451
+ readonly MAX_TITLES: 1;
1452
+ /** Maximum number of scoring components per template */
1453
+ readonly MAX_SCORING_COMPONENTS: 1;
1454
+ };
1455
+ /** Webhook event type identifier */
1456
+ readonly EVENT_TYPE: "messaging_feedback";
1457
+ };
1458
+ /**
1459
+ * Validation helper to check if a score is valid for a given feedback type
1460
+ *
1461
+ * @param feedbackType - The type of feedback being validated
1462
+ * @param score - The score to validate
1463
+ * @returns True if the score is within the valid range for the feedback type
1464
+ *
1465
+ * @example
1466
+ * ```typescript
1467
+ * const isValid = isValidFeedbackScore(FeedbackType.CSAT, 4); // true
1468
+ * const isInvalid = isValidFeedbackScore(FeedbackType.NPS, 15); // false
1469
+ * ```
1470
+ */
1471
+ declare function isValidFeedbackScore(feedbackType: FeedbackType, score: number): boolean;
1472
+ /**
1473
+ * Validation helper to check if a question ID is valid
1474
+ *
1475
+ * @param questionId - The question ID to validate
1476
+ * @returns True if the question ID meets the format requirements
1477
+ *
1478
+ * @example
1479
+ * ```typescript
1480
+ * const isValid = isValidQuestionId('satisfaction_q1'); // true
1481
+ * const isInvalid = isValidQuestionId('invalid-id!'); // false
1482
+ * ```
1483
+ */
1484
+ declare function isValidQuestionId(questionId: string): boolean;
1485
+ /**
1486
+ * Validation helper to check if text feedback is within character limits
1487
+ *
1488
+ * @param textFeedback - The text feedback to validate
1489
+ * @returns True if the text is within the character limit
1490
+ *
1491
+ * @example
1492
+ * ```typescript
1493
+ * const isValid = isValidTextFeedback('Great service!'); // true
1494
+ * const isInvalid = isValidTextFeedback('a'.repeat(500)); // false
1495
+ * ```
1496
+ */
1497
+ declare function isValidTextFeedback(textFeedback: string): boolean;
1498
+
1499
+ /**
1500
+ * Facebook Messenger Platform - Messages Webhook Types
1501
+ *
1502
+ * These types represent the webhook event structure for messages events.
1503
+ * Triggered when a user sends a message to your page.
1504
+ *
1505
+ * @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messages
1506
+ */
1507
+
1508
+ /**
1509
+ * Enumeration of attachment types supported by the Messenger Platform
1510
+ */
1511
+ declare enum AttachmentType {
1512
+ AUDIO = "audio",
1513
+ FILE = "file",
1514
+ IMAGE = "image",
1515
+ VIDEO = "video",
1516
+ FALLBACK = "fallback",
1517
+ REEL = "reel",
1518
+ IG_REEL = "ig_reel"
1519
+ }
1520
+ /**
1521
+ * Enumeration of referral types for message referrals
1522
+ */
1523
+ declare enum ReferralType {
1524
+ OPEN_THREAD = "OPEN_THREAD",
1525
+ PRODUCT = "product",
1526
+ ADS = "ads"
1527
+ }
1528
+ /**
1529
+ * Enumeration of referral sources
1530
+ */
1531
+ declare enum ReferralSource {
1532
+ MESSENGER_CODE = "MESSENGER_CODE",
1533
+ DISCOVER_TAB = "DISCOVER_TAB",
1534
+ ADS = "ADS",
1535
+ SHORTLINK = "SHORTLINK",
1536
+ CUSTOMER_CHAT_PLUGIN = "CUSTOMER_CHAT_PLUGIN"
1537
+ }
1538
+
1539
+ /**
1540
+ * Represents a quick reply payload in a message
1541
+ */
1542
+ interface QuickReply {
1543
+ /**
1544
+ * The payload string that was defined when the quick reply was sent.
1545
+ * Maximum 1000 characters.
1546
+ */
1547
+ payload: string;
1548
+ }
1549
+ /**
1550
+ * Represents the reply-to information when a message is a reply
1551
+ */
1552
+ interface ReplyTo {
1553
+ /**
1554
+ * Message ID of the message being replied to
1555
+ */
1556
+ mid: string;
1557
+ }
1558
+ /**
1559
+ * Base attachment payload interface
1560
+ */
1561
+ interface BaseAttachmentPayload {
1562
+ /** URL to the attachment file */
1563
+ url: string;
1564
+ }
1565
+ /**
1566
+ * Attachment payload for media files (audio, image, video, file)
1567
+ */
1568
+ interface MediaAttachmentPayload extends BaseAttachmentPayload {
1569
+ /** URL to the attachment file */
1570
+ url: string;
1571
+ /** Title of the attachment, if available */
1572
+ title?: string;
1573
+ }
1574
+ /**
1575
+ * Attachment payload for sticker attachments
1576
+ */
1577
+ interface StickerAttachmentPayload extends BaseAttachmentPayload {
1578
+ /** URL to the sticker image */
1579
+ url: string;
1580
+ /** Sticker ID for the sent sticker */
1581
+ sticker_id: number;
1582
+ }
1583
+ /**
1584
+ * Attachment payload for reel attachments (Instagram Reels, Facebook Reels)
1585
+ */
1586
+ interface ReelAttachmentPayload extends BaseAttachmentPayload {
1587
+ /** URL to the reel */
1588
+ url: string;
1589
+ /** Video ID of the reel */
1590
+ reel_video_id?: number;
1591
+ }
1592
+ /**
1593
+ * Attachment payload for fallback attachments
1594
+ */
1595
+ interface FallbackAttachmentPayload extends BaseAttachmentPayload {
1596
+ /** URL to the attachment */
1597
+ url: string;
1598
+ /** Title of the fallback attachment */
1599
+ title?: string;
1600
+ }
1601
+ /**
1602
+ * Union type for all possible attachment payload types
1603
+ */
1604
+ type AttachmentPayload = MediaAttachmentPayload | StickerAttachmentPayload | ReelAttachmentPayload | FallbackAttachmentPayload;
1605
+ /**
1606
+ * Represents an attachment in a message
1607
+ */
1608
+ interface MessageAttachment {
1609
+ /** The type of attachment */
1610
+ type: AttachmentType;
1611
+ /** The attachment payload containing the actual attachment data */
1612
+ payload: AttachmentPayload;
1613
+ }
1614
+ /**
1615
+ * Represents referral data in a message (for referral campaigns, ads, etc.)
1616
+ */
1617
+ interface MessageReferral {
1618
+ /** The source of the referral */
1619
+ source: ReferralSource;
1620
+ /** The type of referral */
1621
+ type: ReferralType;
1622
+ /**
1623
+ * The optional ref parameter passed in the referral.
1624
+ * Maximum 250 characters.
1625
+ */
1626
+ ref?: string;
1627
+ /**
1628
+ * URL of the website where the referral was triggered.
1629
+ * Only present for CUSTOMER_CHAT_PLUGIN source.
1630
+ */
1631
+ referer_uri?: string;
1632
+ /**
1633
+ * Indicates whether the referral is from a guest user.
1634
+ * Only present for CUSTOMER_CHAT_PLUGIN source.
1635
+ */
1636
+ is_guest_user?: boolean;
1637
+ /**
1638
+ * Product information for product referrals.
1639
+ * Only present when type is 'product'.
1640
+ */
1641
+ product?: {
1642
+ /** Product ID */
1643
+ id: string;
1644
+ };
1645
+ /**
1646
+ * Ad information for ad referrals.
1647
+ * Only present when type is 'ads'.
1648
+ */
1649
+ ads?: {
1650
+ /** Ad ID */
1651
+ id: string;
1652
+ /** Ad title */
1653
+ title?: string;
1654
+ /** Ad image URL */
1655
+ image_url?: string;
1656
+ };
1657
+ }
1658
+ /**
1659
+ * Represents a command in a message (for bot commands)
1660
+ */
1661
+ interface MessageCommand {
1662
+ /** The name of the command */
1663
+ name: string;
1664
+ }
1665
+ /**
1666
+ * Represents the main message content in a webhook event
1667
+ */
1668
+ interface Message {
1669
+ /**
1670
+ * Unique message identifier
1671
+ */
1672
+ mid: string;
1673
+ /**
1674
+ * Text content of the message.
1675
+ * Present for text messages and messages with quick replies.
1676
+ * Maximum 2000 UTF-8 characters.
1677
+ */
1678
+ text?: string;
1679
+ /**
1680
+ * Quick reply payload, if the message was sent as a response to a quick reply.
1681
+ * Only present when the user taps a quick reply button.
1682
+ */
1683
+ quick_reply?: QuickReply;
1684
+ /**
1685
+ * Reply-to information, if this message is a reply to another message.
1686
+ * Only present when the user replies to a specific message.
1687
+ */
1688
+ reply_to?: ReplyTo;
1689
+ /**
1690
+ * Array of attachments sent with the message.
1691
+ * Can include images, audio, video, files, location, etc.
1692
+ */
1693
+ attachments?: MessageAttachment[];
1694
+ /**
1695
+ * Referral information, if the message came from a referral.
1696
+ * Present when users click on ads, m.me links, etc.
1697
+ */
1698
+ referral?: MessageReferral;
1699
+ /**
1700
+ * Array of commands, if the message contains bot commands.
1701
+ * Present when users send commands like /start, /help, etc.
1702
+ */
1703
+ commands?: MessageCommand[];
1704
+ }
1705
+ /**
1706
+ * Main webhook event structure for messages with discriminator
1707
+ *
1708
+ * This event is triggered when a user sends a message to your page.
1709
+ * The webhook provides the message content and metadata.
1710
+ *
1711
+ * @example Text message:
1712
+ * ```json
1713
+ * {
1714
+ * "type": "message",
1715
+ * "sender": {
1716
+ * "id": "1234567890123456"
1717
+ * },
1718
+ * "recipient": {
1719
+ * "id": "9876543210987654"
1720
+ * },
1721
+ * "timestamp": 1458668856463,
1722
+ * "message": {
1723
+ * "mid": "mid.1458668856218:ed81099e15d3f4f233",
1724
+ * "text": "Hello, world!"
1725
+ * }
1726
+ * }
1727
+ * ```
1728
+ *
1729
+ * @example Message with attachment:
1730
+ * ```json
1731
+ * {
1732
+ * "type": "message",
1733
+ * "sender": {
1734
+ * "id": "1234567890123456"
1735
+ * },
1736
+ * "recipient": {
1737
+ * "id": "9876543210987654"
1738
+ * },
1739
+ * "timestamp": 1458668856463,
1740
+ * "message": {
1741
+ * "mid": "mid.1458668856218:ed81099e15d3f4f233",
1742
+ * "attachments": [
1743
+ * {
1744
+ * "type": "image",
1745
+ * "payload": {
1746
+ * "url": "https://scontent.xx.fbcdn.net/v/image.jpg"
1747
+ * }
1748
+ * }
1749
+ * ]
1750
+ * }
1751
+ * }
1752
+ * ```
1753
+ *
1754
+ * @example Message with quick reply:
1755
+ * ```json
1756
+ * {
1757
+ * "type": "message",
1758
+ * "sender": {
1759
+ * "id": "1234567890123456"
1760
+ * },
1761
+ * "recipient": {
1762
+ * "id": "9876543210987654"
1763
+ * },
1764
+ * "timestamp": 1458668856463,
1765
+ * "message": {
1766
+ * "mid": "mid.1458668856218:ed81099e15d3f4f233",
1767
+ * "text": "Yes",
1768
+ * "quick_reply": {
1769
+ * "payload": "YES_PAYLOAD"
1770
+ * }
1771
+ * }
1772
+ * }
1773
+ * ```
1774
+ */
1775
+ interface MessageWebhookEvent extends BaseWebhookEvent {
1776
+ /** Discriminator for type narrowing */
1777
+ type: WebhookEventType.MESSAGE;
1778
+ /** The message content and metadata */
1779
+ message: Message;
1780
+ }
1781
+ /**
1782
+ * Complete webhook payload structure that includes the message event
1783
+ * along with other webhook metadata
1784
+ */
1785
+ interface MessageWebhookPayload extends WebhookPayload<MessageWebhookEvent> {
1786
+ }
1787
+ /**
1788
+ * Type guard to check if a webhook event is a message event
1789
+ *
1790
+ * @param event - The webhook event to check
1791
+ * @returns True if the event contains a message property
1792
+ *
1793
+ * @example
1794
+ * ```typescript
1795
+ * if (isMessageEvent(event)) {
1796
+ * // TypeScript now knows event has message property
1797
+ * console.log(`Received message: ${event.message.text || '[attachment]'}`);
1798
+ * }
1799
+ * ```
1800
+ */
1801
+ declare function isMessageEvent(event: any): event is MessageWebhookEvent;
1802
+ /**
1803
+ * Type guard to check if a message has text content
1804
+ *
1805
+ * @param message - The message to check
1806
+ * @returns True if the message has text content
1807
+ */
1808
+ declare function isTextMessage(message: Message): message is Message & {
1809
+ text: string;
1810
+ };
1811
+ /**
1812
+ * Type guard to check if a message has attachments
1813
+ *
1814
+ * @param message - The message to check
1815
+ * @returns True if the message has attachments
1816
+ */
1817
+ declare function hasAttachments(message: Message): message is Message & {
1818
+ attachments: MessageAttachment[];
1819
+ };
1820
+ /**
1821
+ * Type guard to check if a message has a quick reply
1822
+ *
1823
+ * @param message - The message to check
1824
+ * @returns True if the message has a quick reply
1825
+ */
1826
+ declare function hasQuickReply(message: Message): message is Message & {
1827
+ quick_reply: QuickReply;
1828
+ };
1829
+ /**
1830
+ * Type guard to check if a message is a reply to another message
1831
+ *
1832
+ * @param message - The message to check
1833
+ * @returns True if the message is a reply
1834
+ */
1835
+ declare function isReplyMessage(message: Message): message is Message & {
1836
+ reply_to: ReplyTo;
1837
+ };
1838
+ /**
1839
+ * Type guard to check if a message has referral data
1840
+ *
1841
+ * @param message - The message to check
1842
+ * @returns True if the message has referral data
1843
+ */
1844
+ declare function hasReferral(message: Message): message is Message & {
1845
+ referral: MessageReferral;
1846
+ };
1847
+ /**
1848
+ * Type guard to check if an attachment is a specific type
1849
+ *
1850
+ * @param attachment - The attachment to check
1851
+ * @param type - The attachment type to check for
1852
+ * @returns True if the attachment is of the specified type
1853
+ */
1854
+ declare function isAttachmentType<T extends AttachmentType>(attachment: MessageAttachment, type: T): attachment is MessageAttachment & {
1855
+ type: T;
1856
+ };
1857
+ /**
1858
+ * Utility type for common message properties that might be used in processing
1859
+ */
1860
+ interface MessageProcessingContext extends BaseProcessingContext {
1861
+ /** The message ID */
1862
+ messageId: string;
1863
+ /** Message text content, if available */
1864
+ text?: string;
1865
+ /** Whether the message has attachments */
1866
+ hasAttachments: boolean;
1867
+ /** Whether the message is a quick reply */
1868
+ isQuickReply: boolean;
1869
+ /** Whether the message is a reply to another message */
1870
+ isReply: boolean;
1871
+ /** Whether the message has referral data */
1872
+ hasReferral: boolean;
1873
+ /** Quick reply payload, if available */
1874
+ quickReplyPayload?: string;
1875
+ /** Replied message ID, if this is a reply */
1876
+ repliedToMessageId?: string;
1877
+ }
1878
+ /**
1879
+ * Helper function to extract processing context from a message event
1880
+ *
1881
+ * @param event - The message webhook event
1882
+ * @returns Simplified processing context
1883
+ *
1884
+ * @example
1885
+ * ```typescript
1886
+ * const context = extractMessageContext(webhookEvent);
1887
+ * console.log(`User ${context.senderId} sent: "${context.text || '[attachment]'}"`);
1888
+ * if (context.isQuickReply) {
1889
+ * console.log(`Quick reply payload: ${context.quickReplyPayload}`);
1890
+ * }
1891
+ * ```
1892
+ */
1893
+ declare function extractMessageContext(event: MessageWebhookEvent): MessageProcessingContext;
1894
+ /**
1895
+ * Helper function to get attachments of a specific type from a message
1896
+ *
1897
+ * @param message - The message to extract attachments from
1898
+ * @param type - The attachment type to filter by
1899
+ * @returns Array of attachments of the specified type
1900
+ *
1901
+ * @example
1902
+ * ```typescript
1903
+ * const images = getAttachmentsByType(message, AttachmentType.IMAGE);
1904
+ * console.log(`Message contains ${images.length} image(s)`);
1905
+ * ```
1906
+ */
1907
+ declare function getAttachmentsByType<T extends AttachmentType>(message: Message, type: T): Array<MessageAttachment & {
1908
+ type: T;
1909
+ }>;
1910
+ /**
1911
+ * Helper function to extract all URLs from message attachments
1912
+ *
1913
+ * @param message - The message to extract URLs from
1914
+ * @returns Array of attachment URLs
1915
+ *
1916
+ * @example
1917
+ * ```typescript
1918
+ * const urls = getAttachmentUrls(message);
1919
+ * console.log(`Message contains ${urls.length} attachment(s)`);
1920
+ * ```
1921
+ */
1922
+ declare function getAttachmentUrls(message: Message): string[];
1923
+ /**
1924
+ * Constants related to message limits and constraints
1925
+ */
1926
+ declare const MESSAGE_CONSTANTS: {
1927
+ /** Maximum length of message text */
1928
+ readonly MAX_TEXT_LENGTH: 2000;
1929
+ /** Maximum length of quick reply payload */
1930
+ readonly MAX_QUICK_REPLY_PAYLOAD_LENGTH: 1000;
1931
+ /** Maximum length of referral ref parameter */
1932
+ readonly MAX_REFERRAL_REF_LENGTH: 250;
1933
+ /** Webhook event type identifier */
1934
+ readonly EVENT_TYPE: "message";
1935
+ };
1936
+ /**
1937
+ * Common attachment MIME types for validation
1938
+ */
1939
+ declare const ATTACHMENT_MIME_TYPES: {
1940
+ readonly image: readonly ["image/jpeg", "image/png", "image/gif", "image/webp"];
1941
+ readonly video: readonly ["video/mp4", "video/avi", "video/quicktime", "video/webm"];
1942
+ readonly audio: readonly ["audio/mpeg", "audio/mp4", "audio/wav", "audio/ogg"];
1943
+ readonly file: readonly ["application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain"];
1944
+ };
1945
+
1946
+ /**
1947
+ * Facebook Messenger Webhook Events - Main Entry Point
1948
+ *
1949
+ * This file provides the unified type system for all webhook events supported
1950
+ * by the Messenger Platform. It uses discriminated unions with proper type
1951
+ * narrowing to ensure type safety.
1952
+ *
1953
+ * @module webhooks/webhook-events
1954
+ */
1955
+
1956
+ /**
1957
+ * Discriminated union type of all possible webhook events.
1958
+ * Each event has a 'type' field that allows TypeScript to narrow the type.
1959
+ */
1960
+ type MessengerWebhookEvent = MessageEditWebhookEvent | MessageReactionWebhookEvent | MessageWebhookEvent | MessageReadsWebhookEvent | MessagingFeedbackWebhookEvent | MessagingPostbackWebhookEvent;
1961
+ /**
1962
+ * Union type of all possible webhook payloads
1963
+ */
1964
+ type MessengerWebhookPayload = MessageEditWebhookPayload | MessageReactionWebhookPayload | MessageWebhookPayload | MessageReadsWebhookPayload | MessagingFeedbackWebhookPayload | MessagingPostbackWebhookPayload;
1965
+ /**
1966
+ * Type guard to check webhook event type for a SINGLE event.
1967
+ * This function now properly handles individual events from the messaging array.
1968
+ *
1969
+ * @param event - A single webhook event from the messaging array
1970
+ * @returns The event type or null if unknown
1971
+ *
1972
+ * @example
1973
+ * ```typescript
1974
+ * const events = extractWebhookEvents(payload);
1975
+ * for (const event of events) {
1976
+ * const eventType = getWebhookEventType(event);
1977
+ * console.log(`Event type: ${eventType}`);
1978
+ * }
1979
+ * ```
1980
+ */
1981
+ declare function getWebhookEventType(event: MessengerWebhookEvent | any): WebhookEventType | null;
1982
+ /**
1983
+ * Extract all events from a webhook payload.
1984
+ * This properly extracts individual events from the nested structure.
1985
+ *
1986
+ * @param payload - The complete webhook payload
1987
+ * @returns Array of individual webhook events
1988
+ *
1989
+ * @example
1990
+ * ```typescript
1991
+ * const events = extractWebhookEvents(payload);
1992
+ * events.forEach(event => {
1993
+ * const type = getWebhookEventType(event);
1994
+ * console.log(`Processing ${type} event`);
1995
+ * });
1996
+ * ```
1997
+ */
1998
+ declare function extractWebhookEvents(payload: WebhookPayload): MessengerWebhookEvent[];
1999
+ /**
2000
+ * Process webhook events by type with proper type narrowing.
2001
+ * This uses the discriminated union for automatic type narrowing.
2002
+ *
2003
+ * @param payload - The complete webhook payload
2004
+ * @param handlers - Object with handler functions for each event type
2005
+ *
2006
+ * @example
2007
+ * ```typescript
2008
+ * processWebhookEvents(payload, {
2009
+ * onMessage: async (event) => {
2010
+ * // TypeScript knows event is MessageWebhookEvent
2011
+ * console.log(`Message: ${event.message.text}`);
2012
+ * },
2013
+ * onMessageEdit: async (event) => {
2014
+ * // TypeScript knows event is MessageEditWebhookEvent
2015
+ * console.log(`Edited to: ${event.message_edit.text}`);
2016
+ * }
2017
+ * });
2018
+ * ```
2019
+ */
2020
+ interface WebhookEventHandlers {
2021
+ onMessage?: (event: MessageWebhookEvent) => void | Promise<void>;
2022
+ onMessageEdit?: (event: MessageEditWebhookEvent) => void | Promise<void>;
2023
+ onMessageReaction?: (event: MessageReactionWebhookEvent) => void | Promise<void>;
2024
+ onMessageRead?: (event: MessageReadsWebhookEvent) => void | Promise<void>;
2025
+ onMessagingFeedback?: (event: MessagingFeedbackWebhookEvent) => void | Promise<void>;
2026
+ onMessagingPostback?: (event: MessagingPostbackWebhookEvent) => void | Promise<void>;
2027
+ onUnknown?: (event: any) => void | Promise<void>;
2028
+ }
2029
+ declare function processWebhookEvents(payload: WebhookPayload, handlers: WebhookEventHandlers): Promise<void>;
2030
+ /**
2031
+ * Webhook verification parameters for subscription verification
2032
+ */
2033
+ interface WebhookVerificationParams {
2034
+ 'hub.mode': string;
2035
+ 'hub.verify_token': string;
2036
+ 'hub.challenge': string;
2037
+ }
2038
+ /**
2039
+ * Verify webhook subscription during initial setup
2040
+ *
2041
+ * @param params - Query parameters from Facebook's verification request
2042
+ * @param verifyToken - Your webhook verify token
2043
+ * @returns The challenge string if valid, null if invalid
2044
+ *
2045
+ * @example
2046
+ * ```typescript
2047
+ * app.get('/webhook', (req, res) => {
2048
+ * const challenge = verifyWebhookSubscription(req.query, process.env.VERIFY_TOKEN);
2049
+ * if (challenge) {
2050
+ * res.send(challenge);
2051
+ * } else {
2052
+ * res.status(403).send('Forbidden');
2053
+ * }
2054
+ * });
2055
+ * ```
2056
+ */
2057
+ declare function verifyWebhookSubscription(params: WebhookVerificationParams, verifyToken: string): string | null;
2058
+
338
2059
  declare class MessengerAPIError extends Error {
339
2060
  readonly code: number;
340
2061
  readonly type: string;
@@ -385,4 +2106,4 @@ declare const TEMPLATE_LIMITS: {
385
2106
  readonly MEDIA_BUTTONS_MAX_COUNT: 3;
386
2107
  };
387
2108
 
388
- export { ATTACHMENT_LIMITS, type AttachmentType, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsAPI, type Button, type ButtonTemplatePayload, type DefaultAction, type ErrorResponse, type GenericTemplateElement, type GenericTemplatePayload, type GetProfileRequest, MESSAGE_LIMITS, type MediaTemplateElement, type MediaTemplatePayload, type Message, MessageValidationError, type MessagingType, Messenger, MessengerAPIError, type MessengerConfig, MessengerConfigError, type MessengerError, MessengerNetworkError, MessengerTimeoutError, type ModerateConversationsRequest, type ModerateConversationsResponse, ModerationAPI, type ModerationAction, type ProductTemplateElement, type ProductTemplatePayload, ProfileAPI, type ProfileField, type QuickReply, type Recipient, SendAPI, type SendMessageRequest, type SendMessageResponse, type SenderAction, TEMPLATE_LIMITS, TemplateValidationError, TemplatesAPI, type UserId, type UserProfile };
2109
+ export { ATTACHMENT_LIMITS, ATTACHMENT_MIME_TYPES, type AttachmentPayload, type AttachmentType$1 as AttachmentType, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsAPI, type Button, type ButtonTemplatePayload, CESDisplayOption, COMMON_POSTBACK_PAYLOADS, CSATDisplayOption, type DefaultAction, type ErrorResponse, type FallbackAttachmentPayload, type FeedbackFollowUp, type FeedbackQuestion, type FeedbackScreen, FeedbackType, FollowUpType, type GenericTemplateElement, type GenericTemplatePayload, type WebhookPayload as GenericWebhookPayload, type GetProfileRequest, MESSAGE_CONSTANTS, MESSAGE_EDIT_CONSTANTS, MESSAGE_LIMITS, MESSAGE_READS_CONSTANTS, MESSAGING_FEEDBACK_CONSTANTS, type MediaAttachmentPayload, type MediaTemplateElement, type MediaTemplatePayload, type Message$1 as Message, type MessageAttachment, type MessageCommand, type MessageEdit, type MessageEditProcessingContext, type WebhookRecipient as MessageEditRecipient, type WebhookSender as MessageEditSender, type MessageEditWebhookEvent, type MessageEditWebhookPayload, type MessageProcessingContext, MessageReactionAction, type MessageReactionData, type MessageReactionProcessingContext, type WebhookRecipient as MessageReactionRecipient, type WebhookSender as MessageReactionSender, type MessageReactionStats, MessageReactionType, type MessageReactionWebhookConfig, type MessageReactionWebhookEvent, type MessageReactionWebhookPayload, type MessageReadData, type MessageReadsProcessingContext, type MessageReadsWebhookEvent, type MessageReadsWebhookPayload, type WebhookRecipient as MessageRecipient, type MessageReferral, ReferralSource as MessageReferralSource, ReferralType as MessageReferralType, type WebhookSender as MessageSender, MessageValidationError, type MessageWebhookEvent, type MessageWebhookPayload, type MessagingFeedbackData, type MessagingFeedbackProcessingContext, type MessagingFeedbackWebhookEvent, type MessagingFeedbackWebhookPayload, type MessagingPostbackWebhookEvent, type MessagingPostbackWebhookPayload, type MessagingType, Messenger, MessengerAPIError, type MessengerConfig, MessengerConfigError, type MessengerError, MessengerNetworkError, MessengerTimeoutError, type MessengerWebhookEvent, type MessengerWebhookPayload, type ModerateConversationsRequest, type ModerateConversationsResponse, ModerationAPI, type ModerationAction, NPSDisplayOption, POSTBACK_CONSTANTS, type PostbackData, type PostbackEventData, type PostbackPayload, type PostbackProcessingContext, type WebhookRecipient as PostbackRecipient, type PostbackReferral, type WebhookSender as PostbackSender, type ProductTemplateElement, type ProductTemplatePayload, ProfileAPI, type ProfileField, type QuickReply$1 as QuickReply, type Recipient, type ReelAttachmentPayload, type ReferralSource$1 as ReferralSource, type ReferralType$1 as ReferralType, type ReplyTo, SendAPI, type SendMessageRequest, type SendMessageResponse, type SenderAction, type StickerAttachmentPayload, TEMPLATE_LIMITS, TemplateValidationError, TemplatesAPI, type UserId, type UserProfile, type WatermarkTimestamp, AttachmentType as WebhookAttachmentType, type WebhookEntry, type WebhookEventHandlers, WebhookEventType, type Message as WebhookMessage, type QuickReply as WebhookQuickReply, type WebhookVerificationParams, extractMessageContext, extractMessageEditContext, extractMessageReadsContext, extractMessagingFeedbackContext, extractPostbackContext, extractTextFeedback, extractWebhookEvents, getAttachmentUrls, getAttachmentsByType, getFeedbackScoresByType, getReadMessageCount, getReadMessages, getWebhookEventType, hasAttachments, hasQuickReply, hasReferral, hasReferralData, isAttachmentType, isIdentifiedSender, isMessageEditEvent, isMessageEvent, isMessageRead, isMessageReadsEvent, isMessagingFeedbackEvent, isMessagingPostbackEvent, isReplyMessage, isTextMessage, isValidFeedbackScore, isValidQuestionId, isValidTextFeedback, processWebhookEvents, verifyWebhookSubscription };