0.2.81 • Published 14 days ago

@typebot.io/js v0.2.81

Weekly downloads
-
License
MIT
Repository
-
Last release
14 days ago

Typebot JS library

Frontend library to embed typebots from Typebot.

Installation

Using npm

To install, simply run:

npm install @typebot.io/js

Directly in your HTML

<script type="module">
  import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.2/dist/web.js'

  Typebot.initStandard({
    typebot: 'my-typebot',
  })
</script>

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

Standard

You can get the standard HTML and Javascript code by clicking on the "HTML & Javascript" button in the "Share" tab of your typebot.

There, you can change the container dimensions. Here is a code example:

<script type="module">
  import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.2/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.

Popup

You can get the popup HTML and Javascript code by clicking on the "HTML & Javascript" button in the "Share" tab of your typebot.

Here is an example:

<script type="module">
  import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.2/dist/web.js'

  Typebot.initPopup({
    typebot: 'my-typebot',
    apiHost: 'http://localhost:3001',
    autoShowDelay: 3000,
  })
</script>

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

Open or Close a popup

You can use these commands:

Typebot.open()
Typebot.close()
Typebot.toggle()

You can bind these commands on a button element, for example:

<button onclick="Typebot.open()">Contact us</button>

Bubble

You can get the bubble HTML and Javascript code by clicking on the "HTML & Javascript" button in the "Share" tab of your typebot.

Here is an example:

<script type="module">
  import Typebot from 'https://cdn.jsdelivr.net/npm/@typebot.io/js@0.2/dist/web.js'

  Typebot.initBubble({
    typebot: 'my-typebot',
    previewMessage: {
      message: 'I have a question for you!',
      autoShowDelay: 5000,
      avatarUrl: 'https://avatars.githubusercontent.com/u/16015833?v=4',
    },
    theme: {
      button: { backgroundColor: '#0042DA', iconColor: '#FFFFFF' },
      previewMessage: { backgroundColor: '#ffffff', textColor: 'black' },
      chatWindow: { backgroundColor: '#ffffff' },
    },
  })
</script>

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:

Typebot.showPreviewMessage()
Typebot.hidePreviewMessage()

Open or close the typebot

You can use these commands:

Typebot.open()
Typebot.close()
Typebot.toggle()

You can bind these commands on a button element, for example:

<button onclick="Typebot.open()">Contact us</button>

Additional configuration

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

Typebot.initStandard({
  typebot: 'my-typebot',
  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.

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.

0.2.81

14 days ago

0.2.80

15 days ago

0.2.79

15 days ago

0.2.78

15 days ago

0.2.77

16 days ago

0.2.76

21 days ago

0.2.75

22 days ago

0.2.74

22 days ago

0.2.73

24 days ago

0.2.72

27 days ago

0.2.71

27 days ago

0.2.70

27 days ago

0.2.69

28 days ago

0.2.68

28 days ago

0.2.67

28 days ago

0.2.66

29 days ago

0.2.65

29 days ago

0.2.64

1 month ago

0.2.63

1 month ago

0.2.62

1 month ago

0.2.61

1 month ago

0.2.60

1 month ago

0.2.59

1 month ago

0.2.58

1 month ago

0.2.57

1 month ago

0.2.56

2 months ago

0.2.55

2 months ago

0.2.54

2 months ago

0.2.53

2 months ago

0.2.52

2 months ago

0.2.51

2 months ago

0.2.50

2 months ago

0.2.49

2 months ago

0.2.48

2 months ago

0.2.47

2 months ago

0.2.46

2 months ago

0.2.45

2 months ago

0.2.44

2 months ago

0.2.43

3 months ago

0.2.42

3 months ago

0.2.41

3 months ago

0.2.40

3 months ago

0.2.39

3 months ago

0.2.38

3 months ago

0.2.37

3 months ago

0.2.36

4 months ago

0.2.35

4 months ago

0.2.34

4 months ago

0.2.33

4 months ago

0.2.32

4 months ago

0.2.30

5 months ago

0.2.31

5 months ago

0.2.29

5 months ago

0.2.27

5 months ago

0.2.28

5 months ago

0.2.26

5 months ago

0.2.25

5 months ago

0.2.24

5 months ago

0.2.23

6 months ago

0.0.80

10 months ago

0.2.22

6 months ago

0.2.21

6 months ago

0.2.20

6 months ago

0.2.19

6 months ago

0.2.17

6 months ago

0.0.73

10 months ago

0.0.74

10 months ago

0.0.75

10 months ago

0.0.76

10 months ago

0.0.77

10 months ago

0.0.78

10 months ago

0.0.79

10 months ago

0.2.16

6 months ago

0.2.15

6 months ago

0.2.14

6 months ago

0.2.13

6 months ago

0.2.12

6 months ago

0.2.11

6 months ago

0.0.70

10 months ago

0.2.10

7 months ago

0.0.71

10 months ago

0.0.72

10 months ago

0.1.30

8 months ago

0.1.31

8 months ago

0.1.32

7 months ago

0.1.33

7 months ago

0.1.34

7 months ago

0.0.66

10 months ago

0.0.67

10 months ago

0.0.68

10 months ago

0.0.69

10 months ago

0.1.27

8 months ago

0.1.28

8 months ago

0.1.29

8 months ago

0.1.20

8 months ago

0.1.21

8 months ago

0.1.22

8 months ago

0.1.23

8 months ago

0.1.24

8 months ago

0.1.25

8 months ago

0.1.26

8 months ago

0.1.16

9 months ago

0.1.17

9 months ago

0.1.18

9 months ago

0.1.19

8 months ago

0.1.10

10 months ago

0.1.11

10 months ago

0.1.12

9 months ago

0.1.13

9 months ago

0.1.14

9 months ago

0.1.15

9 months ago

0.1.0

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.9

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.2.7

7 months ago

0.2.6

7 months ago

0.2.9

7 months ago

0.2.8

7 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.5

7 months ago

0.2.4

7 months ago

0.0.63

11 months ago

0.0.64

11 months ago

0.0.65

11 months ago

0.0.45

1 year ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.62

11 months ago

0.0.60

11 months ago

0.0.61

11 months ago

0.0.59

12 months ago

0.0.51

12 months ago

0.0.52

12 months ago

0.0.53

12 months ago

0.0.54

12 months ago

0.0.55

12 months ago

0.0.56

12 months ago

0.0.57

12 months ago

0.0.50

12 months ago

0.0.48

12 months ago

0.0.49

12 months ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.20

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.3

1 year ago

0.0.15

1 year ago

0.0.9

1 year ago

0.0.16

1 year ago

0.0.8

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago