Giter VIP home page Giter VIP logo

botfuel-webchat-client's Introduction

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/[email protected]"></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.

botfuel-webchat-client's People

Contributors

kevinadda avatar kevindepuydt avatar louisjc avatar windkomo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

botfuel-webchat-client's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.