🧑💻 (whatsapp) Option to modify the default interactive split message number (#1296)
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 <baptiste.arnaud95@gmail.com> Co-authored-by: Baptiste Arnaud <contact@baptiste-arnaud.fr>
This commit is contained in:
@ -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_NAME | | The preview start template message name |
|
||||||
| WHATSAPP_PREVIEW_TEMPLATE_LANG | en_US | 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_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
|
## Others
|
||||||
|
|
||||||
|
@ -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 { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice/constants'
|
||||||
import { defaultChoiceInputOptions } from '@typebot.io/schemas/features/blocks/inputs/choice/constants'
|
import { defaultChoiceInputOptions } from '@typebot.io/schemas/features/blocks/inputs/choice/constants'
|
||||||
import { convertRichTextToMarkdown } from '@typebot.io/lib/markdown/convertRichTextToMarkdown'
|
import { convertRichTextToMarkdown } from '@typebot.io/lib/markdown/convertRichTextToMarkdown'
|
||||||
|
import { env } from '@typebot.io/env'
|
||||||
|
|
||||||
export const convertInputToWhatsAppMessages = (
|
export const convertInputToWhatsAppMessages = (
|
||||||
input: NonNullable<ContinueChatResponse['input']>,
|
input: NonNullable<ContinueChatResponse['input']>,
|
||||||
@ -110,7 +111,7 @@ export const convertInputToWhatsAppMessages = (
|
|||||||
]
|
]
|
||||||
const items = groupArrayByArraySize(
|
const items = groupArrayByArraySize(
|
||||||
input.items.filter((item) => isDefined(item.content)),
|
input.items.filter((item) => isDefined(item.content)),
|
||||||
3
|
env.WHATSAPP_INTERACTIVE_GROUP_SIZE
|
||||||
) as ButtonItem[][]
|
) as ButtonItem[][]
|
||||||
return items.map((items, idx) => ({
|
return items.map((items, idx) => ({
|
||||||
type: 'interactive',
|
type: 'interactive',
|
||||||
|
1
packages/env/env.ts
vendored
1
packages/env/env.ts
vendored
@ -307,6 +307,7 @@ const whatsAppEnv = {
|
|||||||
.url()
|
.url()
|
||||||
.optional()
|
.optional()
|
||||||
.default('https://graph.facebook.com'),
|
.default('https://graph.facebook.com'),
|
||||||
|
WHATSAPP_INTERACTIVE_GROUP_SIZE: z.coerce.number().optional().default(3),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user