Deploy on the browser

The goal is to run the skill directly in the browser to achieve a conversational system

  1. Type npx webpack in the terminal

  2. You find the generated file in dist

  3. Create an index.html file:

<script src="https://unpkg.com/newbot@latest/dist/newbot.min.js"></script>
<script src="path/dist/browser"></script>

<script>
const converse = new NewBot(MainSkill)
converse.exec('Hey', (output, done) => {
    console.log(output)
    done()
})
</script>

MainSkill is a global variable in the generated file.

On browser, setting the user ID as the second parameter of the exec () method is optional

With the native NLP

  1. Put the newbot.with-nlp.min.js file

  2. Set the path to model.nlp

NLP in other languages (other than English)

Please, follow this tutorial : Web NLP

  1. Install dependencies

npm i newbot @nlpjs/lang-fr

  1. Use the modelLangs property

On-the-fly training

Use a bundler like webpack, parcel, rollup, etc. to read imports and generate a file

Use the parser

If you want to test uncompiled code directly in the browser, integrate the newbot.with-parser.min.js file instead

Beware, the newbot.with-parser.min.js file is much heavier than thenewbot.min.js file. Prefer the latter if reading uncompiled code is not necessary.

Last updated

Was this helpful?