IcaliaLabs / alpha

Craft your own web-based chatbot
MIT License
138 stars 76 forks source link

cannot use special charactor in the name ? #26

Open RonnSanji opened 5 years ago

RonnSanji commented 5 years ago

I use some special charactor like "?" in the name . the bot cannot reply and just hang there, how to solve this ?

kurenn commented 5 years ago

@CharlieIGG can you take a look into this?

CharlieIGG commented 5 years ago

The current basic implementation for Alpha is not hooked up to DialogFlow or any other kind of NLP @kurenn @RonnSanji.

Instead of that it tests against pre-defined patterns, such as the following:

 /My\s+name\s+is\s+([A-zÁ-ÿ]+)/i,
      /I\s+am\s+([A-zÁ-ÿ]+)/i,
      /I'm\s+([A-zÁ-ÿ]+)/i,
      /Im\s+([A-zÁ-ÿ]+)/i,
      /This\s+is\s+([A-zÁ-ÿ]+)/i,
      /(hello|hi|hey)\W?\s+My\s+name\s+is\s+([A-zÁ-ÿ]+)/i,
      /(hello|hi|hey)\W?\s+I\s+am\s+([A-zÁ-ÿ]+)/i,
      /(hello|hi|hey)\W?\s+I'm\s+([A-zÁ-ÿ]+)/i,
      /(hello|hi|hey)\W?\s+Im\s+([A-zÁ-ÿ]+)/i,
      /(hello|hi|hey)\W?\s+This\s+is\s+([A-zÁ-ÿ]+)/i,
      /(?!^hello$|^hi$|^hey$)\s*([A-zÁ-ÿ]+)/i,

We might need to add some escape routes so it doesn't get stuck. But I'm unsure as to what other RegEx patterns might be better suited.

If you want something more sophisticated, you can plug in an NLP service using the ReduxSagas included in the project, but you'll have to do some tinkering.

Thoughts @kurenn ?