Giter VIP home page Giter VIP logo

web-widget's Introduction

Hu:toma web-widget

Hu:toma Widget provides a rich set of client-side functionality similar to one provided by Facebook Messenger.

Local development

Please read before you start coding

Set local configuration

Add a new file called config.env.js under src/ directory in your local copy of the project. Settings can slightly vary depending on local setup, example one:

export const SERVICE = 'local.hutoma.widget';
export const HUTOMA_ORIGIN = 'https://0.0.0.0.xip.io:8443';
export const WIDGET_IFRAME_URL = 'https://0.0.0.0.xip.io:8443/widget/index.html';

Any *.env.js files are excluded in gitignore

Generate nginx certificate

In the nginx folder there are two empty files, cert.key and cert.pem, you need to populate these before you build for your local testing.

Run your local widget container using Docker

$ docker-compose up server

Enter following installation code in an online editor of your choice, at first run you'll need to accept self-signed certificates. Update the code with your bot name bot_name and my_bot_token.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Web Widget</title>
  </head>
  <body>

    <script>(function() {document.head.appendChild(Object.assign(document.createElement('script'),{
      src: 'https://0.0.0.0.xip.io:8443/widget/widget.js', type: 'module'
    }))})();</script>

    <script>
      var hutoma = window.hutoma || [];
        
      hutoma.push(['boot', 'bot_name', {
        'token': 'CLIENT_TOKEN',
        'languageCode': 'en-US'
      }]);

    </script>
  </body>
</html>

Example at Jsbin: https://jsbin.com/mucipo/edit?html,console,output

For more complex commands please check the documentation

I18l

Translations are kept in local/ directory, new can be added manually or using Poedit. During the deploy translation, JSON files are created. To create a local copy install Node packages locally or using a Node container, and run yarn run translate.

Project links

Examples

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.