Hello! I need help in making a chatbot. Basically my problem is that I would like to add in my chatbot that when the user says Bye or GoodBye the Bot says nice talking to you and the application closes. I have no clue how to do that. And I also want my bot to talk and write at the same time. Lastly, I also want to console the user when the user says that he/she is feeling sad or stressed by saying words like don't worry and then recommend some meditation or yoga for the user. I would really appreciate it if anyone could help me with this. Thanks in advance.
You are trying to recreate the Eliza program.
Study the text Contains block. It's very useful for detecting particular words in sentences.
Also, it is easy to downcase the input to help avoid case mismatches.
Another helpful combination is the split at spaces block, in combination with the is in list block.
Thanks for the speedy reply. Thank you it worked out well. Thanks again.
There was one more thing I wanted to ask that I wanted the Bot to speak but when I add text to speech component it speaks the whole conversation. I just want it to say it's line that it just wrote not the whole thing. Like if I write "How are you?" and the Bot writes " I am good." Now it should speak "I am good" only not "How are you?" along with "I am good." Can we make this happen. I would really appreciate if you could help me in this.
Without your new blocks, all I could advise would be to keep the user input separate from your response, and only send your response to speech output.
You may need an extra local variable for that.
Thanks for the efficient reply.
But can you please elaborate how I can do that?
Please download and post each of those event block(s)/procedures here ...
(sample video)
Those blocks are not draggable.
Post your .aia if you can't post draggable blocks.
You need an extra output Label under your log Label, just to hold the latest reply.
This .Text value should be sent to voice output.
(I don't have the .aia file, so I can't do it for you.)
I got it working without the extra Label.
However, I had to abandon the obsolete stock AI2 emulator because it could not handle the new replace all mappings text block (a java lang error), and instead use a version 4.1.1 GenyMotion emulator.
Here are the new blocks:
ChatBot_ABG.aia (65.7 KB)
I renamed a button to identify its function.
These blocks should be draggable.
Thanks it worked but I have another problem regarding the chatbot Eliza. The problem is that I want to close the screen when the user types "Bye" "Goodbye". I can do it but the output is like this
Be well have a nice day!
Bot: Be well have a nice day!
These are the dragable blocks
this is the .aia file
ChatBot_ABG (1).aia (65.2 KB)
The problem might have been from setting a value in a label then expecting it to be there immediately.
Here is some alternate logic, using the After Speaking event to check a global true/false flag to see if it is time to shut down the app. (change the action to fit your screen usage.)
All blocks are draggable.
I did each and everything you said but it did not work. I really don't know what the problem is with it.
Be sure to compile this as an apk.
it won't close in the Companion.
Also, don't ask to open Screens that aren't there. (MainScreen?)
Also, testing for "Bye" is very restrictive. It is looser to downcase the text and test for "bye".
Here is working code and proof ...
video (click it to watch all 28 seconds)
I think I was not able to explain my problem correctly. Basically when the application is closed the output is " Be well have a nice day!
Bot: Be well have a nice day!"
Now I only want the output to be "Bot: Be well have a nice day!" But the output that is coming is given above. And I want the bot to speak "Be well have a nice day!" That the bot is doing right now but the output is not what I want plus all the chat I have the bot also disappears when I say "bye". That should not happen as well but it is happening.
All that logic is in the if/then block that tests for "bye".
You should be able to read and understand what I coded there by now, and
to modify it to fit your personal tastes.
Remember, this is a do it yourself and learning site.
If there are individual blocks you don't understand, hover over them in the Blocks Editor and read the tool tips.
Sure. Thanks for your help!!! I really appreciate all of what you have done to me. Thank you again