2023-01-09 14:51:36 +01:00
|
|
|
import { Bubble } from '@/Bubble'
|
|
|
|
import {
|
|
|
|
open,
|
|
|
|
toggle,
|
|
|
|
close,
|
|
|
|
showPreviewMessage,
|
|
|
|
hidePreviewMessage,
|
|
|
|
setPrefilledVariables,
|
|
|
|
} from '@typebot.io/js'
|
|
|
|
import { useState } from 'react'
|
2023-01-25 11:27:47 +01:00
|
|
|
import { leadGenerationTypebot } from './assets/leadGenerationTypebot'
|
2023-01-09 14:51:36 +01:00
|
|
|
|
|
|
|
export const Default = () => {
|
|
|
|
const [name, setName] = useState('John')
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
|
|
<button onClick={toggle}>Toggle chat window</button>
|
|
|
|
<button onClick={open}>Open chat window</button>
|
|
|
|
<button onClick={close}>Close chat window</button>
|
|
|
|
<button onClick={() => showPreviewMessage()}>
|
|
|
|
Show Preview Message
|
|
|
|
</button>
|
|
|
|
<button onClick={hidePreviewMessage}>Close Preview Message</button>
|
|
|
|
<div>
|
|
|
|
<p>Predefined name:</p>
|
|
|
|
<input value={name} onChange={(e) => setName(e.target.value)} />
|
|
|
|
<button onClick={() => setPrefilledVariables({ Name: name })}>
|
|
|
|
Set predefined name
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<Bubble
|
2023-01-25 11:27:47 +01:00
|
|
|
typebot={leadGenerationTypebot}
|
2023-01-09 14:51:36 +01:00
|
|
|
apiHost="http://localhost:3001"
|
|
|
|
prefilledVariables={{
|
|
|
|
Name: 'John',
|
|
|
|
}}
|
|
|
|
previewMessage={{
|
|
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/16015833?v=4',
|
|
|
|
message: 'Hello, I am a preview message',
|
|
|
|
autoShowDelay: 3000,
|
|
|
|
}}
|
2023-01-16 12:13:21 +01:00
|
|
|
theme={{
|
|
|
|
button: {
|
|
|
|
backgroundColor: '#FF7537',
|
2023-01-25 11:27:47 +01:00
|
|
|
iconColor: 'white',
|
2023-01-09 14:51:36 +01:00
|
|
|
},
|
|
|
|
}}
|
2023-01-16 12:13:21 +01:00
|
|
|
isPreview
|
2023-01-09 14:51:36 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|