Jovo platform web - input


#1

Hi everybody!

I have a problem. I am trying to create a chatbot, integrated in an ionic app, but I have a big problem:
jovo doesn’t recognize correctly my inputs in phrases, so it return me a error.

How can I resolve this problem?

@jan


#3

Hi @Simone_Leo, welcome to the Jovo community :tada:

Could you elaborate a bit more where you’re running into problems? Could you share relevant request JSONs and error messages?


#4

Hi @jan,
Yes, now I try to explain better.
In my app.js I have:

const webPlatform = new WebPlatform();

webPlatform.use(new NlpjsNlu({ 
  languages: ['it'],
 }));

app.use(
  webPlatform,
  new JovoDebugger(),
  new FileDb()
);


So, in this project I have a web platform, made in Ionic.

My question is: since I don’t use Alexa or Dialogflow, when creating an intent, what kind of inputs should I assign to it? How do I create an intent with variables?
{
“name”: “TestIntent”,
“phrases”: [
“I have {number} apple”
],
“inputs”: [
{
“name”: “number”,
“type”: // what’s the correct type?
}
]
}

Moreover, jovo confuses intents, if I use a word that is contained in two different sentences of two different intents, it doesn’t know which intent I’m referring to.


#5

@jan The error that I have is this:

Error -----------------------------------------------------------------

Code:
ERR_NO_ROUTE

Message:
Could not find the route “StartState.GetHoursIntent” in your handler function.

Stack:
Error: Could not find the route “StartState.GetHoursIntent” in your handler function.
at Function.applyHandle (/Users/simoneleo/Development/jovo/vcare-chatbot-jovo/node_modules/jovo-core/src/plugins/Handler.ts:165:15)
at handle (/Users/simoneleo/Development/jovo/vcare-chatbot-jovo/node_modules/jovo-core/src/plugins/Handler.ts:241:19)

Module:
jovo-framework


Request details:
this.$webApp initialized
this.$type: {“type”:“INTENT”}
this.$session.$data : {“JOVO_STATE”:“StartState”,“phrase”:“Quante ore hai dormito nella notte precedente?”}
this.$nlu : {“intent”:{“name”:“GetHoursIntent”},“NlpjsNlu”:{“locale”:“it”,“utterance”:“Dire quante ore ho dormito”,“languageGuessed”:false,“localeIso2”:“it”,“language”:“Italian”,“nluAnswer”:{“classifications”:[{“intent”:“GetHoursIntent”,“score”:1},{“intent”:“YesIntent”,“score”:0},{“intent”:“RoutingIntent”,“score”:0},{“intent”:“NoIntent”,“score”:0}]},“classifications”:[{“intent”:“GetHoursIntent”,“score”:1},{“intent”:“YesIntent”,“score”:0},{“intent”:“RoutingIntent”,“score”:0},{“intent”:“NoIntent”,“score”:0}],“intent”:“GetHoursIntent”,“score”:1,“domain”:“default”,“sourceEntities”:[],“entities”:[{“start”:0,“end”:25,“len”:26,“levenshtein”:0,“accuracy”:1,“entity”:“state”,“type”:“enum”,“option”:“Dire quante ore ho dormito”,“sourceText”:“Dire quante ore ho dormito”,“utteranceText”:“Dire quante ore ho dormito”}],“answers”:[],“actions”:[],“sentiment”:{“score”:0,“numWords”:0,“numHits”:0,“average”:0,“locale”:“it”,“vote”:“neutral”}}}
this.$inputs : {“state”:{“key”:“Dire quante ore ho dormito”,“name”:“Dire quante ore ho dormito”,“value”:“Dire quante ore ho dormito”}}


#6

Seems like you don’t have StartState.GetHoursIntent in your app.js, could you take a look there?


#7

Here’s a workaround for numbers using Nlp.js: https://github.com/jovotech/jovo-starter-web-standalone/issues/5


#8

If I need other types of variables, different of number, what I need to do?


#9

Add them as input type: https://www.jovo.tech/marketplace/jovo-model#input-types


#10

Sorry @jan, I didn’t understand a thing. I do the the workaround how the example

