3.25.1 • Published 4 years ago

botfuel-webchat-client v3.25.1

Weekly downloads
62
License
Apache-2.0
Repository
-
Last release
4 years ago

Botfuel Webchat Client

Botfuel webchat client designed to work with bots made with Botfuel Bot SDK. For a more detailed documentation, see https://app.botfuel.io/docs.

We provide a HTTP poll fallback if websockets are not supported by the browser.

Install

<script> tag using CDN

jsDelivr is a global CDN delivery for JavaScript libraries.

To include the latest release:

<script src="https://cdn.jsdelivr.net/npm/botfuel-webchat-client"></script>

For older releases:

<script src="https://cdn.jsdelivr.net/npm/botfuel-webchat-client@1.0.0"></script>

Then add the following script on your page:

BotfuelWebChat.init({
    appToken: '<BOTFUEL_APP_TOKEN>'
});

Note: Register and create an app on https://app.botfuel.io to get a <BOTFUEL_APP_TOKEN>.

For development, you can also provide a custom backend:

BotfuelWebChat.init({
    appToken: '<BOTFUEL_APP_TOKEN>'
    serverUrl: 'http://localhost:7001'
});

Technologies

We mainly use:

  • React.js: UI building library
  • Syled-components: CSS-in-JS library for styling React UI components
  • Apollo: Execute GraphQL queries and subscriptions to the webchat server (https://webchat.botfuel.io).
  • Webpack: development and production builds

Development

To launch a development server, run:

yarn
yarn start

It will launch a webpack dev server.

Build for production

To build a production optimized for production, run:

yarn build:production

this is useful for testing bundle size or issues that only happen in production. It is executed by the npm publish command (prepublish hook).

Publishing

To publish package on NPM and jsdelivr, simply bump the version (according to semver) and publish it:

npm version <patch, minor, major>
npm publish

The script will automatically be available on jsdelivr.

Links in messages

By default, webchat-client automatically parses links. Links such as https://www.botfuel.io will appear as clickable anchor tags in messages.

HTML

It is possible to display HTML in messages by turning on the parseHTML option. By default it’s turned off. Dangerous HTML tags are filtered.

Useful development notes

We use Fragment on the payload field in the Message query in the WebChat/index.jsx file because it can be of several types: Text, Table, Actions, Postback, Quickreplies, BotAction and Images. The type of payload define which fields are available on it. These types are defined server-side.

In the same file, we use optimiticResponse (Apollo) when sending the use message so we immediately update UI with the message sent instead of waiting for the server’s response. This provides a better UI experience where the user can immediately see the message he typed and entered.

License

See the LICENSE file.

3.25.1

4 years ago

3.26.0

5 years ago

3.25.0

5 years ago

3.24.1

5 years ago

3.24.0

5 years ago

3.23.5

5 years ago

3.23.4

5 years ago

3.23.3

5 years ago

3.23.2

5 years ago

3.23.1

5 years ago

3.23.0

5 years ago

3.22.2

5 years ago

3.22.1

5 years ago

3.22.0

5 years ago

3.21.0

5 years ago

3.20.2

5 years ago

3.20.1

5 years ago

3.20.0

5 years ago

3.19.2

5 years ago

3.19.1

5 years ago

3.19.0

5 years ago

3.18.1

5 years ago

3.18.0

5 years ago

3.17.2

6 years ago

3.17.1

6 years ago

3.17.0

6 years ago

3.16.8

6 years ago

3.16.7

6 years ago

3.16.6

6 years ago

3.16.5

6 years ago

3.16.4

6 years ago

3.16.3

6 years ago

3.16.2

6 years ago

3.16.1

6 years ago

3.16.0

6 years ago

3.15.0

6 years ago

3.14.0

6 years ago

3.13.13

6 years ago

3.13.12

6 years ago

3.13.11

6 years ago

3.13.10

6 years ago

3.13.9

6 years ago

3.13.8

6 years ago

3.13.7

6 years ago

3.13.6

6 years ago

3.13.5

6 years ago

3.13.4

6 years ago

3.13.3

6 years ago

3.13.2

6 years ago

3.13.1

6 years ago

3.13.0

6 years ago

3.12.0

6 years ago

3.11.1

6 years ago

3.11.0

6 years ago

3.10.0

6 years ago

3.9.1

6 years ago

3.9.0

6 years ago

3.8.1

6 years ago

3.8.0

6 years ago

3.7.0

6 years ago

3.6.2

6 years ago

3.6.1

6 years ago

3.6.0

6 years ago

3.5.0

6 years ago

3.4.0

6 years ago

3.3.0

7 years ago

3.2.1

7 years ago

3.2.0

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago