🚸 (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 { WhatsAppSendingMessage } from '@typebot.io/schemas/features/whatsapp'
|
||||||
import { isSvgSrc } from '@typebot.io/lib/utils'
|
import { isSvgSrc } from '@typebot.io/lib/utils'
|
||||||
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
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'
|
import { convertRichTextToMarkdown } from '@typebot.io/lib/markdown/convertRichTextToMarkdown'
|
||||||
|
|
||||||
export const convertMessageToWhatsAppMessage = (
|
export const convertMessageToWhatsAppMessage = (
|
||||||
@ -41,17 +48,31 @@ export const convertMessageToWhatsAppMessage = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case BubbleBlockType.VIDEO: {
|
case BubbleBlockType.VIDEO: {
|
||||||
if (
|
if (!message.content.url) return null
|
||||||
!message.content.url ||
|
if (message.content.type === VideoBubbleContentType.URL)
|
||||||
message.content.type !== VideoBubbleContentType.URL
|
|
||||||
)
|
|
||||||
return null
|
|
||||||
return {
|
return {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
video: {
|
video: {
|
||||||
link: message.content.url,
|
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: {
|
case BubbleBlockType.EMBED: {
|
||||||
if (!message.content.url) return null
|
if (!message.content.url) return null
|
||||||
|
Reference in New Issue
Block a user