const nlpjsNlu = new NlpjsNlu({
  setupModelCallback: async (handleRequest, nlp) => {
    // force entity extraction
    nlp.forceNER = true;
    // register module for entity extraction
    nlp.container.use(BuiltinDefault, 'extract-builtin');
    // register module for English
    nlp.use(LangEn);
    // add corpus via path to the models directory
    // you might change it to pass an absolute path
    nlpjsNlu.addCorpus('./models');
  },
});

But in the models file, how can I do the intent?

{
      "name": "GetHoursIntent",
      "phrases": [
        "I slept {hours} hours"
      ],
      "inputs": [
        {
          "name": "hours",
          "type": {
            // what is the correct type?
          }
        }
      ]
    }

#11

also, with the workaround I get this error:

unhandledRejection
  {}
  Error: ENOENT: no such file or directory, scandir './models/it-IT.json'
  {"errno":-2,"code":"ENOENT","syscall":"scandir","path":"./models/it-IT.json"}
  Error: ENOENT: no such file or directory, scandir './models/it-IT.json'
  {"errno":-2,"code":"ENOENT","syscall":"scandir","path":"./models/it-IT.json"}

#12

With this workaround it doesn’t find the intent

Error -----------------------------------------------------------------
  
  Code:
  ERR_NO_ROUTE
  
  Message:
  Could not find the route "StartState.None" in your handler function.
  
  Stack:
  Error: Could not find the route "StartState.None" in your handler function.
      at Function.applyHandle (/Users/simoneleo/Development/jovo/vcare-chatbot-jovo/node_modules/jovo-core/src/plugins/Handler.ts:165:15)
      at handle (/Users/simoneleo/Development/jovo/vcare-chatbot-jovo/node_modules/jovo-core/src/plugins/Handler.ts:241:19)
  
  Module:
  jovo-framework
  
   ----------------------------------------------------------------------
  
  
  Request details:
  this.$webApp initialized
  this.$type: {"type":"INTENT"}
  this.$session.$data : {"_JOVO_STATE_":"StartState"}
  this.$nlu : {"intent":{"name":"None"},"NlpjsNlu":{"locale":"it","utterance":"Dire quante ore ho dormito","languageGuessed":false,"localeIso2":"it","language":"Italian","classifications":[],"intent":"None","score":1,"entities":[],"answers":[],"actions":[],"sentiment":{"score":0,"numWords":5,"numHits":0,"average":0,"type":"pattern","locale":"it","vote":"neutral"}}}
  this.$inputs : {}
--------------
{
   "version": "3.4.0",
   "actions": [
      {
         "plain": "error!",
         "ssml": "<speak>error!</speak>",
         "type": "SPEECH"
      }
   ],
   "reprompts": [],
   "user": {
      "data": {}
   },
   "session": {
      "data": {},
      "end": true
   },
   "context": {
      "request": {
         "nlu": {
            "intent": {
               "name": "None"
            }
         }
      }
   }
}

#13

I think in this example, it would be

"type": { "nlpjs": "number" } 

And for the next one:

It apparently triggered the None intent, which means NLPjs couldn’t find a match for your input. You can make sure the app doesn’t throw an error then by adding None (or UNHANDLED) to your handler


#14

For the workaround, did you follow all the necessary steps and adjust for your example? https://github.com/jovotech/jovo-starter-web-standalone/issues/5#issuecomment-866085494

e.g. the language package @nlpjs/lang-en needs to be replaced with @nlpjs/lang-it for you


#15

Thank you @jan
Last thing, in the workaround’s example, at last it does

nlpjsNlu.addCorpus('./models');

The ‘./models’ is the path of the models file? In my case it-IT.json?
Can you send me an example of this specific models file please?


#16

Have you tried it with a few things, like ./models/it-IT?


#17

Yes, but I have an error in console like “path not find”
@jan


#18

Is your model in ./models/it-IT relatively from the src folder? Might be possible that you need to adjust the path. I think the code example assumes that the language model is in src/models/it-IT


#19

My models file is out the src folder. So should I add it to the src folder?

02


#20

Yes, you could do that


#21

Thank you @jan