♻️ (lp) Remove old bot-engine from landing page
This commit is contained in:
@@ -11,12 +11,12 @@ import {
|
|||||||
Textarea,
|
Textarea,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { TypebotViewer } from 'bot-engine'
|
|
||||||
import { PublicTypebot } from 'models'
|
import { PublicTypebot } from 'models'
|
||||||
import { sendRequest } from 'utils'
|
import { sendRequest } from 'utils'
|
||||||
import { DontIcon } from 'assets/icons/DontIcon'
|
import { DontIcon } from 'assets/icons/DontIcon'
|
||||||
import { DoIcon } from 'assets/icons/DoIcon'
|
import { DoIcon } from 'assets/icons/DoIcon'
|
||||||
import { HandDrawnArrow } from 'assets/illustrations/HandDrawnArrow'
|
import { HandDrawnArrow } from 'assets/illustrations/HandDrawnArrow'
|
||||||
|
import { Standard } from '@typebot.io/react'
|
||||||
|
|
||||||
export const IntroducingChatApps = () => {
|
export const IntroducingChatApps = () => {
|
||||||
const [typebot, setTypebot] = useState<PublicTypebot>()
|
const [typebot, setTypebot] = useState<PublicTypebot>()
|
||||||
@@ -83,18 +83,14 @@ export const IntroducingChatApps = () => {
|
|||||||
>
|
>
|
||||||
<DoIcon />
|
<DoIcon />
|
||||||
{typebot && (
|
{typebot && (
|
||||||
<Flex
|
<Standard
|
||||||
w="full"
|
typebot={typebot}
|
||||||
h="full"
|
style={{
|
||||||
minH={['600px', '0']}
|
borderRadius: '0.375rem',
|
||||||
borderWidth="1px"
|
borderWidth: '1px',
|
||||||
rounded="md"
|
height: '562px',
|
||||||
>
|
}}
|
||||||
<TypebotViewer
|
/>
|
||||||
typebot={typebot}
|
|
||||||
style={{ borderRadius: '0.375rem' }}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
)}
|
)}
|
||||||
<Flex top="-20px" right="40px" pos="absolute">
|
<Flex top="-20px" right="40px" pos="absolute">
|
||||||
<Text fontFamily="'Indie Flower'" fontSize="2xl">
|
<Text fontFamily="'Indie Flower'" fontSize="2xl">
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import { Flex, Stack, Heading, Text, Button, VStack } from '@chakra-ui/react'
|
import { Flex, Stack, Heading, Text, Button, VStack } from '@chakra-ui/react'
|
||||||
|
import { Standard } from '@typebot.io/react'
|
||||||
import { ArrowRight } from 'assets/icons/ArrowRight'
|
import { ArrowRight } from 'assets/icons/ArrowRight'
|
||||||
import { TypebotViewer } from 'bot-engine'
|
|
||||||
import { PublicTypebot, Typebot } from 'models'
|
import { PublicTypebot, Typebot } from 'models'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { sendRequest } from 'utils'
|
import { sendRequest } from 'utils'
|
||||||
|
|
||||||
|
const nameBlockId = 'shuUtMDMw9P4iAHbz7B5SqJ'
|
||||||
|
const messageBlockId = 'sqvXpT1YXE3Htp6BCPvVGv3'
|
||||||
|
|
||||||
export const RealTimeResults = () => {
|
export const RealTimeResults = () => {
|
||||||
const iframeRef = useRef<HTMLIFrameElement | null>(null)
|
const iframeRef = useRef<HTMLIFrameElement | null>(null)
|
||||||
const [typebot, setTypebot] = useState<PublicTypebot>()
|
const [typebot, setTypebot] = useState<PublicTypebot>()
|
||||||
@@ -21,25 +24,19 @@ export const RealTimeResults = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchTemplate()
|
fetchTemplate()
|
||||||
window.addEventListener('message', processMessage)
|
|
||||||
const interval = setInterval(refreshIframeContent, 30000)
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clearInterval(interval)
|
|
||||||
window.removeEventListener('message', processMessage)
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const processMessage = (event: MessageEvent) => {
|
|
||||||
if (event.data.from === 'typebot') refreshIframeContent()
|
|
||||||
}
|
|
||||||
|
|
||||||
const refreshIframeContent = () => {
|
const refreshIframeContent = () => {
|
||||||
if (!iframeRef.current) return
|
if (!iframeRef.current) return
|
||||||
iframeRef.current.src += ''
|
iframeRef.current.src += ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleAnswer = ({ blockId }: { blockId: string }) => {
|
||||||
|
if ([nameBlockId, messageBlockId].includes(blockId)) {
|
||||||
|
refreshIframeContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex as="section" justify="center">
|
<Flex as="section" justify="center">
|
||||||
<Stack
|
<Stack
|
||||||
@@ -91,13 +88,15 @@ export const RealTimeResults = () => {
|
|||||||
data-aos="fade"
|
data-aos="fade"
|
||||||
>
|
>
|
||||||
{typebot && (
|
{typebot && (
|
||||||
<Flex w="full" h="full" minH="300" borderWidth="1px" rounded="md">
|
<Standard
|
||||||
<TypebotViewer
|
typebot={typebot}
|
||||||
typebot={typebot}
|
onAnswer={handleAnswer}
|
||||||
style={{ borderRadius: '0.375rem' }}
|
style={{
|
||||||
apiHost="https://typebot.io"
|
borderRadius: '0.375rem',
|
||||||
/>
|
borderWidth: '1px',
|
||||||
</Flex>
|
height: '533px',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<iframe
|
<iframe
|
||||||
ref={iframeRef}
|
ref={iframeRef}
|
||||||
|
|||||||
@@ -2,76 +2,69 @@
|
|||||||
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
||||||
enabled: process.env.ANALYZE === 'true',
|
enabled: process.env.ANALYZE === 'true',
|
||||||
})
|
})
|
||||||
const withTM = require('next-transpile-modules')([
|
|
||||||
'utils',
|
|
||||||
'models',
|
|
||||||
'bot-engine',
|
|
||||||
])
|
|
||||||
|
|
||||||
const pages = ['pricing', 'privacy-policies', 'terms-of-service', 'about']
|
const pages = ['pricing', 'privacy-policies', 'terms-of-service', 'about']
|
||||||
|
|
||||||
module.exports = withTM(
|
module.exports = withBundleAnalyzer({
|
||||||
withBundleAnalyzer({
|
transpilePackages: ['utils', 'models'],
|
||||||
async redirects() {
|
async redirects() {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
source: '/typebot-lib',
|
||||||
|
destination:
|
||||||
|
'https://unpkg.com/typebot-js@2.0.21/dist/index.umd.min.js',
|
||||||
|
permanent: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: '/typebot-lib/v2',
|
||||||
|
destination: 'https://unpkg.com/typebot-js@2.1.3/dist/index.umd.min.js',
|
||||||
|
permanent: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
async rewrites() {
|
||||||
|
return {
|
||||||
|
beforeFiles: [
|
||||||
{
|
{
|
||||||
source: '/typebot-lib',
|
source: '/_next/static/:static*',
|
||||||
destination:
|
destination:
|
||||||
'https://unpkg.com/typebot-js@2.0.21/dist/index.umd.min.js',
|
process.env.NEXT_PUBLIC_VIEWER_URL + '/_next/static/:static*',
|
||||||
permanent: true,
|
has: [
|
||||||
},
|
|
||||||
{
|
|
||||||
source: '/typebot-lib/v2',
|
|
||||||
destination:
|
|
||||||
'https://unpkg.com/typebot-js@2.1.3/dist/index.umd.min.js',
|
|
||||||
permanent: true,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
async rewrites() {
|
|
||||||
return {
|
|
||||||
beforeFiles: [
|
|
||||||
{
|
|
||||||
source: '/_next/static/:static*',
|
|
||||||
destination:
|
|
||||||
process.env.NEXT_PUBLIC_VIEWER_URL + '/_next/static/:static*',
|
|
||||||
has: [
|
|
||||||
{
|
|
||||||
type: 'header',
|
|
||||||
key: 'referer',
|
|
||||||
value:
|
|
||||||
process.env.LANDING_PAGE_HOST +
|
|
||||||
'/(?!' +
|
|
||||||
pages.join('|') +
|
|
||||||
'|\\?).+',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
fallback: [
|
|
||||||
{
|
|
||||||
source: '/:typebotId*',
|
|
||||||
destination: process.env.NEXT_PUBLIC_VIEWER_URL + '/:typebotId*',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: '/api/:path*',
|
|
||||||
destination: process.env.NEXT_PUBLIC_VIEWER_URL + '/api/:path*',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
headers: async () => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
source: '/(.*)?',
|
|
||||||
headers: [
|
|
||||||
{
|
{
|
||||||
key: 'X-Frame-Options',
|
type: 'header',
|
||||||
value: 'DENY',
|
key: 'referer',
|
||||||
|
value:
|
||||||
|
process.env.LANDING_PAGE_HOST +
|
||||||
|
'/(?!' +
|
||||||
|
pages.join('|') +
|
||||||
|
'|\\?).+',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
fallback: [
|
||||||
})
|
{
|
||||||
)
|
source: '/:typebotId*',
|
||||||
|
destination: process.env.NEXT_PUBLIC_VIEWER_URL + '/:typebotId*',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: '/api/:path*',
|
||||||
|
destination: process.env.NEXT_PUBLIC_VIEWER_URL + '/api/:path*',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headers: async () => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: '/(.*)?',
|
||||||
|
headers: [
|
||||||
|
{
|
||||||
|
key: 'X-Frame-Options',
|
||||||
|
value: 'DENY',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|||||||
@@ -15,8 +15,9 @@
|
|||||||
"@emotion/react": "11.10.5",
|
"@emotion/react": "11.10.5",
|
||||||
"@emotion/styled": "11.10.5",
|
"@emotion/styled": "11.10.5",
|
||||||
"@vercel/analytics": "0.1.8",
|
"@vercel/analytics": "0.1.8",
|
||||||
|
"@typebot.io/react": "workspace:*",
|
||||||
|
"@typebot.io/js": "workspace:*",
|
||||||
"aos": "2.3.4",
|
"aos": "2.3.4",
|
||||||
"bot-engine": "workspace:*",
|
|
||||||
"db": "workspace:*",
|
"db": "workspace:*",
|
||||||
"focus-visible": "5.2.0",
|
"focus-visible": "5.2.0",
|
||||||
"framer-motion": "8.5.0",
|
"framer-motion": "8.5.0",
|
||||||
|
|||||||
@@ -110,7 +110,8 @@
|
|||||||
"groupId": "o4SH1UtKANnW5N5D67oZUz",
|
"groupId": "o4SH1UtKANnW5N5D67oZUz",
|
||||||
"options": {
|
"options": {
|
||||||
"labels": { "button": "Send", "placeholder": "Type your email..." },
|
"labels": { "button": "Send", "placeholder": "Type your email..." },
|
||||||
"variableId": "3VFChNVSCXQ2rXv4DrJ8Ah"
|
"variableId": "3VFChNVSCXQ2rXv4DrJ8Ah",
|
||||||
|
"retryMessageContent": "This email doesn't seem to be valid. Can you type it again?"
|
||||||
},
|
},
|
||||||
"outgoingEdgeId": "w3MiN1Ct38jT5NykVsgmb5"
|
"outgoingEdgeId": "w3MiN1Ct38jT5NykVsgmb5"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,12 +37,16 @@ export const executeWebhookBlock = async (
|
|||||||
where: { id: block.webhookId },
|
where: { id: block.webhookId },
|
||||||
})) as Webhook | null
|
})) as Webhook | null
|
||||||
if (!webhook) {
|
if (!webhook) {
|
||||||
|
log = {
|
||||||
|
status: 'error',
|
||||||
|
description: `Couldn't find webhook with id ${block.webhookId}`,
|
||||||
|
}
|
||||||
result &&
|
result &&
|
||||||
(await saveErrorLog({
|
(await saveErrorLog({
|
||||||
resultId: result.id,
|
resultId: result.id,
|
||||||
message: `Couldn't find webhook`,
|
message: log.description,
|
||||||
}))
|
}))
|
||||||
return { outgoingEdgeId: block.outgoingEdgeId }
|
return { outgoingEdgeId: block.outgoingEdgeId, logs: [log] }
|
||||||
}
|
}
|
||||||
const preparedWebhook = prepareWebhookAttributes(webhook, block.options)
|
const preparedWebhook = prepareWebhookAttributes(webhook, block.options)
|
||||||
const resultValues = result && (await getResultValues(result.id))
|
const resultValues = result && (await getResultValues(result.id))
|
||||||
|
|||||||
@@ -11,26 +11,27 @@ const hostElementCss = `
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const Standard = (props: BotProps) => {
|
export const Standard = (
|
||||||
|
props: BotProps,
|
||||||
|
{ element }: { element: HTMLElement }
|
||||||
|
) => {
|
||||||
const [isBotDisplayed, setIsBotDisplayed] = createSignal(false)
|
const [isBotDisplayed, setIsBotDisplayed] = createSignal(false)
|
||||||
|
|
||||||
const launchBot = () => {
|
const launchBot = () => {
|
||||||
setIsBotDisplayed(true)
|
setIsBotDisplayed(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const observer = new IntersectionObserver((intersections) => {
|
const botLauncherObserver = new IntersectionObserver((intersections) => {
|
||||||
if (intersections.some((intersection) => intersection.isIntersecting))
|
if (intersections.some((intersection) => intersection.isIntersecting))
|
||||||
launchBot()
|
launchBot()
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const standardElement = document.querySelector('typebot-standard')
|
botLauncherObserver.observe(element)
|
||||||
if (!standardElement) return
|
|
||||||
observer.observe(standardElement)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
observer.disconnect()
|
botLauncherObserver.disconnect()
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { Standard } from './features/standard'
|
|||||||
|
|
||||||
export const registerWebComponents = () => {
|
export const registerWebComponents = () => {
|
||||||
if (typeof window === 'undefined') return
|
if (typeof window === 'undefined') return
|
||||||
|
// @ts-expect-error element incorect type
|
||||||
customElement('typebot-standard', defaultBotProps, Standard)
|
customElement('typebot-standard', defaultBotProps, Standard)
|
||||||
customElement('typebot-bubble', defaultBubbleProps, Bubble)
|
customElement('typebot-bubble', defaultBubbleProps, Bubble)
|
||||||
customElement('typebot-popup', defaultPopupProps, Popup)
|
customElement('typebot-popup', defaultPopupProps, Popup)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable solid/reactivity */
|
||||||
import { BubbleProps } from './features/bubble'
|
import { BubbleProps } from './features/bubble'
|
||||||
import { PopupProps } from './features/popup'
|
import { PopupProps } from './features/popup'
|
||||||
import { BotProps } from './components/Bot'
|
import { BotProps } from './components/Bot'
|
||||||
@@ -10,10 +11,10 @@ import {
|
|||||||
toggle,
|
toggle,
|
||||||
} from './features/commands'
|
} from './features/commands'
|
||||||
|
|
||||||
export const initStandard = (
|
export const initStandard = (props: BotProps & { id?: string }) => {
|
||||||
props: BotProps & { style?: string; class?: string }
|
const standardElement = props.id
|
||||||
) => {
|
? document.getElementById(props.id)
|
||||||
const standardElement = document.querySelector('typebot-standard')
|
: document.querySelector('typebot-standard')
|
||||||
if (!standardElement) throw new Error('<typebot-standard> element not found.')
|
if (!standardElement) throw new Error('<typebot-standard> element not found.')
|
||||||
Object.assign(standardElement, props)
|
Object.assign(standardElement, props)
|
||||||
}
|
}
|
||||||
|
|||||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@@ -291,13 +291,14 @@ importers:
|
|||||||
'@emotion/react': 11.10.5
|
'@emotion/react': 11.10.5
|
||||||
'@emotion/styled': 11.10.5
|
'@emotion/styled': 11.10.5
|
||||||
'@next/bundle-analyzer': 13.1.4
|
'@next/bundle-analyzer': 13.1.4
|
||||||
|
'@typebot.io/js': workspace:*
|
||||||
|
'@typebot.io/react': workspace:*
|
||||||
'@types/aos': 3.0.4
|
'@types/aos': 3.0.4
|
||||||
'@types/node': 18.11.18
|
'@types/node': 18.11.18
|
||||||
'@types/react': 18.0.27
|
'@types/react': 18.0.27
|
||||||
'@vercel/analytics': 0.1.8
|
'@vercel/analytics': 0.1.8
|
||||||
aos: 2.3.4
|
aos: 2.3.4
|
||||||
autoprefixer: 10.4.13
|
autoprefixer: 10.4.13
|
||||||
bot-engine: workspace:*
|
|
||||||
cross-env: 7.0.3
|
cross-env: 7.0.3
|
||||||
db: workspace:*
|
db: workspace:*
|
||||||
eslint: 8.32.0
|
eslint: 8.32.0
|
||||||
@@ -319,9 +320,10 @@ importers:
|
|||||||
'@chakra-ui/react': 2.4.9_ldho2is67tyoj4oiqudu5lhoj4
|
'@chakra-ui/react': 2.4.9_ldho2is67tyoj4oiqudu5lhoj4
|
||||||
'@emotion/react': 11.10.5_yxdp3dl3eazy3vwpbmv4fq727a
|
'@emotion/react': 11.10.5_yxdp3dl3eazy3vwpbmv4fq727a
|
||||||
'@emotion/styled': 11.10.5_4erqsq3n444jecyuvaxwc5b3vi
|
'@emotion/styled': 11.10.5_4erqsq3n444jecyuvaxwc5b3vi
|
||||||
|
'@typebot.io/js': link:../../packages/js
|
||||||
|
'@typebot.io/react': link:../../packages/react
|
||||||
'@vercel/analytics': 0.1.8_react@18.2.0
|
'@vercel/analytics': 0.1.8_react@18.2.0
|
||||||
aos: 2.3.4
|
aos: 2.3.4
|
||||||
bot-engine: link:../../packages/bot-engine
|
|
||||||
db: link:../../packages/db
|
db: link:../../packages/db
|
||||||
focus-visible: 5.2.0
|
focus-visible: 5.2.0
|
||||||
framer-motion: 8.5.0_biqbaboplfbrettd7655fr4n2y
|
framer-motion: 8.5.0_biqbaboplfbrettd7655fr4n2y
|
||||||
|
|||||||
Reference in New Issue
Block a user