I am trying to implement to read user input from one action and to read in other screen, like:
user: xx
Bixby: who's there?
user: yyy
Bixby: yyy who?
I am able to read user input yyy but unable to pass in different actions to display yyy who.
can you please help or guide what I am doing wrong or what will be best approach to do this kind of capsules?
Thanks in advance.
This is how I would model the behavior of what you are probably trying to achieve.
Concepts
- Joke
- JokeQuestion (posed by 'Bixby')
- JokeAnswer (answered by User)
Views
- JokeResultView
- JokeAnswerInputView
Layouts
- JokeLayout
- JokeQuestionLayout
- JokeAnswerLayout
Action (all of these Actions take Joke as input AND output the Joke back)
- GetJokeAnswerFromUser (get an Answer concept from the user and update the Interaction concept)
- ShowJokeQuestionToUser (show the next JokeQuestion to the user)
Other Actions as needed?
With this arrangement, you always have access to both the JokeQuestion(s) and JokeAnswer(s) through the Joke Concept. The JokeResultView will drive what the user sees on the screen and you can build some sort of logic in your implementation to signal the beginning and the end of the Joke etc.
Try this out and see if it helps.
Related
I'm writing an account creator using Inquirer.js, and wanted to ask for the user's e-mail and password only if the user asked for such protection. It goes like this:
inquirer.prompt([
{type:'input', name:'username', message:'Choose an username:'},
{type:'confirm', name:'protect_ask', message:'Do you want to password-protect your game list?'},
{type:'input', name:'email', message:'E-mail (for password recovering):', when:function(answers){return answers.protect_ask}},
{type:'password', name:'password', message:'Password:', when:function(answers){return answers.protect_ask}},
{type:'password', name:'confirm_password', message:'Confirm you password:', when:function(answers){return answers.protect_ask}}
]
As you can see, I'm running the exact same when statement three times, for it verifies if the password-protection was chosen or not. I want to know if there's a more intelligent, pragmatic way to do so, this is, to run this verification without repeating the when function.
Maybe nesting the three questions would do it, but how to do so without breaking the prompt flow?
I'm trying to make a medical diagnosis chatbot. The general idea is that the bot prompts the user for symptoms.
The user must input at least 1 symptom and a maximum of 3 symptoms.
The end of conversation is reached when user does one of the following:
Inputs 3 symptoms OR
Types 'end' after inputting at least 1 symptom
Example 1 (3 symptoms):
Bot: Hello! Diagnosis Bot at your service here. Please type in the symptoms you are having.
User: Cough
Bot: Gotcha! Please type in another symptom.
User: Fever
Bot: Roger that. Please type in another symptom.
User: Phlegm
Bot: I have received the following symptoms: Cough, Fever, Phlegm. Give me a few seconds to calculate your diagnosis.....
// This part will connect to a custom built AI engine
Example 2 (2 symptoms):
Bot: Hello! Diagnosis Bot at your service here. Please type in the symptoms you are having.
User: Chest pain
Bot: Gotcha! Please type in another symptom.
User: Dizziness
Bot: Roger that. Please type in another symptom.
User: End
Bot: I have received the following symptoms: Chest pain, Dizziness. Give me a few seconds to calculate your diagnosis.....
To design this chat bot, I have setup the following:
A 'symptom' entity
A 'Get Started' intent
A 'symptom-input' intent which requires 3 symptom parameters.
Question:
I would like to set it up so that at any point the user types 'end' to any of the prompts then it finishes the symptom-input intent and invokes the symptom-end intent. How do I do so?
Symptom entity:
Get Started intent:
symptom-input intent:
symptom-end intent:
This doesn't seem like a good design, how would the user know that he can finish the input with the 'end' keyword? It would be better if your agent would simply accept a list of symptoms like so:
Bot: Hello! Diagnosis Bot at your service here. Please tell me what symptoms you are having.
User: I'm having fever, dizziness and chest pain.
Bot: Ok, give me a few seconds to calculate your diagnosis.....
All you have to do for that is to check the list box next to the symptom parameter in the parameter table of your symptom-input intent. This would make your dialog shorter and more intuitive and save you the need for a separate symptom-end intent. See the documentation on parameters for details.
Can anyone suggest me , how to allowed scope of questions in api.ai? i.e. I want to ask user "how many book can you carry at a time ?" : user can reply any positive integer number. Then my bot reply: "good , you can still better than others!". now, without any reference if user directly write "any positive integer number" at starting then also bot reply : "good , you can still better than others!" , instead of "I didn't get"(or default response.). This answer come only when previous question has been asked.How can I do this?
==== case : 1 ====
Bot: how many book can you carry at a time ?
User:5
Bot:good , you can still better than others!
=== case : 2 ===
(without any reference if users gives inputs at very starting of conversation)
User: 5
Bot: good , you can still better than others!
Thanks In Advance.
You should make a required parameter instead of putting numbers in User says:
In your intent configure your action to have one required parameter numBooks. Have the prompt for that parameter be "how many book can you carry at a time ?". Then for that intent, have the response be, "good , you can still better than others!". Finally, in the User says section, add anything you want the user to say to trigger the intent, for example: "hi". Save your intent. Now whenever a user says "hi" the bot will ask the question and the conversation will begin. But if the user randomly sends a number, it will respond with fallback intent.
It's a mess in my head right now. I've seen this video tutorial to understand Wit.ai logic : https://www.youtube.com/watch?v=yLAHVPaHWFA
It's a really good video for basic training. But I can't still understand the logic.
I want to create a story like that Human(H) / Robot(R):
(H) Hello
(R) Hello human, you can choose A action or B action
(H) A action
(R) Ok human, this is A action
It's really simple but I don't know what to declare in "understanding" section.
1 - Do I have to create a "Say Hello" intent
2 - If yes, Do I have to create an "hello" entity and feed it with other salutations like "Hi", "yo", "What's up?", ...
3 - Do I have to create a "choose action" intent or it's just one intent for one story ? This is exactly what I don't understand.
4 - If yes, A&B action are free-text like ("An hotel", "a restaurant"). How can I teach the bot to recognized them ?
I just need some enlightening about those points ! It's really hard for me to translate and understand correctly. Thank you for you help !
You may declare a "greeting" intent(Intents are just user-created entities). After that, you can validate(feed) it with many other words like "Hey buddy, Sup bud, Hellloooo, Hi bot, etc". Also, you can give values to that intent such as Negative or Positive values.
For instance:
" Hey dumb f* " >> "greeting" Intent + Negative value ❌
" Hi brother! " >> "greeting" Intent + Positive value ✅
So that you can decide between:
"Language, please... Anyway. Hey {user_name}"
or
"Hey {user_name} ! :) Really nice to see you here ! "
to respond to the user's simple hi text.
Other than that:
(R) Hello human, you can choose A action or B action
(H) A action
(R) Ok human, this is A action
This type of interaction needs the usage of /converse API
https://wit.ai/docs/recipes#converse-link
In this above link go down to the "Handle yes/no answers" section.
Also, you can use Quick Replies for letting the user choose between the A Action or B Action. Quick Replies are really useful for this type of interactions.
https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies
I have a cakephp 1.3 application and I have run into a 'data leak' security hole. I am looking for the best solution using cake and not just something that will work. The application is a grade tracking system that lets teachers enter grades and students can retrieve their grades. Everything is working as expected but when I started to audit security I found that the basic CRUD operations have leaks. Meaning that student X can see student Y's grades. Students should only see their own grades. I will limit this questions to the read operation.
Using cake, I have a grade_controller.php file with this view function:
function view($id = null) {
// Extra, not related code removed
$this->set('grade', $this->grade->read(null, $id));
}
And
http://localhost/grade/view/5
Shows the grade for student $id=5. That's great. But if student #5 manipulates the URL and changes it to a 6, person #6's grades are shown. The classic data leak security hole.
I had two thoughts on the best way to resolve this. 1) I can add checks to every CRUD operations called in the controller. Or 2) add code to the model (for example using beforeFind()) to check if person X has access to that data element.
Option #1 seems like it is time consuming and error prone.
Option #2 seem like the best way to go. But, it required calling find() before some operations. The read() example above never executes beforeFind() and there is no beforeRead() callback.
Suggestions?
Instead of having a generic read() in your controller, you should move ALL finds, queries..etc into the respective model.
Then, go through each model and add any type of security checks you need on any finds that need to be restricted. 1) it will be much more DRY coding, and 2) you'll better be able to manage security risks like this since you know where all your queries are held.
For your example, I would create a getGrade($id) method in my Grade model and check the student_id field (or whatever) against your Auth user id CakeSession::read("Auth.User.id");
You could also build some generic method(s) similar to is_owner() to re-use the same logic throughout multiple methods.
If CakePHP supports isAuthorized, here's something you could do:
Create a column, that has the types of users (eg. 'student', 'teacher', ...)
Now, it the type of User is 'student', you can limit their access, to view only their data. An example of isAuthorized is as follows. I am allowing the student to edit only their profile information. You can extend the concept.
if ((($role['User']['role'] & $this->user_type['student']) == $this->user_type['student']) {
if (in_array($this->action, array('view')) == true) {
$id = $this->params->pass[0];
if ($id == $user_id) {
return (true);
}
}
}
}