@adatechnology/meta-whatsapp-module 0.2.0-rc.21 → 0.2.0-rc.23

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.cts CHANGED
@@ -2559,6 +2559,12 @@ interface MetaWhatsAppModuleConfig {
2559
2559
  wabaId?: string;
2560
2560
  apiVersion?: string;
2561
2561
  baseUrl?: string;
2562
+ /**
2563
+ * Catálogo do Meta Commerce que a vitrine no chat oferece. Sem ele — ou sem `providers.catalog`
2564
+ * — a action `send_product_list` não é registrada: nó que o editor oferece e que em silêncio não
2565
+ * faz nada é pior do que nó que não existe.
2566
+ */
2567
+ catalogId?: string;
2562
2568
  }
2563
2569
  interface MetaWhatsAppModuleFeatures {
2564
2570
  flowEngine?: boolean;
@@ -2754,6 +2760,18 @@ declare class WhatsAppChannelAdapter implements ChannelAdapterInterface {
2754
2760
  }): Promise<{
2755
2761
  externalMessageId: string | null;
2756
2762
  }>;
2763
+ sendProductList(params: {
2764
+ to: string;
2765
+ headerText: string;
2766
+ body: string;
2767
+ footerText?: string;
2768
+ sections: {
2769
+ title: string;
2770
+ retailerIds: string[];
2771
+ }[];
2772
+ }): Promise<{
2773
+ externalMessageId: string | null;
2774
+ }>;
2757
2775
  /**
2758
2776
  * Busca o binário da mídia — da Meta, ou do storage quando o id é do simulador.
2759
2777
  *
@@ -2841,4 +2859,32 @@ type CreateSendMediaActionParams = {
2841
2859
  */
2842
2860
  declare function createSendMediaAction(params: CreateSendMediaActionParams): FlowActionHandler;
2843
2861
 
