I would like to know how to display a file when a user types something. Ex: Show me the course details Output: The file(pdf format) which is on my PC gets displayed.
-
Hi @Amit Sarma, if my answer help you, please dont forget, mark the questions for help other people if they have the same purpose. See inside the Stackoverflow [how it works](https://stackoverflow.com/help/accepted-answer). – Sayuri Mizuguchi Jul 10 '17 at 21:09
1 Answers
Basically, you need to know how to work conversation: is one API for creating Intents, Entities and your Dialog flow.
Your application will access all nodes with the return from the API, and you will create conditions to get something for know if the user asked something about "Show me the course details".
I recommend to you create one intent like #aboutCourse and show examples to Watson know if the user will ask something with this purpose.
Something like:
Watson says: Hi! How can I help you?
User: Please show me the course details
Watson will recognize your intent and response what you paste within the node with the Intent condition #aboutCourse.
Make sure if the user really want this with:
Watson says: You really want to know details about the course?
User: yes / ok // or something to confirm
Or you can add some Intent confidence level for this node condition like: intents[0].confidence >= 0.75
And your code will check if the Intent is #aboutCourse and the entity is @yes, and do something in your application. Or, you can create one context variable too, because, depends on your node flow, the intents will modify within your flow because every time Watson try to recognize what the user wants.
With your dialog flow, you will create one context variable and check if user says yes, like:
{
"context": {
"courseConfirm": "<? @yes ?>" //create one intent with confirm examples and value equal yes
},
"output": {
"text": {
"values": [
"Ok, you say @yes. I'll check, one moment."
],
"selection_policy": "sequential"
}
}
}
And within your application:
function updateMessage(input, response) {
if (response.context.courseConfirm == 'yes') {
//do something with code with code
}
}
Or you can create one function inside my example, like this answer.
Obs.: This code example is with conversation-simple project, from IBM Developers, but you will do something like my example with the same logic:get the return from API and do something within your application.

- 5,250
- 3
- 26
- 53
-
Thanks and one more thing how to give a new line space within the dialog? – Amit Sarma Jul 02 '17 at 04:15
-
Check this [answer](https://stackoverflow.com/questions/42572439/how-to-add-a-new-line-in-ibm-watson-chatbot-conversation/42582465#42582465) too and you'll see how to do that. – Sayuri Mizuguchi Jul 02 '17 at 18:08