2
0

🚸 (whatsapp) Enable embed video thumbnail previ…

This commit is contained in:
Baptiste Arnaud
2024-05-17 10:12:21 +02:00
parent 8151d7fd90
commit 9b8298b131

View File

@ -1,8 +1,15 @@
import { ContinueChatResponse } from '@typebot.io/schemas'
import {
ContinueChatResponse,
EmbeddableVideoBubbleContentType,
} from '@typebot.io/schemas'
import { WhatsAppSendingMessage } from '@typebot.io/schemas/features/whatsapp'
import { isSvgSrc } from '@typebot.io/lib/utils'
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
import { VideoBubbleContentType } from '@typebot.io/schemas/features/blocks/bubbles/video/constants'
import {
VideoBubbleContentType,
embedBaseUrls,
embeddableVideoTypes,
} from '@typebot.io/schemas/features/blocks/bubbles/video/constants'
import { convertRichTextToMarkdown } from '@typebot.io/lib/markdown/convertRichTextToMarkdown'
export const convertMessageToWhatsAppMessage = (
@ -41,17 +48,31 @@ export const convertMessageToWhatsAppMessage = (
}
}
case BubbleBlockType.VIDEO: {
if (
!message.content.url ||
message.content.type !== VideoBubbleContentType.URL
)
return null
if (!message.content.url) return null
if (message.content.type === VideoBubbleContentType.URL)
return {
type: 'video',
video: {
link: message.content.url,
},
}
if (
embeddableVideoTypes.includes(
message.content.type as EmbeddableVideoBubbleContentType
)
)
return {
type: 'text',
text: {
body: `${
embedBaseUrls[
message.content.type as EmbeddableVideoBubbleContentType
]
}/${message.content.id}`,
},
preview_url: true,
}
return null
}
case BubbleBlockType.EMBED: {
if (!message.content.url) return null