🐛 (whatsapp) Fix image or video bubble before choice input
This commit is contained in:
@ -17,6 +17,7 @@ import { computeTypingDuration } from '../computeTypingDuration'
|
|||||||
import { continueBotFlow } from '../continueBotFlow'
|
import { continueBotFlow } from '../continueBotFlow'
|
||||||
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
|
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
|
||||||
import { defaultSettings } from '@typebot.io/schemas/features/typebot/settings/constants'
|
import { defaultSettings } from '@typebot.io/schemas/features/typebot/settings/constants'
|
||||||
|
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
||||||
|
|
||||||
// Media can take some time to be delivered. This make sure we don't send a message before the media is delivered.
|
// Media can take some time to be delivered. This make sure we don't send a message before the media is delivered.
|
||||||
const messageAfterMediaTimeout = 5000
|
const messageAfterMediaTimeout = 5000
|
||||||
@ -39,7 +40,10 @@ export const sendChatReplyToWhatsApp = async ({
|
|||||||
credentials,
|
credentials,
|
||||||
state,
|
state,
|
||||||
}: Props): Promise<void> => {
|
}: Props): Promise<void> => {
|
||||||
const messagesBeforeInput = isLastMessageIncludedInInput(input)
|
const messagesBeforeInput = isLastMessageIncludedInInput(
|
||||||
|
input,
|
||||||
|
messages.at(-1)
|
||||||
|
)
|
||||||
? messages.slice(0, -1)
|
? messages.slice(0, -1)
|
||||||
: messages
|
: messages
|
||||||
|
|
||||||
@ -202,10 +206,14 @@ const getTypingDuration = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isLastMessageIncludedInInput = (
|
const isLastMessageIncludedInInput = (
|
||||||
input: ContinueChatResponse['input']
|
input: ContinueChatResponse['input'],
|
||||||
|
lastMessage?: ContinueChatResponse['messages'][number]
|
||||||
): boolean => {
|
): boolean => {
|
||||||
if (isNotDefined(input)) return false
|
if (isNotDefined(input)) return false
|
||||||
return input.type === InputBlockType.CHOICE
|
return (
|
||||||
|
input.type === InputBlockType.CHOICE &&
|
||||||
|
(!lastMessage || lastMessage.type === BubbleBlockType.TEXT)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const executeClientSideAction =
|
const executeClientSideAction =
|
||||||
|
Reference in New Issue
Block a user