PageSourceSearch

https://botonic.io/assets/js/179ab3d2.0300c266.js

js botonic.io collected 2026-10-03 23:47:50 UTC 17,946 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[4826],{3905:(t,e,n)=>{n.d(e,{Zo:()=>u,kt:()=>k});var a=n(7294);function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,a)}return n}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function l(t,e){if(null==t)return{};var n,a,r=function(t,e){if(null==t)return{};var n,a,r={},o=Object.keys(t);for(a=0;a<o.length;a++)n=o[a],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a<o.length;a++)n=o[a],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}var s=a.createContext({}),p=function(t){var e=a.useContext(s),n=e;return t&&(n="function"==typeof t?t(e):i(i({},e),t)),n},u=function(t){var e=p(t.components);return a.createElement(s.Provider,{value:e},t.children)},d="mdxType",m={inlineCode:"code",wrapper:function(t){var e=t.children;return a.createElement(a.Fragment,{},e)}},c=a.forwardRef((function(t,e){var n=t.components,r=t.mdxType,o=t.originalType,s=t.parentName,u=l(t,["components","mdxType","originalType","parentName"]),d=p(n),c=r,k=d["".concat(s,".").concat(c)]||d[c]||m[c]||o;return n?a.createElement(k,i(i({ref:e},u),{},{components:n})):a.createElement(k,i({ref:e},u))}));function k(t,e){var n=arguments,r=e&&e.mdxType;if("string"==typeof t||r){var o=n.length,i=new Array(o);i[0]=c;var l={};for(var s in e)hasOwnProperty.call(e,s)&&(l[s]=e[s]);l.originalType=t,l[d]="string"==typeof t?t:r,i[1]=l;for(var p=2;p<o;p++)i[p]=n[p];return a.createElement.apply(null,i)}return a.createElement.apply(null,n)}c.displayName="MDXCreateElement"},3663:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>s,contentTitle:()=>i,default:()=>m,frontMatter:()=>o,metadata:()=>l,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const o={title:"Plugin NLU",id:"plugin-nlu"},i=void 0,l={unversionedId:"plugins/plugin-nlu",id:"plugins/plugin-nlu",title:"Plugin NLU",description:"---",source:"@site/docs/plugins/plugin-nlu.md",sourceDirName:"plugins",slug:"/plugins/plugin-nlu",permalink:"/docs/plugins/plugin-nlu",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/plugins/plugin-nlu.md",tags:[],version:"current",frontMatter:{title:"Plugin NLU",id:"plugin-nlu"}},s={},p=[{value:"What Does This Plugin Do?",id:"what-does-this-plugin-do",level:2},{value:"Setup",id:"setup",level:2},{value:"Install the plugin",id:"install-the-plugin",level:3},{value:"Require the Plugin",id:"require-the-plugin",level:3},{value:"Use",id:"use",level:2},{value:"Define Intents",id:"define-intents",level:3},{value:"Train the Bot",id:"train-the-bot",level:3},{value:"Define Routes with Intents",id:"define-routes-with-intents",level:3},{value:"Go Live",id:"go-live",level:3},{value:"Multilingual Support",id:"multilingual-support",level:3}],u={toc:p},d="wrapper";function m(t){let{components:e,...n}=t;return(0,r.kt)(d,(0,a.Z)({},u,n,{components:e,mdxType:"MDXLayout"}),(0,r.kt)("hr",null),(0,r.kt)("p",null,"For more information, refer to ",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("a",{parentName:"strong",href:"https://github.com/hubtype/botonic/tree/master/packages/botonic-plugin-nlu"},"GitHub")),"."),(0,r.kt)("hr",null),(0,r.kt)("h2",{id:"what-does-this-plugin-do"},"What Does This Plugin Do?"),(0,r.kt)("p",null,"Botonic Plugin NLU allows you to predict intents from the user inputs for your bot."),(0,r.kt)("p",null,"To set up a new example using Botonic Plugin NLU, you can create a bot by running the following command:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-shell"},"$ botonic new {BOT_NAME} nlu\n")),(0,r.kt)("p",null,"Alternatively, if you already have a project, you can follow the steps below to setup it up."),(0,r.kt)("h2",{id:"setup"},"Setup"),(0,r.kt)("h3",{id:"install-the-plugin"},"Install the plugin"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"From your project, enter the command ",(0,r.kt)("inlineCode",{parentName:"li"},"npm install @botonic/plugin-nlu"),". This command installs everything necessary to start working with your intents and entities.\n",(0,r.kt)("strong",{parentName:"li"},"Note"),": Windows users should first use the command\n",(0,r.kt)("inlineCode",{parentName:"li"},"npm install --global --production windows-build-tools --vs2015")," followed by ",(0,r.kt)("inlineCode",{parentName:"li"},"npm install @botonic/plugin-nlu")),(0,r.kt)("li",{parentName:"ol"},"Under the ",(0,r.kt)("inlineCode",{parentName:"li"},"src")," files of your project, create a folder called ",(0,r.kt)("inlineCode",{parentName:"li"},"nlu"),".")),(0,r.kt)("h3",{id:"require-the-plugin"},"Require the Plugin"),(0,r.kt)("p",null,"You must require the plugin in ",(0,r.kt)("inlineCode",{parentName:"p"},"src/plugins.js")," to be able to predict the intent of user inputs. You must set its ",(0,r.kt)("inlineCode",{parentName:"p"},"id")," to ",(0,r.kt)("strong",{parentName:"p"},"nlu")," for the plugin to work."),(0,r.kt)("p",null,"In case that you have trained your model with default preprocessing engines, you only need to specify the languages that you want to supp
1ort."),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"src/plugins.js")),(0,r.kt)("blockquote",null,(0,r.kt)("p",{parentName:"blockquote"},(0,r.kt)("strong",{parentName:"p"},"E.g.:"))),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-javascript"},"export const plugins = [\n  {\n    id: 'nlu',\n    resolve: require('@botonic/plugin-nlu'),\n    options: {\n      en: {},\n      es: {},\n    },\n  },\n]\n")),(0,r.kt)("p",null,"Otherwise, you ",(0,r.kt)("strong",{parentName:"p"},"must")," load also the preprocessing engines for every language used to train your models."),(0,r.kt)("blockquote",null,(0,r.kt)("p",{parentName:"blockquote"},(0,r.kt)("strong",{parentName:"p"},"E.g.:"))),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-javascript"},"import { ENTokenizer, ESTokenizer } from './nlu/preprocessing-tools/tokenizer'\n\nexport const plugins = [\n  {\n    id: 'nlu',\n    resolve: require('@botonic/plugin-nlu'),\n    options: {\n      en: {\n        tokenizer: ENTokenizer,\n      },\n      es: {\n        tokenizer: ESTokenizer,\n      },\n    },\n  },\n]\n")),(0,r.kt)("h2",{id:"use"},"Use"),(0,r.kt)("h3",{id:"define-intents"},"Define Intents"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"Under the ",(0,r.kt)("inlineCode",{parentName:"li"},"nlu")," folder, create a folder called ",(0,r.kt)("inlineCode",{parentName:"li"},"utterances"),", which will contain your multilingual intents."),(0,r.kt)("li",{parentName:"ol"},"For every language you want to support, create a folder under ",(0,r.kt)("inlineCode",{parentName:"li"},"/src/nlu/utterances")," with its language code (it must be ",(0,r.kt)("a",{parentName:"li",href:"https://iso639-3.sil.org/code_tables/639/data"},"ISO 639-1"),"). Ex: Training for English (",(0,r.kt)("inlineCode",{parentName:"li"},"en"),"), will result in the following path: ",(0,r.kt)("inlineCode",{parentName:"li"},"/src/nlu/utterances/en/"),"."),(0,r.kt)("li",{parentName:"ol"},"Add a text file for each intent you want to create by naming them ",(0,r.kt)("inlineCode",{parentName:"li"},"IntentName.txt"),"."),(0,r.kt)("li",{parentName:"ol"},"Fill them with possible ways to express each intent. ",(0,r.kt)("strong",{parentName:"li"},"Every sentence must be on a different line of the file."),"\nSee ",(0,r.kt)("a",{parentName:"li",href:"https://botonic.io/docs/concepts/nlu"},"Natural Language Understanding section")," for more information.")),(0,r.kt)("h3",{id:"train-the-bot"},"Train the Bot"),(0,r.kt)("p",null,"Now it's time to order Botonic NLU to train each intent with the provided sentences:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash"},"botonic train\n")),(0,r.kt)("blockquote",null,(0,r.kt)("p",{parentName:"blockquote"},"Alternatively you can also run ",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"strong"},"npm run train")),".")),(0,r.kt)("p",null,"After this, the bot will be able to run predictions on new input
1s.",(0,r.kt)("br",{parentName:"p"}),"\n","Every time you make changes in your utterances, you will need to run again the command above so that the changes take effect."),(0,r.kt)("h3",{id:"define-routes-with-intents"},"Define Routes with Intents"),(0,r.kt)("p",null,"Once you've defined your intents, you can use them in the routes in the same way you use ",(0,r.kt)("inlineCode",{parentName:"p"},"text"),", ",(0,r.kt)("inlineCode",{parentName:"p"},"payloads"),", and the like.\nBelow, we see how we might use them:\n",(0,r.kt)("strong",{parentName:"p"},"routes.js")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-javascript"},"import Start from './actions/start'\nimport ShowRestaurants from './actions/show-restaurants'\nimport NotFound from './actions/not-found'\nimport ShowDirections from './actions/show-directions'\nexport const routes = [\n  { input: i => i.confidence < 0.7, action: NotFound },\n  { intent: 'Greetings', action: Start },\n  { intent: 'BookRestaurant', action: ShowRestaurants },\n]\n")),(0,r.kt)("h3",{id:"go-live"},"Go Live"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"Run ",(0,r.kt)("inlineCode",{parentName:"li"},"botonic serve")," to see how the bot runs in the development environment."),(0,r.kt)("li",{parentName:"ol"},"For further details of the variables stored during the execution, open the ",(0,r.kt)("inlineCode",{parentName:"li"},"Botonic Dev Console")," by clicking on the tab in the top-left corner."),(0,r.kt)("li",{parentName:"ol"},"Deploy your bot with ",(0,r.kt)("inlineCode",{parentName:"li"},"botonic deploy"),".\nYou got a bot with a customized intent and entity recognition system!")),(0,r.kt)("h3",{id:"multilingual-support"},"Multilingual Support"),(0,r.kt)("p",null,"The pre-trained word embeddings below are supported, which means that you can train your bot in these specific languages.\nFor more information about other supported languages, feel free to contact us on ",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("a",{parentName:"strong",href:"http://botonic.slack.com"},"Slack")),"."),(0,r.kt)("p",null,"You can also generate your own word embeddings following these ",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("a",{parentName:"strong",href:"https://github.com/hubtype/botonic/tree/master/scripts"},"instructions")),"."),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:"center"},"Language"),(0,r.kt)("th",{parentName:"tr",align:"center"},"Language Code"),(0,r.kt)("th",{parentName:"tr",align:"center"},"Type","*"),(0,r.kt)("th",{parentName:"tr",align:"center"},"Dimensions"),(0,r.kt)("th",{parentName:"tr",align:"center"},"Source"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"English"),(0,r.kt)("td",{parentName:"tr",align:"center"},"en"),(0,r.kt)("td",{parentName:"tr",align:"center"},"glove"),(0,r.kt)("td",{parentName:"tr",align:"center"},"50"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/glove-50d-en.db"},"glove-50d-en")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"English"),(0,r.kt)("td",{parentName:"tr",align:"center"},"en"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-en.db"},"10k-fasttext-300d-en")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Spanish"),(0,r.kt)("td",{parentName:"tr",align:"center"},"es"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-es.db"},"10k-fasttext-300d-es")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Catalan"),(0,r.kt)("td",{parentName:"tr",align:"center"},"ca"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-ca.db"},"10k-fasttext-300d-ca")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"French"),(0,r.kt)("td",{parentName:"tr",align:"center"},"fr"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-fr.db"},"10k-fasttext-300d-fr")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Portuguese"),(0,r.kt)("td",{parentName:"tr",align:"center"},"pt"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-pt.db"},"10k-fasttext-300d-pt")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"German"),(0,r.kt)("td",{parentName:"tr",align:"center"},"de"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-de.db"},"10k-fasttext-300d-de")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Italian"),(0,r.kt)("td",{parentName:"tr",align:"center"},"it"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-it.db"},"10k-fasttext-300d-it")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Hindi"),(0,r.kt)("td",{parentName:"tr",align:"center"},"hi"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-hi.db"},"10k-fasttext-300d-hi")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Indonesian"),(0,r.kt)("td",{parentName:"tr",align:"center"},"id"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-id.db"},"10k-fasttext-300d-id")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Russian"),(0,r.kt)("td",{parentName:"tr",align:"center"},"ru"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-ru.db"},"10k-fasttext-300d-ru")))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:"center"},"Turkish"),(0,r.kt)("td",{parentName:"tr",align:"center"},"tr"),(0,r.kt)("td",{parentName:"tr",align:"center"},"10k-fasttext"),(0,r.kt)("td",{parentName:"tr",align:"center"},"300"),(0,r.kt)("td",{parentName:"tr",align:"center"},(0,r.kt)("strong",{parentName:"td"},(0,r.kt)("a",{parentName:"strong",href:"https://s3-eu-west-1.amazonaws.com/word-embeddings.hubtype.com/10k-fasttext-300d-tr.db"},"10k-fasttext-300d-tr")))))),(0,r.kt)("p",null,(0,r.kt)("em",{parentName:"p"},"*","10k-fasttext word embeddings contain the 10k most commons words of the language.")),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Note:")," All the word embeddings are stored by default in ",(0,r.kt)("inlineCode",{parentName:"p"},"~/.botonic/word-embeddings/"),". If you encounter any issues when automatically downloading word embeddings, you can download them manually and store them in the mentioned directory."))}m.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.