Skip to content

Commit

Permalink
fix(node): Fixing chat missing in events interface (#5661)
Browse files Browse the repository at this point in the history
* adding chat to overrides interface

* feat(providers): adding mobishastra sms provider

* fix(node): remove code unrelated to fix

* fix(node): Add missing 'chat' property to ITriggerOverrides interface

* fix(events): Add 'whatsapp' property to ITriggerOverrides interface

* refactor(events): Update IWhatsappOverrides interface to use IWhatsappComponent type
  • Loading branch information
ameensom authored Jun 12, 2024
1 parent 1ec4aed commit 531d62b
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
99 changes: 99 additions & 0 deletions packages/node/src/lib/events/events.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export type ITriggerOverrides = {
[key in 'sms']?: ITriggerOverrideSMS;
} & {
[key in SmsProviderIdEnum]?: ITriggerOverrideSMS;
} & {
[key in 'whatsapp']?: IWhatsappOverrides;
};

export type ITriggerOverrideDelayAction = {
Expand Down Expand Up @@ -154,6 +156,103 @@ export type ITriggerOverrideExpo = {
mutableContent?: boolean;
};

export type IWhatsappOverrides = {
template?: {
name: string;
language: {
code: string;
};
components?: IWhatsappComponent[];
};
} & {
[key in
| 'audio'
| 'document'
| 'image'
| 'sticker'
| 'video']?: IWhatsappMedia;
} & {
interactive?: {
type:
| 'button'
| 'catalog_message'
| 'list'
| 'product'
| 'product_list'
| 'flow';
action: {
button?: string;
buttons?: {
type: 'reply';
title: string;
id: string;
}[];
catalog_id?: string;
product_retailer_id?: string;
sections?: IWhatsappSections[];
mode?: 'draft' | 'published';
flow_message_version?: '3';
flow_token?: string;
flow_id?: string;
flow_cta?: string;
flow_action?: string;
flow_action_payload?: {
screen: string;
data?: {
[key: string]: string;
};
};
};
header?: {
type: 'text' | 'image' | 'video' | 'document';
document?: IWhatsappMedia;
image?: IWhatsappMedia;
text?: string;
video?: IWhatsappMedia;
};
body?: {
text: string;
};
footer?: {
text: string;
};
};
};

export type IWhatsappMedia = {
id?: string;
link?: string;
caption?: string;
filename?: string;
};

export interface IWhatsappSections {
product_items?: { product_retailer_id: string }[];
rows?: { id: string; title: string; description: string }[];
title?: string;
}

export interface IWhatsappComponent {
type: 'body' | 'header' | 'button';
sub_type?: 'quick_reply' | 'url' | 'catalog';
parameters: {
type: 'currency' | 'date_time' | 'document' | 'image' | 'text' | 'video';
text?: string;
currency?: {
fallback_value: string;
code: string;
amount_1000: number;
};
date_time?: {
fallback_value: string;
};
image?: IWhatsappMedia;
document?: IWhatsappMedia;
video?: IWhatsappMedia;
}[];
index?: number;
}

export interface IBulkEvents extends ITriggerPayloadOptions {
name: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
export enum WhatsAppMessageTypeEnum {
TEMPLATE = 'template',
TEXT = 'text',
INTERACTIVE = 'interactive',
IMAGE = 'image',
DOCUMENT = 'document',
VIDEO = 'video',
AUDIO = 'audio',
LOCATION = 'location',
CONTACTS = 'contacts',
STICKER = 'sticker',
}

0 comments on commit 531d62b

Please sign in to comment.