0
votes

I've created a pattern for a specific variable in my dialogue.

Type: Pattern ^[A-Za-z]{1,}$

I'd like the value of that variable to be only one word specifically, no more. I just don't know where to insert it in the JSON editor.

   {
  "output": {
    "text": {
      "values": [
        "Nice to meet you $firstname. How can I assist you mate?"
      ],
      "selection_policy": "sequential"
    }
  },
  "context": {
    "firstname": "<? input.text.substring(0, 1).toUpperCase() + input.text.substring(1) ?>"
  }
}
1
What variable is it? On what is the pattern based on, e.g. the input or something else?data_henrik

1 Answers

1
votes

If I understand correctly, I think what you want is to create a Pattern based entity with your expression https://cloud.ibm.com/docs/services/assistant?topic=assistant-entities#entities-dictionary-overview

Watson Assistant will identify occurrences of your pattern and store them in the 'entities' array. You can then either build conditions in your dialog nodes using the '@myentitiy' syntax, or access them right from the 'entities' array. If you want just the first occurrence use entities.get(0)