Search code examples
ibm-watsonwatson-conversation

IBM Watson - How to get login from user with Regex


I'm working with IBM Watson API's a few months ago.

I want to know more about Regex inside the Conversation Service. And how to get the login from the user, if they type some like:

  • My login is sayuri.mizuguchi!
  • My login? ooh, is sayuri.mizuguchi

The default is always firstname.lastname.

I want use input.text.find to get the login, and with one context variable I'll save the login, like:

{
  "context": {
    "loginUser": <? input.text ?>
  },

Simon did the same but with other data, 11 numbers and works amazingly.

In this case I'll use just input.text because my input.text.find inside the node with IF condition will extract my data.


Solution

  • I find this solution with regex, @revo help with one example.

    Try this inside the if condition:

    input.text.find('\w+\.\w') 
    

    And only if user types login, the conversation will flow.