Skip to content

Listen node

Guidone edited this page Jan 30, 2020 · 4 revisions

This node is deprecated, use the NLP.js nodes

Simple keyword based language interpreter. If the inbound message matches the keywords then it's redirected to the related output

All the keywords for a row must match the input message in order to have the message go through the related output. Smaller keywords requires an exact match, longer ones match with Levehnstein algorithm (so for example the keyword "building" also matches "boilding").

If a rule is matched, the following rules are skipped and not evaluated. A rule with just a * matches everything and it's generally used as a catch-all at the end if every other rules are not matched. The node will not try to parse command-like sentences (for example /my_command)

Given these two set of tokens :ke

1 - |send| |curriculum| |vitae|
2 - |send| |cv|

then the inbound messages:

"can you send your curriculum vitae"
// MATCH
"can you send your curriculum vita"
// MATCH, takes into account small typos
"please send your cv"
// MATCH
"please send your curriculum"
// DOESN'T MATCH

Listen node is also capable of a basic simple language processing of the sentence (only available for English) and for a more specific match is possible to specify also the type for a keyword

1 - |send[verb]| |curriculum[noun]| |vitae|
2 - |send[verb]| |cv|

Available types are: word (catches everything), noun, verb, adjective, conjunction, adverb, symbol, date, determiner, person, number, email, url, currency.

Keyword types are particularly useful to search for patterns in the user's input and store them in the chat context, for example to match a sentence like "send you curriculum vitae to Peter at peter.something@gmail.com"

1 - |send[verb]| |curriculum| |to| |[person]->name| |at| |[email]->toemail|

then the inbound messages:

"can you send your curriculum vitae to John at my-email@email.com"
// MATCH
"can you send your curriculum vitae to John at my-emailATemail.com"
// DOESN'T MATCH, not a valid email
"can you send your curriculum vitae to someone at my-email@email.com"
// DOESN'T MATCH, someone is not a valid name

and in any Function node connected to the related output

var chat = msg.chat();
chat.get('name'); // -> John
chat.get('toemail'); // -> peter.something@gmail.com

or in a message node connected to the related output

Hi {{name}}, I'll send the curriculum vitae to {{toemail}}

The generic syntax of a token is text-to-match[type]->variable:

  • text-to-match: the text to match
  • type: the type of token (verb, number, url, etc.)
  • variable: the variable name to store the value into

Available types:

  • word: matches everything
  • adjective, conjunction, adverb, preposition, determiner: match the keyword using Levenshtein distance (the keyword "home" will match "hime" but will not match "hole")
  • symbol: Match a symbol like: &eur;, %, $, £ and #
  • number: match a number: float, integer or written in plain english (e.g. "forty two")
  • currency: match a currency (e.g. "dollars", "$", "euros", "&eur;")
  • email: match a valid email
  • url: match a valid URL address
  • verb: match a verb, if the keyword is specified it could match the exact word of the infinitive form (for example the keyword "tell[verb]" will match the sentence "I can tell" but also "I told you the truth")
  • person: Matches a person name (e.g. "Jack Frost")
  • date: Matches a date (e.g. "10th January" or "10/1/1972") and convert it to a date object. If the year or month are not specified, the current year or month will be used

Enable debug to see in terminal console how the sentence is analyzed and tokenized.

Clone this wiki locally