🚸 (whatsapp) Enable embed video thumbnail previ…
This commit is contained in:
@ -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) return null
|
||||
if (message.content.type === VideoBubbleContentType.URL)
|
||||
return {
|
||||
type: 'video',
|
||||
video: {
|
||||
link: message.content.url,
|
||||
},
|
||||
}
|
||||
if (
|
||||
!message.content.url ||
|
||||
message.content.type !== VideoBubbleContentType.URL
|
||||
embeddableVideoTypes.includes(
|
||||
message.content.type as EmbeddableVideoBubbleContentType
|
||||
)
|
||||
)
|
||||
return null
|
||||
return {
|
||||
type: 'video',
|
||||
video: {
|
||||
link: message.content.url,
|
||||
},
|
||||
}
|
||||
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
|
||||
|
Reference in New Issue
Block a user