@semboja/connect 0.2.2 → 0.3.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.mts +162 -7
- package/dist/index.d.ts +162 -7
- package/dist/index.js +92 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -310,7 +310,7 @@ interface InteractiveListSection {
|
|
|
310
310
|
}>;
|
|
311
311
|
}
|
|
312
312
|
interface InteractiveMessage {
|
|
313
|
-
type: 'button' | 'list' | 'product' | 'product_list';
|
|
313
|
+
type: 'button' | 'list' | 'product' | 'product_list' | 'flow';
|
|
314
314
|
header?: {
|
|
315
315
|
type: 'text' | 'image' | 'video' | 'document';
|
|
316
316
|
text?: string;
|
|
@@ -325,17 +325,76 @@ interface InteractiveMessage {
|
|
|
325
325
|
text: string;
|
|
326
326
|
};
|
|
327
327
|
action: {
|
|
328
|
+
/** Button text for list messages */
|
|
328
329
|
button?: string;
|
|
330
|
+
/** Reply buttons (for button type) */
|
|
329
331
|
buttons?: InteractiveButton[];
|
|
332
|
+
/** List sections (for list type) */
|
|
330
333
|
sections?: InteractiveListSection[];
|
|
334
|
+
/** Flow action name (for flow type) */
|
|
335
|
+
name?: 'flow';
|
|
336
|
+
/** Flow parameters (for flow type) */
|
|
337
|
+
parameters?: FlowActionParameters;
|
|
331
338
|
};
|
|
332
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Parameters for WhatsApp Flow interactive messages
|
|
342
|
+
*/
|
|
343
|
+
interface FlowActionParameters {
|
|
344
|
+
/** Flow message version (must be "3") */
|
|
345
|
+
flow_message_version: '3';
|
|
346
|
+
/** The Flow ID from WhatsApp Business Manager */
|
|
347
|
+
flow_id: string;
|
|
348
|
+
/** Text displayed on the CTA button (max ~30 chars, no emoji) */
|
|
349
|
+
flow_cta: string;
|
|
350
|
+
/** Token to identify this flow session (returned in nfm_reply webhook) */
|
|
351
|
+
flow_token?: string;
|
|
352
|
+
/** How the flow starts: navigate to a screen or call the endpoint */
|
|
353
|
+
flow_action?: 'navigate' | 'data_exchange';
|
|
354
|
+
/** Initial screen and data when flow_action is 'navigate' */
|
|
355
|
+
flow_action_payload?: {
|
|
356
|
+
/** Screen name to navigate to */
|
|
357
|
+
screen: string;
|
|
358
|
+
/** Data to pass to the screen */
|
|
359
|
+
data?: Record<string, unknown>;
|
|
360
|
+
};
|
|
361
|
+
/** Use 'draft' to test unpublished flows */
|
|
362
|
+
mode?: 'draft' | 'published';
|
|
363
|
+
}
|
|
333
364
|
interface SendInteractiveOptions extends SendMessageOptions {
|
|
334
365
|
/** Interactive message configuration */
|
|
335
366
|
interactive: InteractiveMessage;
|
|
336
367
|
/** Message ID to reply to */
|
|
337
368
|
replyTo?: string;
|
|
338
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Options for sending a WhatsApp Flow message.
|
|
372
|
+
* Convenience type that enforces flow-specific interactive message shape.
|
|
373
|
+
*/
|
|
374
|
+
interface SendFlowOptions extends SendMessageOptions {
|
|
375
|
+
/** Flow message body text */
|
|
376
|
+
body: string;
|
|
377
|
+
/** Optional header text */
|
|
378
|
+
header?: string;
|
|
379
|
+
/** Optional footer text */
|
|
380
|
+
footer?: string;
|
|
381
|
+
/** The Flow ID from WhatsApp Business Manager */
|
|
382
|
+
flowId: string;
|
|
383
|
+
/** Text displayed on the CTA button (max ~30 chars, no emoji) */
|
|
384
|
+
flowCta: string;
|
|
385
|
+
/** Token to identify this flow session (returned in nfm_reply webhook) */
|
|
386
|
+
flowToken?: string;
|
|
387
|
+
/** How the flow starts: navigate to a screen or call the endpoint (default: navigate) */
|
|
388
|
+
flowAction?: 'navigate' | 'data_exchange';
|
|
389
|
+
/** Initial screen name (required when flowAction is 'navigate') */
|
|
390
|
+
screen?: string;
|
|
391
|
+
/** Initial data to pass to the screen */
|
|
392
|
+
screenData?: Record<string, unknown>;
|
|
393
|
+
/** Use 'draft' to test unpublished flows (default: published) */
|
|
394
|
+
mode?: 'draft' | 'published';
|
|
395
|
+
/** Message ID to reply to */
|
|
396
|
+
replyTo?: string;
|
|
397
|
+
}
|
|
339
398
|
interface MessageContact {
|
|
340
399
|
input: string;
|
|
341
400
|
wa_id: string;
|
|
@@ -370,18 +429,18 @@ interface MetaPhoneNumberInfo {
|
|
|
370
429
|
id: string;
|
|
371
430
|
verified_name: string;
|
|
372
431
|
display_phone_number: string;
|
|
373
|
-
quality_rating:
|
|
374
|
-
code_verification_status:
|
|
432
|
+
quality_rating: 'GREEN' | 'YELLOW' | 'RED' | 'UNKNOWN';
|
|
433
|
+
code_verification_status: 'VERIFIED' | 'NOT_VERIFIED' | 'EXPIRED';
|
|
375
434
|
is_official_business_account: boolean;
|
|
376
435
|
is_pin_enabled: boolean;
|
|
377
|
-
name_status:
|
|
378
|
-
new_name_status?:
|
|
436
|
+
name_status: 'APPROVED' | 'PENDING' | 'DECLINED' | 'NONE';
|
|
437
|
+
new_name_status?: 'APPROVED' | 'PENDING' | 'DECLINED' | 'NONE';
|
|
379
438
|
messaging_limit_tier?: string;
|
|
380
439
|
platform_type?: string;
|
|
381
440
|
throughput?: {
|
|
382
441
|
level: string;
|
|
383
442
|
};
|
|
384
|
-
account_mode?:
|
|
443
|
+
account_mode?: 'LIVE' | 'SANDBOX';
|
|
385
444
|
}
|
|
386
445
|
/** Business profile from Meta Graph API */
|
|
387
446
|
interface MetaBusinessProfile {
|
|
@@ -432,6 +491,43 @@ interface VerifyWebhookOptions {
|
|
|
432
491
|
/** Your webhook secret */
|
|
433
492
|
secret: string;
|
|
434
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* Interactive reply data from an incoming webhook message.
|
|
496
|
+
* Covers button_reply, list_reply, and nfm_reply (WhatsApp Flows).
|
|
497
|
+
*/
|
|
498
|
+
interface WebhookInteractiveReply {
|
|
499
|
+
type: 'button_reply' | 'list_reply' | 'nfm_reply';
|
|
500
|
+
/** Button reply data (when type is 'button_reply') */
|
|
501
|
+
button_reply?: {
|
|
502
|
+
id: string;
|
|
503
|
+
title: string;
|
|
504
|
+
};
|
|
505
|
+
/** List reply data (when type is 'list_reply') */
|
|
506
|
+
list_reply?: {
|
|
507
|
+
id: string;
|
|
508
|
+
title: string;
|
|
509
|
+
description?: string;
|
|
510
|
+
};
|
|
511
|
+
/** Flow reply data (when type is 'nfm_reply') */
|
|
512
|
+
nfm_reply?: {
|
|
513
|
+
/** Stringified JSON containing flow_token and all collected data */
|
|
514
|
+
response_json: string;
|
|
515
|
+
/** Display body text (usually "Sent") */
|
|
516
|
+
body: string;
|
|
517
|
+
/** Flow name identifier */
|
|
518
|
+
name: string;
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Parsed flow response data from an nfm_reply webhook message.
|
|
523
|
+
* The response_json string parsed into a typed object.
|
|
524
|
+
*/
|
|
525
|
+
interface FlowResponseData {
|
|
526
|
+
/** The flow_token that was passed when sending the flow */
|
|
527
|
+
flow_token: string;
|
|
528
|
+
/** All key-value pairs collected by the flow screens */
|
|
529
|
+
[key: string]: unknown;
|
|
530
|
+
}
|
|
435
531
|
|
|
436
532
|
/**
|
|
437
533
|
* Messages API resource
|
|
@@ -673,6 +769,42 @@ declare class Messages {
|
|
|
673
769
|
* ```
|
|
674
770
|
*/
|
|
675
771
|
sendContacts(options: SendContactsOptions): Promise<ApiResponse<MessageResponseData>>;
|
|
772
|
+
/**
|
|
773
|
+
* Send a WhatsApp Flow message
|
|
774
|
+
*
|
|
775
|
+
* WhatsApp Flows allow you to create structured, multi-screen forms
|
|
776
|
+
* that run entirely inside WhatsApp. The flow must be registered via
|
|
777
|
+
* the Meta Business Manager before sending.
|
|
778
|
+
*
|
|
779
|
+
* @param options - Flow message options
|
|
780
|
+
* @returns Message response with message ID
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* ```typescript
|
|
784
|
+
* // Send a flow with navigate action (most common)
|
|
785
|
+
* await client.messages.sendFlow({
|
|
786
|
+
* phoneNumberId: '123456789',
|
|
787
|
+
* to: '+6281234567890',
|
|
788
|
+
* body: 'Please fill in your company details',
|
|
789
|
+
* flowId: '1234567890',
|
|
790
|
+
* flowCta: 'Start Form',
|
|
791
|
+
* flowToken: 'session_abc123',
|
|
792
|
+
* flowAction: 'navigate',
|
|
793
|
+
* screen: 'COMPANY_NAME',
|
|
794
|
+
* });
|
|
795
|
+
*
|
|
796
|
+
* // Send a draft flow for testing
|
|
797
|
+
* await client.messages.sendFlow({
|
|
798
|
+
* phoneNumberId: '123456789',
|
|
799
|
+
* to: '+6281234567890',
|
|
800
|
+
* body: 'Test flow',
|
|
801
|
+
* flowId: '1234567890',
|
|
802
|
+
* flowCta: 'Open',
|
|
803
|
+
* mode: 'draft',
|
|
804
|
+
* });
|
|
805
|
+
* ```
|
|
806
|
+
*/
|
|
807
|
+
sendFlow(options: SendFlowOptions): Promise<ApiResponse<MessageResponseData>>;
|
|
676
808
|
/**
|
|
677
809
|
* Mark a message as read
|
|
678
810
|
*
|
|
@@ -996,6 +1128,29 @@ declare function verifyWebhookSignature(options: VerifyWebhookOptions): boolean;
|
|
|
996
1128
|
* @returns Parsed webhook event
|
|
997
1129
|
*/
|
|
998
1130
|
declare function parseWebhookPayload<T = unknown>(payload: string | object): T;
|
|
1131
|
+
/**
|
|
1132
|
+
* Parse the response_json string from a WhatsApp Flow nfm_reply webhook.
|
|
1133
|
+
*
|
|
1134
|
+
* When a user completes a WhatsApp Flow, the webhook delivers an interactive
|
|
1135
|
+
* message with type 'nfm_reply'. The `response_json` field contains a stringified
|
|
1136
|
+
* JSON object with the `flow_token` and all data collected by the flow screens.
|
|
1137
|
+
*
|
|
1138
|
+
* @param responseJson - The response_json string from nfm_reply
|
|
1139
|
+
* @returns Parsed flow response data including flow_token and collected fields
|
|
1140
|
+
*
|
|
1141
|
+
* @example
|
|
1142
|
+
* ```typescript
|
|
1143
|
+
* import { parseFlowResponse } from '@semboja/connect';
|
|
1144
|
+
*
|
|
1145
|
+
* // In your webhook handler:
|
|
1146
|
+
* if (message.interactive?.type === 'nfm_reply') {
|
|
1147
|
+
* const flowData = parseFlowResponse(message.interactive.nfm_reply.response_json);
|
|
1148
|
+
* console.log('Flow token:', flowData.flow_token);
|
|
1149
|
+
* console.log('Company name:', flowData.company_name);
|
|
1150
|
+
* }
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
declare function parseFlowResponse(responseJson: string): FlowResponseData;
|
|
999
1154
|
|
|
1000
1155
|
/**
|
|
1001
1156
|
* Base error class for all Semboja API errors
|
|
@@ -1080,4 +1235,4 @@ declare class NetworkError extends SembojaError {
|
|
|
1080
1235
|
* @packageDocumentation
|
|
1081
1236
|
*/
|
|
1082
1237
|
|
|
1083
|
-
export { type ApiErrorResponse, type ApiResponse, AuthenticationError, type ClientOptions, type Contact, type ContactAddress, type ContactEmail, type ContactName, type ContactOrg, type ContactPhone, type ContactUrl, type InteractiveButton, type InteractiveListSection, type InteractiveMessage, type ListTemplatesOptions, type LocationObject, type MarkAsReadOptions, type MarkAsReadResponseData, type MediaObject, type MessageContact, type MessageResponseData, type MessageResult, type MessageType, type MetaBusinessProfile, type MetaPhoneNumberInfo, NetworkError, NotFoundError, type PhoneNumber, type PhoneNumberProfile, RateLimitError, SembojaClient, SembojaError, type SendAudioOptions, type SendContactsOptions, type SendDocumentOptions, type SendImageOptions, type SendInteractiveOptions, type SendLocationOptions, type SendMessageOptions, type SendReactionOptions, type SendStickerOptions, type SendTemplateOptions, type SendTextOptions, type SendVideoOptions, ServerError, type StickerObject, type Template, type TemplateComponent, type TemplateInfo, type TemplateLanguage, type TemplateParameter, type TemplateStatus, type TriggerWebhookOptions, type UsageData, type UsageMessages, type UsagePeriod, ValidationError, type VerifyWebhookOptions, SembojaClient as default, parseWebhookPayload, verifyWebhookSignature };
|
|
1238
|
+
export { type ApiErrorResponse, type ApiResponse, AuthenticationError, type ClientOptions, type Contact, type ContactAddress, type ContactEmail, type ContactName, type ContactOrg, type ContactPhone, type ContactUrl, type FlowActionParameters, type FlowResponseData, type InteractiveButton, type InteractiveListSection, type InteractiveMessage, type ListTemplatesOptions, type LocationObject, type MarkAsReadOptions, type MarkAsReadResponseData, type MediaObject, type MessageContact, type MessageResponseData, type MessageResult, type MessageType, type MetaBusinessProfile, type MetaPhoneNumberInfo, NetworkError, NotFoundError, type PhoneNumber, type PhoneNumberProfile, RateLimitError, SembojaClient, SembojaError, type SendAudioOptions, type SendContactsOptions, type SendDocumentOptions, type SendFlowOptions, type SendImageOptions, type SendInteractiveOptions, type SendLocationOptions, type SendMessageOptions, type SendReactionOptions, type SendStickerOptions, type SendTemplateOptions, type SendTextOptions, type SendVideoOptions, ServerError, type StickerObject, type Template, type TemplateComponent, type TemplateInfo, type TemplateLanguage, type TemplateParameter, type TemplateStatus, type TriggerWebhookOptions, type UsageData, type UsageMessages, type UsagePeriod, ValidationError, type VerifyWebhookOptions, type WebhookInteractiveReply, SembojaClient as default, parseFlowResponse, parseWebhookPayload, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -310,7 +310,7 @@ interface InteractiveListSection {
|
|
|
310
310
|
}>;
|
|
311
311
|
}
|
|
312
312
|
interface InteractiveMessage {
|
|
313
|
-
type: 'button' | 'list' | 'product' | 'product_list';
|
|
313
|
+
type: 'button' | 'list' | 'product' | 'product_list' | 'flow';
|
|
314
314
|
header?: {
|
|
315
315
|
type: 'text' | 'image' | 'video' | 'document';
|
|
316
316
|
text?: string;
|
|
@@ -325,17 +325,76 @@ interface InteractiveMessage {
|
|
|
325
325
|
text: string;
|
|
326
326
|
};
|
|
327
327
|
action: {
|
|
328
|
+
/** Button text for list messages */
|
|
328
329
|
button?: string;
|
|
330
|
+
/** Reply buttons (for button type) */
|
|
329
331
|
buttons?: InteractiveButton[];
|
|
332
|
+
/** List sections (for list type) */
|
|
330
333
|
sections?: InteractiveListSection[];
|
|
334
|
+
/** Flow action name (for flow type) */
|
|
335
|
+
name?: 'flow';
|
|
336
|
+
/** Flow parameters (for flow type) */
|
|
337
|
+
parameters?: FlowActionParameters;
|
|
331
338
|
};
|
|
332
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Parameters for WhatsApp Flow interactive messages
|
|
342
|
+
*/
|
|
343
|
+
interface FlowActionParameters {
|
|
344
|
+
/** Flow message version (must be "3") */
|
|
345
|
+
flow_message_version: '3';
|
|
346
|
+
/** The Flow ID from WhatsApp Business Manager */
|
|
347
|
+
flow_id: string;
|
|
348
|
+
/** Text displayed on the CTA button (max ~30 chars, no emoji) */
|
|
349
|
+
flow_cta: string;
|
|
350
|
+
/** Token to identify this flow session (returned in nfm_reply webhook) */
|
|
351
|
+
flow_token?: string;
|
|
352
|
+
/** How the flow starts: navigate to a screen or call the endpoint */
|
|
353
|
+
flow_action?: 'navigate' | 'data_exchange';
|
|
354
|
+
/** Initial screen and data when flow_action is 'navigate' */
|
|
355
|
+
flow_action_payload?: {
|
|
356
|
+
/** Screen name to navigate to */
|
|
357
|
+
screen: string;
|
|
358
|
+
/** Data to pass to the screen */
|
|
359
|
+
data?: Record<string, unknown>;
|
|
360
|
+
};
|
|
361
|
+
/** Use 'draft' to test unpublished flows */
|
|
362
|
+
mode?: 'draft' | 'published';
|
|
363
|
+
}
|
|
333
364
|
interface SendInteractiveOptions extends SendMessageOptions {
|
|
334
365
|
/** Interactive message configuration */
|
|
335
366
|
interactive: InteractiveMessage;
|
|
336
367
|
/** Message ID to reply to */
|
|
337
368
|
replyTo?: string;
|
|
338
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Options for sending a WhatsApp Flow message.
|
|
372
|
+
* Convenience type that enforces flow-specific interactive message shape.
|
|
373
|
+
*/
|
|
374
|
+
interface SendFlowOptions extends SendMessageOptions {
|
|
375
|
+
/** Flow message body text */
|
|
376
|
+
body: string;
|
|
377
|
+
/** Optional header text */
|
|
378
|
+
header?: string;
|
|
379
|
+
/** Optional footer text */
|
|
380
|
+
footer?: string;
|
|
381
|
+
/** The Flow ID from WhatsApp Business Manager */
|
|
382
|
+
flowId: string;
|
|
383
|
+
/** Text displayed on the CTA button (max ~30 chars, no emoji) */
|
|
384
|
+
flowCta: string;
|
|
385
|
+
/** Token to identify this flow session (returned in nfm_reply webhook) */
|
|
386
|
+
flowToken?: string;
|
|
387
|
+
/** How the flow starts: navigate to a screen or call the endpoint (default: navigate) */
|
|
388
|
+
flowAction?: 'navigate' | 'data_exchange';
|
|
389
|
+
/** Initial screen name (required when flowAction is 'navigate') */
|
|
390
|
+
screen?: string;
|
|
391
|
+
/** Initial data to pass to the screen */
|
|
392
|
+
screenData?: Record<string, unknown>;
|
|
393
|
+
/** Use 'draft' to test unpublished flows (default: published) */
|
|
394
|
+
mode?: 'draft' | 'published';
|
|
395
|
+
/** Message ID to reply to */
|
|
396
|
+
replyTo?: string;
|
|
397
|
+
}
|
|
339
398
|
interface MessageContact {
|
|
340
399
|
input: string;
|
|
341
400
|
wa_id: string;
|
|
@@ -370,18 +429,18 @@ interface MetaPhoneNumberInfo {
|
|
|
370
429
|
id: string;
|
|
371
430
|
verified_name: string;
|
|
372
431
|
display_phone_number: string;
|
|
373
|
-
quality_rating:
|
|
374
|
-
code_verification_status:
|
|
432
|
+
quality_rating: 'GREEN' | 'YELLOW' | 'RED' | 'UNKNOWN';
|
|
433
|
+
code_verification_status: 'VERIFIED' | 'NOT_VERIFIED' | 'EXPIRED';
|
|
375
434
|
is_official_business_account: boolean;
|
|
376
435
|
is_pin_enabled: boolean;
|
|
377
|
-
name_status:
|
|
378
|
-
new_name_status?:
|
|
436
|
+
name_status: 'APPROVED' | 'PENDING' | 'DECLINED' | 'NONE';
|
|
437
|
+
new_name_status?: 'APPROVED' | 'PENDING' | 'DECLINED' | 'NONE';
|
|
379
438
|
messaging_limit_tier?: string;
|
|
380
439
|
platform_type?: string;
|
|
381
440
|
throughput?: {
|
|
382
441
|
level: string;
|
|
383
442
|
};
|
|
384
|
-
account_mode?:
|
|
443
|
+
account_mode?: 'LIVE' | 'SANDBOX';
|
|
385
444
|
}
|
|
386
445
|
/** Business profile from Meta Graph API */
|
|
387
446
|
interface MetaBusinessProfile {
|
|
@@ -432,6 +491,43 @@ interface VerifyWebhookOptions {
|
|
|
432
491
|
/** Your webhook secret */
|
|
433
492
|
secret: string;
|
|
434
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* Interactive reply data from an incoming webhook message.
|
|
496
|
+
* Covers button_reply, list_reply, and nfm_reply (WhatsApp Flows).
|
|
497
|
+
*/
|
|
498
|
+
interface WebhookInteractiveReply {
|
|
499
|
+
type: 'button_reply' | 'list_reply' | 'nfm_reply';
|
|
500
|
+
/** Button reply data (when type is 'button_reply') */
|
|
501
|
+
button_reply?: {
|
|
502
|
+
id: string;
|
|
503
|
+
title: string;
|
|
504
|
+
};
|
|
505
|
+
/** List reply data (when type is 'list_reply') */
|
|
506
|
+
list_reply?: {
|
|
507
|
+
id: string;
|
|
508
|
+
title: string;
|
|
509
|
+
description?: string;
|
|
510
|
+
};
|
|
511
|
+
/** Flow reply data (when type is 'nfm_reply') */
|
|
512
|
+
nfm_reply?: {
|
|
513
|
+
/** Stringified JSON containing flow_token and all collected data */
|
|
514
|
+
response_json: string;
|
|
515
|
+
/** Display body text (usually "Sent") */
|
|
516
|
+
body: string;
|
|
517
|
+
/** Flow name identifier */
|
|
518
|
+
name: string;
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Parsed flow response data from an nfm_reply webhook message.
|
|
523
|
+
* The response_json string parsed into a typed object.
|
|
524
|
+
*/
|
|
525
|
+
interface FlowResponseData {
|
|
526
|
+
/** The flow_token that was passed when sending the flow */
|
|
527
|
+
flow_token: string;
|
|
528
|
+
/** All key-value pairs collected by the flow screens */
|
|
529
|
+
[key: string]: unknown;
|
|
530
|
+
}
|
|
435
531
|
|
|
436
532
|
/**
|
|
437
533
|
* Messages API resource
|
|
@@ -673,6 +769,42 @@ declare class Messages {
|
|
|
673
769
|
* ```
|
|
674
770
|
*/
|
|
675
771
|
sendContacts(options: SendContactsOptions): Promise<ApiResponse<MessageResponseData>>;
|
|
772
|
+
/**
|
|
773
|
+
* Send a WhatsApp Flow message
|
|
774
|
+
*
|
|
775
|
+
* WhatsApp Flows allow you to create structured, multi-screen forms
|
|
776
|
+
* that run entirely inside WhatsApp. The flow must be registered via
|
|
777
|
+
* the Meta Business Manager before sending.
|
|
778
|
+
*
|
|
779
|
+
* @param options - Flow message options
|
|
780
|
+
* @returns Message response with message ID
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* ```typescript
|
|
784
|
+
* // Send a flow with navigate action (most common)
|
|
785
|
+
* await client.messages.sendFlow({
|
|
786
|
+
* phoneNumberId: '123456789',
|
|
787
|
+
* to: '+6281234567890',
|
|
788
|
+
* body: 'Please fill in your company details',
|
|
789
|
+
* flowId: '1234567890',
|
|
790
|
+
* flowCta: 'Start Form',
|
|
791
|
+
* flowToken: 'session_abc123',
|
|
792
|
+
* flowAction: 'navigate',
|
|
793
|
+
* screen: 'COMPANY_NAME',
|
|
794
|
+
* });
|
|
795
|
+
*
|
|
796
|
+
* // Send a draft flow for testing
|
|
797
|
+
* await client.messages.sendFlow({
|
|
798
|
+
* phoneNumberId: '123456789',
|
|
799
|
+
* to: '+6281234567890',
|
|
800
|
+
* body: 'Test flow',
|
|
801
|
+
* flowId: '1234567890',
|
|
802
|
+
* flowCta: 'Open',
|
|
803
|
+
* mode: 'draft',
|
|
804
|
+
* });
|
|
805
|
+
* ```
|
|
806
|
+
*/
|
|
807
|
+
sendFlow(options: SendFlowOptions): Promise<ApiResponse<MessageResponseData>>;
|
|
676
808
|
/**
|
|
677
809
|
* Mark a message as read
|
|
678
810
|
*
|
|
@@ -996,6 +1128,29 @@ declare function verifyWebhookSignature(options: VerifyWebhookOptions): boolean;
|
|
|
996
1128
|
* @returns Parsed webhook event
|
|
997
1129
|
*/
|
|
998
1130
|
declare function parseWebhookPayload<T = unknown>(payload: string | object): T;
|
|
1131
|
+
/**
|
|
1132
|
+
* Parse the response_json string from a WhatsApp Flow nfm_reply webhook.
|
|
1133
|
+
*
|
|
1134
|
+
* When a user completes a WhatsApp Flow, the webhook delivers an interactive
|
|
1135
|
+
* message with type 'nfm_reply'. The `response_json` field contains a stringified
|
|
1136
|
+
* JSON object with the `flow_token` and all data collected by the flow screens.
|
|
1137
|
+
*
|
|
1138
|
+
* @param responseJson - The response_json string from nfm_reply
|
|
1139
|
+
* @returns Parsed flow response data including flow_token and collected fields
|
|
1140
|
+
*
|
|
1141
|
+
* @example
|
|
1142
|
+
* ```typescript
|
|
1143
|
+
* import { parseFlowResponse } from '@semboja/connect';
|
|
1144
|
+
*
|
|
1145
|
+
* // In your webhook handler:
|
|
1146
|
+
* if (message.interactive?.type === 'nfm_reply') {
|
|
1147
|
+
* const flowData = parseFlowResponse(message.interactive.nfm_reply.response_json);
|
|
1148
|
+
* console.log('Flow token:', flowData.flow_token);
|
|
1149
|
+
* console.log('Company name:', flowData.company_name);
|
|
1150
|
+
* }
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
declare function parseFlowResponse(responseJson: string): FlowResponseData;
|
|
999
1154
|
|
|
1000
1155
|
/**
|
|
1001
1156
|
* Base error class for all Semboja API errors
|
|
@@ -1080,4 +1235,4 @@ declare class NetworkError extends SembojaError {
|
|
|
1080
1235
|
* @packageDocumentation
|
|
1081
1236
|
*/
|
|
1082
1237
|
|
|
1083
|
-
export { type ApiErrorResponse, type ApiResponse, AuthenticationError, type ClientOptions, type Contact, type ContactAddress, type ContactEmail, type ContactName, type ContactOrg, type ContactPhone, type ContactUrl, type InteractiveButton, type InteractiveListSection, type InteractiveMessage, type ListTemplatesOptions, type LocationObject, type MarkAsReadOptions, type MarkAsReadResponseData, type MediaObject, type MessageContact, type MessageResponseData, type MessageResult, type MessageType, type MetaBusinessProfile, type MetaPhoneNumberInfo, NetworkError, NotFoundError, type PhoneNumber, type PhoneNumberProfile, RateLimitError, SembojaClient, SembojaError, type SendAudioOptions, type SendContactsOptions, type SendDocumentOptions, type SendImageOptions, type SendInteractiveOptions, type SendLocationOptions, type SendMessageOptions, type SendReactionOptions, type SendStickerOptions, type SendTemplateOptions, type SendTextOptions, type SendVideoOptions, ServerError, type StickerObject, type Template, type TemplateComponent, type TemplateInfo, type TemplateLanguage, type TemplateParameter, type TemplateStatus, type TriggerWebhookOptions, type UsageData, type UsageMessages, type UsagePeriod, ValidationError, type VerifyWebhookOptions, SembojaClient as default, parseWebhookPayload, verifyWebhookSignature };
|
|
1238
|
+
export { type ApiErrorResponse, type ApiResponse, AuthenticationError, type ClientOptions, type Contact, type ContactAddress, type ContactEmail, type ContactName, type ContactOrg, type ContactPhone, type ContactUrl, type FlowActionParameters, type FlowResponseData, type InteractiveButton, type InteractiveListSection, type InteractiveMessage, type ListTemplatesOptions, type LocationObject, type MarkAsReadOptions, type MarkAsReadResponseData, type MediaObject, type MessageContact, type MessageResponseData, type MessageResult, type MessageType, type MetaBusinessProfile, type MetaPhoneNumberInfo, NetworkError, NotFoundError, type PhoneNumber, type PhoneNumberProfile, RateLimitError, SembojaClient, SembojaError, type SendAudioOptions, type SendContactsOptions, type SendDocumentOptions, type SendFlowOptions, type SendImageOptions, type SendInteractiveOptions, type SendLocationOptions, type SendMessageOptions, type SendReactionOptions, type SendStickerOptions, type SendTemplateOptions, type SendTextOptions, type SendVideoOptions, ServerError, type StickerObject, type Template, type TemplateComponent, type TemplateInfo, type TemplateLanguage, type TemplateParameter, type TemplateStatus, type TriggerWebhookOptions, type UsageData, type UsageMessages, type UsagePeriod, ValidationError, type VerifyWebhookOptions, type WebhookInteractiveReply, SembojaClient as default, parseFlowResponse, parseWebhookPayload, verifyWebhookSignature };
|