2844
- export { type AttachFlowMediaParams, type AudioTranscriber, type CompanyDocumentView, type CompanyDocumentsPage, type ConversationDocumentView, type ConversationDocumentsPage, type CreateFlowGraphParams, CreateFlowGraphUseCase, type CreateMetaWhatsAppModuleParams, type CreateSendMediaActionParams, DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS, type DeleteConversationParams, type DeleteConversationResult, DeleteConversationUseCase, DeleteFlowGraphUseCase, DocumentRepository, type DocumentRow, type DrizzleMigrateFunction, type ExportConversationParams, type ExportConversationResult, ExportConversationUseCase, FlowGraphCache, FlowGraphRepository, type FlowGraphRow, FlowInterpreter, type FlowMediaLocation, FlowMediaRepository, type FlowMediaRow, type FlowMediaTranscriptLogger, type FlowRunResult, type FlowStepInput, type FlowStepResult, GetFlowGraphUseCase, GetLiveFlowPositionsUseCase, type IngestInboundMediaParams, type IngestInboundMediaResult, IngestInboundMediaUseCase, type IngestTranscriptionOptions, type InsertMessageParams, InvalidFlowGraphError, type LinkDocumentParams, type ListCompanyDocumentsParams, ListCompanyDocumentsUseCase, type ListConversationDocumentsParams, ListConversationDocumentsUseCase, type ListConversationsFilters, type ListConversationsParams, ListConversationsUseCase, type ListDocumentsParams, type ListDocumentsResult, ListFlowGraphsUseCase, type ListMessagesParams, ListMessagesUseCase, type LogMessageParams, LogMessageUseCase, META_WHATSAPP_MIGRATIONS_TABLE, type MessageModerator, MessageRepository, type MessageRow, type MetaWhatsAppDatabase, type MetaWhatsAppModule, type MetaWhatsAppModuleConfig, type MetaWhatsAppModuleFeatures, type MetaWhatsAppModuleProviders, type MetaWhatsAppTranscriptionConfig, type NewDocumentRow, type NewFlowGraphRow, type NewFlowMediaRow, type NewMessageRow, type NewSessionRow, type NewSettingsRow, type NonceStoreInterface, OptimisticLockError, type PreviewMediaSupport, type PurgeExpiredDocumentsParams, type PurgeExpiredDocumentsResult, PurgeExpiredDocumentsUseCase, type RealtimeRelay, type ReceiveWebhookParams, type ReceiveWebhookResult, ReceiveWebhookUseCase, type ReleaseConversationParams, ReleaseConversationUseCase, type ListMessagesParams$1 as RepositoryListMessagesParams, type ResolveTranscriptionPolicyDependencies, type RunMetaWhatsAppMigrationsParams, type SaveFlowGraphParams, SaveFlowGraphUseCase, type SaveTranscriptionByWaMessageIdParams, type SaveTranscriptionParams, type SendMediaParams, SendMessageUseCase, type SendTemplateParams, type SendTextParams, SessionRepository, type SessionRow, SettingsRepository, type SettingsRow, SseHub, type SseListener, type StorePreviewMediaParams, type StorePreviewMediaResult, StorePreviewMediaUseCase, TRANSCRIPTION_MODE, TRANSCRIPTION_STATUS, type TakeoverConversationParams, TakeoverConversationUseCase, type TicketStoreInterface, type TranscribeAudioDependencies, type TranscribeAudioParams, type TranscribeAudioResult, TranscribeAudioUseCase, type TranscriptionPolicy, type TranscriptionPolicyDefaults, type TranscriptionPolicyResolver, type TranscriptionStatus, type UpdateFlowMediaParams, WEBHOOK_NONCE_TTL_SECONDS, WhatsAppChannelAdapter, claimWebhookDelivery, createMetaWhatsAppModule, createSendMediaAction, createTranscriptionPolicyResolver, documents, extractMediaDescriptor, flowGraphs, flowMedia, isAudioMimeType, isRetriableTranscriptionError, isUnsupportedTranscriptionError, issueSseTicket, messages, metaWhatsAppMigrationsFolder, metaWhatsAppSchema, redeemSseTicket, resolveFailureStatus, runMetaWhatsAppMigrations, sessions, settings, transcriptionRetryAfterSeconds, verifyWebhookChallenge, verifyWebhookSignature };
2862
+ /** Tetos da Meta para `interactive.product_list`. Acima disso a mensagem inteira é recusada. */
2863
+ declare const PRODUCT_LIST_LIMIT: {
2864
+ readonly ITEMS: 30;
2865
+ readonly SECTIONS: 10;
2866
+ };
2867
+ type CreateSendProductListActionParams = {
2868
+ catalog: CatalogPort;
2869
+ catalogId: string;
2870
+ logMessage: FlowMediaTranscriptLogger;
2871
+ startState: SessionState;
2872
+ /** Falha de UMA vitrine não pode travar a conversa; o host observa por aqui. */
2873
+ onError?: (error: unknown, details: {
2874
+ flowKey: string;
2875
+ nodeId: string;
2876
+ }) => void;
2877
+ };
2878
+ /**
2879
+ * Action `send_product_list`: ao passar pelo nó, envia a vitrine do catálogo publicado na Meta.
2880
+ *
2881
+ * O nó guarda **critério**, não a lista de produtos. Congelar `retailerId` em `actionParams` faria
2882
+ * o fluxo continuar oferecendo o item esgotado — ou o item excluído, que a Meta recusa junto com a
2883
+ * mensagem inteira. O que o operador edita é o texto e o filtro; o estoque manda no resto.
2884
+ *
2885
+ * Só produto em estoque entra. Vitrine que mostra o que não tem produz a pior conversa possível:
2886
+ * o cliente escolhe, responde, e recebe "acabou".
2887
+ */
2888
+ declare function createSendProductListAction(params: CreateSendProductListActionParams): FlowActionHandler;
2889
+
2890
+ export { type AttachFlowMediaParams, type AudioTranscriber, type CompanyDocumentView, type CompanyDocumentsPage, type ConversationDocumentView, type ConversationDocumentsPage, type CreateFlowGraphParams, CreateFlowGraphUseCase, type CreateMetaWhatsAppModuleParams, type CreateSendMediaActionParams, type CreateSendProductListActionParams, DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS, type DeleteConversationParams, type DeleteConversationResult, DeleteConversationUseCase, DeleteFlowGraphUseCase, DocumentRepository, type DocumentRow, type DrizzleMigrateFunction, type ExportConversationParams, type ExportConversationResult, ExportConversationUseCase, FlowGraphCache, FlowGraphRepository, type FlowGraphRow, FlowInterpreter, type FlowMediaLocation, FlowMediaRepository, type FlowMediaRow, type FlowMediaTranscriptLogger, type FlowRunResult, type FlowStepInput, type FlowStepResult, GetFlowGraphUseCase, GetLiveFlowPositionsUseCase, type IngestInboundMediaParams, type IngestInboundMediaResult, IngestInboundMediaUseCase, type IngestTranscriptionOptions, type InsertMessageParams, InvalidFlowGraphError, type LinkDocumentParams, type ListCompanyDocumentsParams, ListCompanyDocumentsUseCase, type ListConversationDocumentsParams, ListConversationDocumentsUseCase, type ListConversationsFilters, type ListConversationsParams, ListConversationsUseCase, type ListDocumentsParams, type ListDocumentsResult, ListFlowGraphsUseCase, type ListMessagesParams, ListMessagesUseCase, type LogMessageParams, LogMessageUseCase, META_WHATSAPP_MIGRATIONS_TABLE, type MessageModerator, MessageRepository, type MessageRow, type MetaWhatsAppDatabase, type MetaWhatsAppModule, type MetaWhatsAppModuleConfig, type MetaWhatsAppModuleFeatures, type MetaWhatsAppModuleProviders, type MetaWhatsAppTranscriptionConfig, type NewDocumentRow, type NewFlowGraphRow, type NewFlowMediaRow, type NewMessageRow, type NewSessionRow, type NewSettingsRow, type NonceStoreInterface, OptimisticLockError, PRODUCT_LIST_LIMIT, type PreviewMediaSupport, type PurgeExpiredDocumentsParams, type PurgeExpiredDocumentsResult, PurgeExpiredDocumentsUseCase, type RealtimeRelay, type ReceiveWebhookParams, type ReceiveWebhookResult, ReceiveWebhookUseCase, type ReleaseConversationParams, ReleaseConversationUseCase, type ListMessagesParams$1 as RepositoryListMessagesParams, type ResolveTranscriptionPolicyDependencies, type RunMetaWhatsAppMigrationsParams, type SaveFlowGraphParams, SaveFlowGraphUseCase, type SaveTranscriptionByWaMessageIdParams, type SaveTranscriptionParams, type SendMediaParams, SendMessageUseCase, type SendTemplateParams, type SendTextParams, SessionRepository, type SessionRow, SettingsRepository, type SettingsRow, SseHub, type SseListener, type StorePreviewMediaParams, type StorePreviewMediaResult, StorePreviewMediaUseCase, TRANSCRIPTION_MODE, TRANSCRIPTION_STATUS, type TakeoverConversationParams, TakeoverConversationUseCase, type TicketStoreInterface, type TranscribeAudioDependencies, type TranscribeAudioParams, type TranscribeAudioResult, TranscribeAudioUseCase, type TranscriptionPolicy, type TranscriptionPolicyDefaults, type TranscriptionPolicyResolver, type TranscriptionStatus, type UpdateFlowMediaParams, WEBHOOK_NONCE_TTL_SECONDS, WhatsAppChannelAdapter, claimWebhookDelivery, createMetaWhatsAppModule, createSendMediaAction, createSendProductListAction, createTranscriptionPolicyResolver, documents, extractMediaDescriptor, flowGraphs, flowMedia, isAudioMimeType, isRetriableTranscriptionError, isUnsupportedTranscriptionError, issueSseTicket, messages, metaWhatsAppMigrationsFolder, metaWhatsAppSchema, redeemSseTicket, resolveFailureStatus, runMetaWhatsAppMigrations, sessions, settings, transcriptionRetryAfterSeconds, verifyWebhookChallenge, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -2559,6 +2559,12 @@ interface MetaWhatsAppModuleConfig {
2559
2559
  wabaId?: string;
2560
2560
  apiVersion?: string;
2561
2561
  baseUrl?: string;
2562
+ /**
2563
+ * Catálogo do Meta Commerce que a vitrine no chat oferece. Sem ele — ou sem `providers.catalog`
2564
+ * — a action `send_product_list` não é registrada: nó que o editor oferece e que em silêncio não
2565
+ * faz nada é pior do que nó que não existe.
2566
+ */
2567
+ catalogId?: string;
2562
2568
  }
2563
2569
  interface MetaWhatsAppModuleFeatures {
2564
2570
  flowEngine?: boolean;
@@ -2754,6 +2760,18 @@ declare class WhatsAppChannelAdapter implements ChannelAdapterInterface {
2754
2760
  }): Promise<{
2755
2761
  externalMessageId: string | null;
2756
2762
  }>;
2763
+ sendProductList(params: {
2764
+ to: string;
2765
+ headerText: string;
2766
+ body: string;
2767
+ footerText?: string;
2768
+ sections: {
2769
+ title: string;
2770
+ retailerIds: string[];
2771
+ }[];
2772
+ }): Promise<{
2773
+ externalMessageId: string | null;
2774
+ }>;
2757
2775
  /**
2758
2776
  * Busca o binário da mídia — da Meta, ou do storage quando o id é do simulador.
2759
2777
  *
@@ -2841,4 +2859,32 @@ type CreateSendMediaActionParams = {
2841
2859
  */
2842
2860
  declare function createSendMediaAction(params: CreateSendMediaActionParams): FlowActionHandler;
2843
2861
 
2844
- export { type AttachFlowMediaParams, type AudioTranscriber, type CompanyDocumentView, type CompanyDocumentsPage, type ConversationDocumentView, type ConversationDocumentsPage, type CreateFlowGraphParams, CreateFlowGraphUseCase, type CreateMetaWhatsAppModuleParams, type CreateSendMediaActionParams, DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS, type DeleteConversationParams, type DeleteConversationResult, DeleteConversationUseCase, DeleteFlowGraphUseCase, DocumentRepository, type DocumentRow, type DrizzleMigrateFunction, type ExportConversationParams, type ExportConversationResult, ExportConversationUseCase, FlowGraphCache, FlowGraphRepository, type FlowGraphRow, FlowInterpreter, type FlowMediaLocation, FlowMediaRepository, type FlowMediaRow, type FlowMediaTranscriptLogger, type FlowRunResult, type FlowStepInput, type FlowStepResult, GetFlowGraphUseCase, GetLiveFlowPositionsUseCase, type IngestInboundMediaParams, type IngestInboundMediaResult, IngestInboundMediaUseCase, type IngestTranscriptionOptions, type InsertMessageParams, InvalidFlowGraphError, type LinkDocumentParams, type ListCompanyDocumentsParams, ListCompanyDocumentsUseCase, type ListConversationDocumentsParams, ListConversationDocumentsUseCase, type ListConversationsFilters, type ListConversationsParams, ListConversationsUseCase, type ListDocumentsParams, type ListDocumentsResult, ListFlowGraphsUseCase, type ListMessagesParams, ListMessagesUseCase, type LogMessageParams, LogMessageUseCase, META_WHATSAPP_MIGRATIONS_TABLE, type MessageModerator, MessageRepository, type MessageRow, type MetaWhatsAppDatabase, type MetaWhatsAppModule, type MetaWhatsAppModuleConfig, type MetaWhatsAppModuleFeatures, type MetaWhatsAppModuleProviders, type MetaWhatsAppTranscriptionConfig, type NewDocumentRow, type NewFlowGraphRow, type NewFlowMediaRow, type NewMessageRow, type NewSessionRow, type NewSettingsRow, type NonceStoreInterface, OptimisticLockError, type PreviewMediaSupport, type PurgeExpiredDocumentsParams, type PurgeExpiredDocumentsResult, PurgeExpiredDocumentsUseCase, type RealtimeRelay, type ReceiveWebhookParams, type ReceiveWebhookResult, ReceiveWebhookUseCase, type ReleaseConversationParams, ReleaseConversationUseCase, type ListMessagesParams$1 as RepositoryListMessagesParams, type ResolveTranscriptionPolicyDependencies, type RunMetaWhatsAppMigrationsParams, type SaveFlowGraphParams, SaveFlowGraphUseCase, type SaveTranscriptionByWaMessageIdParams, type SaveTranscriptionParams, type SendMediaParams, SendMessageUseCase, type SendTemplateParams, type SendTextParams, SessionRepository, type SessionRow, SettingsRepository, type SettingsRow, SseHub, type SseListener, type StorePreviewMediaParams, type StorePreviewMediaResult, StorePreviewMediaUseCase, TRANSCRIPTION_MODE, TRANSCRIPTION_STATUS, type TakeoverConversationParams, TakeoverConversationUseCase, type TicketStoreInterface, type TranscribeAudioDependencies, type TranscribeAudioParams, type TranscribeAudioResult, TranscribeAudioUseCase, type TranscriptionPolicy, type TranscriptionPolicyDefaults, type TranscriptionPolicyResolver, type TranscriptionStatus, type UpdateFlowMediaParams, WEBHOOK_NONCE_TTL_SECONDS, WhatsAppChannelAdapter, claimWebhookDelivery, createMetaWhatsAppModule, createSendMediaAction, createTranscriptionPolicyResolver, documents, extractMediaDescriptor, flowGraphs, flowMedia, isAudioMimeType, isRetriableTranscriptionError, isUnsupportedTranscriptionError, issueSseTicket, messages, metaWhatsAppMigrationsFolder, metaWhatsAppSchema, redeemSseTicket, resolveFailureStatus, runMetaWhatsAppMigrations, sessions, settings, transcriptionRetryAfterSeconds, verifyWebhookChallenge, verifyWebhookSignature };
2862
+ /** Tetos da Meta para `interactive.product_list`. Acima disso a mensagem inteira é recusada. */
2863
+ declare const PRODUCT_LIST_LIMIT: {
2864
+ readonly ITEMS: 30;
2865
+ readonly SECTIONS: 10;
2866
+ };
2867
+ type CreateSendProductListActionParams = {
2868
+ catalog: CatalogPort;
2869
+ catalogId: string;
2870
+ logMessage: FlowMediaTranscriptLogger;
2871
+ startState: SessionState;
2872
+ /** Falha de UMA vitrine não pode travar a conversa; o host observa por aqui. */
2873
+ onError?: (error: unknown, details: {
2874
+ flowKey: string;
2875
+ nodeId: string;
2876
+ }) => void;
2877
+ };
2878
+ /**
2879
+ * Action `send_product_list`: ao passar pelo nó, envia a vitrine do catálogo publicado na Meta.
2880
+ *
2881
+ * O nó guarda **critério**, não a lista de produtos. Congelar `retailerId` em `actionParams` faria
2882
+ * o fluxo continuar oferecendo o item esgotado — ou o item excluído, que a Meta recusa junto com a
2883
+ * mensagem inteira. O que o operador edita é o texto e o filtro; o estoque manda no resto.
2884
+ *
2885
+ * Só produto em estoque entra. Vitrine que mostra o que não tem produz a pior conversa possível:
2886
+ * o cliente escolhe, responde, e recebe "acabou".
2887
+ */
2888
+ declare function createSendProductListAction(params: CreateSendProductListActionParams): FlowActionHandler;
2889
+
2890
+ export { type AttachFlowMediaParams, type AudioTranscriber, type CompanyDocumentView, type CompanyDocumentsPage, type ConversationDocumentView, type ConversationDocumentsPage, type CreateFlowGraphParams, CreateFlowGraphUseCase, type CreateMetaWhatsAppModuleParams, type CreateSendMediaActionParams, type CreateSendProductListActionParams, DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS, type DeleteConversationParams, type DeleteConversationResult, DeleteConversationUseCase, DeleteFlowGraphUseCase, DocumentRepository, type DocumentRow, type DrizzleMigrateFunction, type ExportConversationParams, type ExportConversationResult, ExportConversationUseCase, FlowGraphCache, FlowGraphRepository, type FlowGraphRow, FlowInterpreter, type FlowMediaLocation, FlowMediaRepository, type FlowMediaRow, type FlowMediaTranscriptLogger, type FlowRunResult, type FlowStepInput, type FlowStepResult, GetFlowGraphUseCase, GetLiveFlowPositionsUseCase, type IngestInboundMediaParams, type IngestInboundMediaResult, IngestInboundMediaUseCase, type IngestTranscriptionOptions, type InsertMessageParams, InvalidFlowGraphError, type LinkDocumentParams, type ListCompanyDocumentsParams, ListCompanyDocumentsUseCase, type ListConversationDocumentsParams, ListConversationDocumentsUseCase, type ListConversationsFilters, type ListConversationsParams, ListConversationsUseCase, type ListDocumentsParams, type ListDocumentsResult, ListFlowGraphsUseCase, type ListMessagesParams, ListMessagesUseCase, type LogMessageParams, LogMessageUseCase, META_WHATSAPP_MIGRATIONS_TABLE, type MessageModerator, MessageRepository, type MessageRow, type MetaWhatsAppDatabase, type MetaWhatsAppModule, type MetaWhatsAppModuleConfig, type MetaWhatsAppModuleFeatures, type MetaWhatsAppModuleProviders, type MetaWhatsAppTranscriptionConfig, type NewDocumentRow, type NewFlowGraphRow, type NewFlowMediaRow, type NewMessageRow, type NewSessionRow, type NewSettingsRow, type NonceStoreInterface, OptimisticLockError, PRODUCT_LIST_LIMIT, type PreviewMediaSupport, type PurgeExpiredDocumentsParams, type PurgeExpiredDocumentsResult, PurgeExpiredDocumentsUseCase, type RealtimeRelay, type ReceiveWebhookParams, type ReceiveWebhookResult, ReceiveWebhookUseCase, type ReleaseConversationParams, ReleaseConversationUseCase, type ListMessagesParams$1 as RepositoryListMessagesParams, type ResolveTranscriptionPolicyDependencies, type RunMetaWhatsAppMigrationsParams, type SaveFlowGraphParams, SaveFlowGraphUseCase, type SaveTranscriptionByWaMessageIdParams, type SaveTranscriptionParams, type SendMediaParams, SendMessageUseCase, type SendTemplateParams, type SendTextParams, SessionRepository, type SessionRow, SettingsRepository, type SettingsRow, SseHub, type SseListener, type StorePreviewMediaParams, type StorePreviewMediaResult, StorePreviewMediaUseCase, TRANSCRIPTION_MODE, TRANSCRIPTION_STATUS, type TakeoverConversationParams, TakeoverConversationUseCase, type TicketStoreInterface, type TranscribeAudioDependencies, type TranscribeAudioParams, type TranscribeAudioResult, TranscribeAudioUseCase, type TranscriptionPolicy, type TranscriptionPolicyDefaults, type TranscriptionPolicyResolver, type TranscriptionStatus, type UpdateFlowMediaParams, WEBHOOK_NONCE_TTL_SECONDS, WhatsAppChannelAdapter, claimWebhookDelivery, createMetaWhatsAppModule, createSendMediaAction, createSendProductListAction, createTranscriptionPolicyResolver, documents, extractMediaDescriptor, flowGraphs, flowMedia, isAudioMimeType, isRetriableTranscriptionError, isUnsupportedTranscriptionError, issueSseTicket, messages, metaWhatsAppMigrationsFolder, metaWhatsAppSchema, redeemSseTicket, resolveFailureStatus, runMetaWhatsAppMigrations, sessions, settings, transcriptionRetryAfterSeconds, verifyWebhookChallenge, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -1741,6 +1741,75 @@ function createSendMediaAction(params) {
1741
1741
  }
1742
1742
  __name(createSendMediaAction, "createSendMediaAction");
1743
1743
 
1744
+ // src/flows/createSendProductListAction.ts
1745
+ var PRODUCT_LIST_LIMIT = {
1746
+ ITEMS: 30,
1747
+ SECTIONS: 10
1748
+ };
1749
+ function createSendProductListAction(params) {
1750
+ return async ({ node, session, channel }) => {
1751
+ if (!channel.sendProductList) return;
1752
+ const actionParams = node.actionParams ?? {};
1753
+ try {
1754
+ const available = await listAvailableProducts({
1755
+ catalog: params.catalog,
1756
+ catalogId: params.catalogId,
1757
+ ...actionParams.search ? {
1758
+ search: actionParams.search
1759
+ } : {}
1760
+ });
1761
+ if (available.length === 0) return;
1762
+ const bodyText = actionParams.bodyText ?? "Veja o que temos dispon\xEDvel:";
1763
+ const { externalMessageId } = await channel.sendProductList({
1764
+ to: session.whatsappNumber,
1765
+ headerText: actionParams.headerText ?? "Nossos produtos",
1766
+ body: bodyText,
1767
+ ...actionParams.footerText ? {
1768
+ footerText: actionParams.footerText
1769
+ } : {},
1770
+ sections: [
1771
+ {
1772
+ title: actionParams.sectionTitle ?? "Dispon\xEDveis",
1773
+ retailerIds: available.map((product) => product.retailerId)
1774
+ }
1775
+ ]
1776
+ });
1777
+ await params.logMessage.execute({
1778
+ companyId: session.companyId,
1779
+ whatsappNumber: session.whatsappNumber,
1780
+ direction: "outbound",
1781
+ sender: "bot",
1782
+ agentUserId: null,
1783
+ type: "interactive",
1784
+ content: bodyText,
1785
+ payload: {
1786
+ kind: "product_list",
1787
+ productCount: available.length
1788
+ },
1789
+ waMessageId: externalMessageId,
1790
+ status: "sent",
1791
+ startState: params.startState
1792
+ });
1793
+ } catch (error) {
1794
+ params.onError?.(error, {
1795
+ flowKey: session.flowKey ?? "",
1796
+ nodeId: node.id
1797
+ });
1798
+ }
1799
+ };
1800
+ }
1801
+ __name(createSendProductListAction, "createSendProductListAction");
1802
+ async function listAvailableProducts(params) {
1803
+ const products = await params.catalog.listProducts({
1804
+ catalogId: params.catalogId,
1805
+ ...params.search ? {
1806
+ search: params.search
1807
+ } : {}
1808
+ });
1809
+ return products.filter((product) => product.availability === "in stock").slice(0, PRODUCT_LIST_LIMIT.ITEMS);
1810
+ }
1811
+ __name(listAvailableProducts, "listAvailableProducts");
1812
+
1744
1813
  // src/repositories/FlowMediaRepository.ts
1745
1814
  import { and as and5, asc as asc2, eq as eq6, sql as sql4 } from "drizzle-orm";
1746
1815
  var FlowMediaRepository = class {
@@ -1899,6 +1968,20 @@ var WhatsAppChannelAdapter = class {
1899
1968
  externalMessageId: result.waMessageId
1900
1969
  };
1901
1970
  }
1971
+ async sendProductList(params) {
1972
+ const result = await this.translateErrors(() => this.messages.sendProductListMessage({
1973
+ to: params.to,
1974
+ headerText: params.headerText,
1975
+ bodyText: params.body,
1976
+ ...params.footerText ? {
1977
+ footerText: params.footerText
1978
+ } : {},
1979
+ sections: params.sections
1980
+ }));
1981
+ return {
1982
+ externalMessageId: result.waMessageId
1983
+ };
1984
+ }
1902
1985
  /**
1903
1986
  * Busca o binário da mídia — da Meta, ou do storage quando o id é do simulador.
1904
1987
  *
@@ -2519,6 +2602,15 @@ function createMetaWhatsAppModule(params) {
2519
2602
  onError: hooks?.onFlowMediaError
2520
2603
  }));
2521
2604
  }
2605
+ if (flowInterpreter && providers.catalog && config.catalogId) {
2606
+ flowInterpreter.registerFlowAction(FLOW_ACTION_KIND.SEND_PRODUCT_LIST, createSendProductListAction({
2607
+ catalog: providers.catalog,
2608
+ catalogId: config.catalogId,
2609
+ logMessage,
2610
+ startState,
2611
+ onError: hooks?.onFlowProductListError
2612
+ }));
2613
+ }
2522
2614
  const transcriptionMode = providers.transcription?.mode ?? TRANSCRIPTION_MODE.ON_DEMAND;
2523
2615
  const resolveTranscriptionPolicy = providers.transcription ? createTranscriptionPolicyResolver({
2524
2616
  settingsRepository,
@@ -2738,6 +2830,7 @@ export {
2738
2830
  MessageRepository,
2739
2831
  OptimisticLockError,
2740
2832
  PREVIEW_MEDIA_ID_PREFIX,
2833
+ PRODUCT_LIST_LIMIT,
2741
2834
  PurgeExpiredDocumentsUseCase,
2742
2835
  ReceiveWebhookUseCase,
2743
2836
  ReleaseConversationUseCase,
@@ -2756,6 +2849,7 @@ export {
2756
2849
  claimWebhookDelivery,
2757
2850
  createMetaWhatsAppModule,
2758
2851
  createSendMediaAction,
2852
+ createSendProductListAction,
2759
2853
  createTranscriptionPolicyResolver,
2760
2854
  documents,
2761
2855
  extractMediaDescriptor,