🐛 (share) Enable back empty public ID for self-hosted version
Closes #576
This commit is contained in:
@ -5,11 +5,11 @@ import { SEO } from './Seo'
|
|||||||
|
|
||||||
export type TypebotPageProps = {
|
export type TypebotPageProps = {
|
||||||
url: string
|
url: string
|
||||||
typebot?: Pick<Typebot, 'settings' | 'theme' | 'name' | 'publicId'>
|
typebot: Pick<Typebot, 'settings' | 'theme' | 'name' | 'publicId'>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TypebotPageV3 = ({ url, typebot }: TypebotPageProps) => {
|
export const TypebotPageV3 = ({ url, typebot }: TypebotPageProps) => {
|
||||||
const { asPath, push, query } = useRouter()
|
const { asPath, push } = useRouter()
|
||||||
|
|
||||||
const background = typebot?.theme.general.background
|
const background = typebot?.theme.general.background
|
||||||
|
|
||||||
@ -36,15 +36,13 @@ export const TypebotPageV3 = ({ url, typebot }: TypebotPageProps) => {
|
|||||||
: '#fff',
|
: '#fff',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{typebot && (
|
<SEO
|
||||||
<SEO
|
url={url}
|
||||||
url={url}
|
typebotName={typebot.name}
|
||||||
typebotName={typebot.name}
|
metadata={typebot.settings.metadata}
|
||||||
metadata={typebot.settings.metadata}
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Standard
|
<Standard
|
||||||
typebot={typebot?.publicId ?? query.publicId?.toString() ?? 'n'}
|
typebot={typebot.publicId}
|
||||||
onInit={clearQueryParamsIfNecessary}
|
onInit={clearQueryParamsIfNecessary}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -125,10 +125,10 @@ export const sendMessage = publicProcedure
|
|||||||
)
|
)
|
||||||
|
|
||||||
const startSession = async (startParams?: StartParams, userId?: string) => {
|
const startSession = async (startParams?: StartParams, userId?: string) => {
|
||||||
if (!startParams?.typebot)
|
if (!startParams)
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'No typebot provided in startParams',
|
message: 'StartParams are missing',
|
||||||
})
|
})
|
||||||
|
|
||||||
const typebot = await getTypebot(startParams, userId)
|
const typebot = await getTypebot(startParams, userId)
|
||||||
|
@ -94,7 +94,14 @@ const getTypebotFromPublicId = async (
|
|||||||
const publishedTypebot = await prisma.publicTypebot.findFirst({
|
const publishedTypebot = await prisma.publicTypebot.findFirst({
|
||||||
where: { typebot: { publicId: publicId ?? '' } },
|
where: { typebot: { publicId: publicId ?? '' } },
|
||||||
include: {
|
include: {
|
||||||
typebot: { select: { name: true, isClosed: true, isArchived: true } },
|
typebot: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
isClosed: true,
|
||||||
|
isArchived: true,
|
||||||
|
publicId: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (isNotDefined(publishedTypebot)) return null
|
if (isNotDefined(publishedTypebot)) return null
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.67",
|
"version": "0.0.68",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { LiteBadge } from './LiteBadge'
|
import { LiteBadge } from './LiteBadge'
|
||||||
import { createEffect, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
import { createEffect, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
||||||
import { isNotEmpty } from '@typebot.io/lib'
|
import { isNotDefined, isNotEmpty } from '@typebot.io/lib'
|
||||||
import { getInitialChatReplyQuery } from '@/queries/getInitialChatReplyQuery'
|
import { getInitialChatReplyQuery } from '@/queries/getInitialChatReplyQuery'
|
||||||
import { ConversationContainer } from './ConversationContainer'
|
import { ConversationContainer } from './ConversationContainer'
|
||||||
import { setIsMobile } from '@/utils/isMobileSignal'
|
import { setIsMobile } from '@/utils/isMobileSignal'
|
||||||
@ -92,7 +92,7 @@ export const Bot = (props: BotProps & { class?: string }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (!props.typebot || isInitialized()) return
|
if (isNotDefined(props.typebot) || isInitialized()) return
|
||||||
initializeBot().then()
|
initializeBot().then()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -20,6 +20,14 @@ export const AudioBubble = (props: Props) => {
|
|||||||
typingTimeout = setTimeout(() => {
|
typingTimeout = setTimeout(() => {
|
||||||
setIsTyping(false)
|
setIsTyping(false)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
const audioElement = ref?.querySelector('audio')
|
||||||
|
if (audioElement) {
|
||||||
|
try {
|
||||||
|
audioElement.play()
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Could not autoplay the audio:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
props.onTransitionEnd(ref?.offsetTop)
|
props.onTransitionEnd(ref?.offsetTop)
|
||||||
}, showAnimationDuration)
|
}, showAnimationDuration)
|
||||||
}, typingDuration)
|
}, typingDuration)
|
||||||
@ -49,7 +57,6 @@ export const AudioBubble = (props: Props) => {
|
|||||||
(isTyping() ? 'opacity-0' : 'opacity-100')
|
(isTyping() ? 'opacity-0' : 'opacity-100')
|
||||||
}
|
}
|
||||||
style={{ height: isTyping() ? '32px' : 'revert' }}
|
style={{ height: isTyping() ? '32px' : 'revert' }}
|
||||||
autoplay
|
|
||||||
controls
|
controls
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { InitialChatReply } from '@/types'
|
import { InitialChatReply } from '@/types'
|
||||||
import { guessApiHost } from '@/utils/guessApiHost'
|
import { guessApiHost } from '@/utils/guessApiHost'
|
||||||
import type { SendMessageInput, StartParams } from '@typebot.io/schemas'
|
import type { SendMessageInput, StartParams } from '@typebot.io/schemas'
|
||||||
import { isNotEmpty, sendRequest } from '@typebot.io/lib'
|
import { isNotDefined, isNotEmpty, sendRequest } from '@typebot.io/lib'
|
||||||
|
|
||||||
export async function getInitialChatReplyQuery({
|
export async function getInitialChatReplyQuery({
|
||||||
typebot,
|
typebot,
|
||||||
@ -13,7 +13,7 @@ export async function getInitialChatReplyQuery({
|
|||||||
}: StartParams & {
|
}: StartParams & {
|
||||||
apiHost?: string
|
apiHost?: string
|
||||||
}) {
|
}) {
|
||||||
if (!typebot)
|
if (isNotDefined(typebot))
|
||||||
throw new Error('Typebot ID is required to get initial messages')
|
throw new Error('Typebot ID is required to get initial messages')
|
||||||
|
|
||||||
return sendRequest<InitialChatReply>({
|
return sendRequest<InitialChatReply>({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.67",
|
"version": "0.0.68",
|
||||||
"description": "React library to display typebots on your website",
|
"description": "React library to display typebots on your website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
Reference in New Issue
Block a user