Comments (13)
That is an interesting question. Yes it's possible, I've simplified the answer with this flow
The chatbot here is used like a state machine, in the default state it try to parse the user input trying to get age, gender and the occupation, when the state (the chat context variable "topic") turns into "complete" the flow proceed in the upper side of the flow. This is the purpose of the topic node
The parse node tries to extract values from the natural language, I've added just a few combination, but there's no limit
Refer to the listen node docs. For example the rule "I" + "am" + "[number]->age" is satisfied if the user sentence contains the keyword "I", the keyword "am" and a number (it doesn't matter if it's written in number or letters) and store it in the "age" variable of the chat context.
In order to catch a sentence that doesn't match anything add a rule with just "*" as last element and provide any kind of feedback.
The function node gets all variables from the chat context and redirects the flow to the right output if some variable is missing, for example if the gender is missing it goes through the second output triggering a question with inline buttons.
If all variables are present and validated, the topic is switched to "complete" and the flow is redirected in the upper part.
Here is the exported flow
from node-red-contrib-chatbot.
Awesome! Thank you so much for such a detailed explanation. Let me try this out and feedback to you.
from node-red-contrib-chatbot.
For some reason, the example that you gave is not working for me. It keeps throwing Age,, in my Telegram chat window.
from node-red-contrib-chatbot.
Also, is it possible to use the Listen node with Quick replies in FB? I've plans to add some quick replies for each question, for instance
- Fav color? (quick reply will have Red, Green, White etc)
- Fav place? (quick reply will have something like London, Paris, Singapore etc)
- Fav food? (Pasta, Pizza, etc)
from node-red-contrib-chatbot.
Hi,
Any clue on why the example flow is not working?
from node-red-contrib-chatbot.
It keeps asking the age because the listen node doesn't understand the sentence and immediately ask the first question. The example flow is quite basic.
The usability of the flow can be improved adding a final rule with just a "*" and connect that to message node that gives back a "I didn't understand" message to the user.
The listen node rules need to be constantly tuned to better understand the user input, here is the doc of the listen node
https://github.com/guidone/node-red-contrib-chatbot#parse-sentences
It uses this library for natural language processing
https://github.com/nlp-compromise/compromise
I suggest to enable the debug of listen node and check the console to see how the library split the entities of each sentence and then improves the rules for a better match
from node-red-contrib-chatbot.
What I mean was, it doesn't even prompt any questions for me. It straightaway prints on debug "Age,,," and when I notice the topic it says complete. I'm sorry, but did the flow work for you?
from node-red-contrib-chatbot.
Sorry, it worked the first time and then I cleaned up adding an extra null that was breaking
from node-red-contrib-chatbot.
Worked perfectly now. Thanks. I'll experiment with this example.
from node-red-contrib-chatbot.
Oh wait..once the variable gets stored, it wont ask me the questions second time? When I talk to the bot, it already is throwing out the recorded variables based on my previous chat.
from node-red-contrib-chatbot.
Yes the context variables are persisted unless manually removed (with the context node) or node-red is restarted
from node-red-contrib-chatbot.
Ok, I got it working by having 4 separate Context nodes right after Telegram Receiver that are set to Delete the 3 variables and the topic upon each new message received. Is there a simpler way? I tried the below function and it didn't work. Not sure if chat.delete is a valid command.
var chat = msg.chat();
chat.delete('age');
chat.delete('gender');
chat.delete('job');
chat.delete('topic');
return msg;`
from node-red-contrib-chatbot.
.remove() is the method to delete a variable from the chatcontext
from node-red-contrib-chatbot.
Related Issues (20)
- Documentation: Changelog is being populated with 'Untitled'
- Feature request: add phone number information HOT 1
- feature request: linkedin messenger
- npm ERR! errno ETIMEDOUT HOT 1
- Snyk vulnerabilities HOT 1
- Image URL param support?
- Telegram Webhook not responding
- An example of how to create mediaGroup?
- Telegram pinned_message
- MC not working in Docker HOT 1
- Viber Images
- install error on node red on pi HOT 6
- Uncaught Exception in Text node HOT 1
- Unable to install from Palette / Docker HOT 3
- Can I use this package to integrate with home-made web-app bot?
- FR: Support MarkdownV2 in Telegram messages.
- Elements not recognized
- Could not login to Mission Control
- FR: Support for Telegram reactions
- Tutorial for messenger
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-red-contrib-chatbot.