How can I detect a plain text or free form text in the chat bot using IBM Watson as example when user says "get ticket with id KMN849SDA", bot will recognize that "KMN849SDA" is the ticket id, if there is a possible way to do that, if not how can i handle it with coding
Asked
Active
Viewed 169 times
1 Answers
1
in this case, IF your id has some default value, for example: every ID start with KMN, you can use some REGEX
for getting the ID and save in your context
variable inside the Watson Conversation Service.
For example, my regex now try to find 11 numbers:
input.text.find('^[^\d]*[\d]{11}[^\d]*$')
And for save this value inside one context
variable, you can use:
"context": {
"ticketID": "<?input.text.extract('^[^\\d]*[\\d]{11}[^\\d]*$',0)?>"
}
For use in your application, you need to access the return from conversation message call method, something like:
//add inside your call, like:
conversation.message(payload, function (err, data) {
console.log(data.context.ticketID); //your ticketID here
if (err) {
return res.status(err.code || 500).json(err);
}
updateMessage(payload, data, req, res);
});
});
And for using in your application to verify with the user if this protocol is correct, you can use:
if bot recognizes input.text.find('^[^\d]*[\d]{11}[^\d]*$') response "Your ticket is is $tickedID?"

Sayuri Mizuguchi
- 5,250
- 3
- 26
- 53
-
Hi, I want to display a date picker on chatbot dialog. For this, I tried : Now, how do I assign this selected date to a context variable in IBM Chatbot? Please help. – Kumar Apr 14 '20 at 04:23