From df209a8e9deaf673498d0b1bb68b4558b7d0ff9a Mon Sep 17 00:00:00 2001 From: thercd <33912026+thercd@users.noreply.github.com> Date: Thu, 7 Mar 2024 05:05:08 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20(whatsapp)?= =?UTF-8?q?=20Option=20to=20modify=20the=20default=20interactive=20split?= =?UTF-8?q?=20message=20number=20(#1296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using the whatsapp oficial api or another that use the same schema, with env we can modify the number of groups that the interactive group will be split. --------- Co-authored-by: Baptiste Arnaud Co-authored-by: Baptiste Arnaud --- apps/docs/self-hosting/configuration.mdx | 1 + packages/bot-engine/whatsapp/convertInputToWhatsAppMessage.ts | 3 ++- packages/env/env.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/docs/self-hosting/configuration.mdx b/apps/docs/self-hosting/configuration.mdx index e0f94f0db..c2de56179 100644 --- a/apps/docs/self-hosting/configuration.mdx +++ b/apps/docs/self-hosting/configuration.mdx @@ -245,6 +245,7 @@ In order to be able to test your bot on WhatsApp from the Preview drawer, you ne | WHATSAPP_PREVIEW_TEMPLATE_NAME | | The preview start template message name | | WHATSAPP_PREVIEW_TEMPLATE_LANG | en_US | The preview start template message name | | WHATSAPP_CLOUD_API_URL | https://graph.facebook.com | The WhatsApp Cloud API base URL | +| WHATSAPP_INTERACTIVE_GROUP_SIZE | 3 | The array size of items to send to API on choice input. You can't choose a number higher than 3 if you are using the official cloud API URL. | ## Others diff --git a/packages/bot-engine/whatsapp/convertInputToWhatsAppMessage.ts b/packages/bot-engine/whatsapp/convertInputToWhatsAppMessage.ts index 83f1d559e..0926fd99d 100644 --- a/packages/bot-engine/whatsapp/convertInputToWhatsAppMessage.ts +++ b/packages/bot-engine/whatsapp/convertInputToWhatsAppMessage.ts @@ -6,6 +6,7 @@ import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/const import { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice/constants' import { defaultChoiceInputOptions } from '@typebot.io/schemas/features/blocks/inputs/choice/constants' import { convertRichTextToMarkdown } from '@typebot.io/lib/markdown/convertRichTextToMarkdown' +import { env } from '@typebot.io/env' export const convertInputToWhatsAppMessages = ( input: NonNullable, @@ -110,7 +111,7 @@ export const convertInputToWhatsAppMessages = ( ] const items = groupArrayByArraySize( input.items.filter((item) => isDefined(item.content)), - 3 + env.WHATSAPP_INTERACTIVE_GROUP_SIZE ) as ButtonItem[][] return items.map((items, idx) => ({ type: 'interactive', diff --git a/packages/env/env.ts b/packages/env/env.ts index b13ab51a7..4faeade51 100644 --- a/packages/env/env.ts +++ b/packages/env/env.ts @@ -307,6 +307,7 @@ const whatsAppEnv = { .url() .optional() .default('https://graph.facebook.com'), + WHATSAPP_INTERACTIVE_GROUP_SIZE: z.coerce.number().optional().default(3), }, }