Digital Assistant and Mobile

Get Involved. Join the Conversation.

Topic

    Stefan Van Liempt
    System.List property with escaping the comma (,)Answered
    Topic posted May 14, 2019 by Stefan Van LiemptGreen Ribbon: 100+ Points, last edited May 14, 2019, tagged Bots, Virtual Assistant 
    16 Views, 7 Comments
    Title:
    System.List property with escaping the comma (,)
    Summary:
    How would we escape a comma (,) in the System.List Component
    Content:

    So the scenario is that the user has been mailed and our bot would check if the mail is received. 

    The user can answer with the following options in the System.List component.

    1. Yes

    2. No, but please sent it again

    3. I need to change my student number

    As you can see, option 2 contains a comma (,). In the current situation this leads to 4 options in the menu (instead of 3):

    Yes
    No
    but please sent it again
    I need to change my student number

    See the snippets what I tried so far.. Will keep on trying, but hopefully someone else has a bright idea.

    Thanks for the help!

    Code Snippet:

    Best Comment

    Rohit Dhamija

    Try this

    askGreeting:
        component: "System.List"
        properties:
          options: ["red,s","green","blue"]
          prompt: "Hi there! What would you like me to echo back?"
          variable: "greeting"

    Comment

     

    • Rohit Dhamija

      Try this

      askGreeting:
          component: "System.List"
          properties:
            options: ["red,s","green","blue"]
            prompt: "Hi there! What would you like me to echo back?"
            variable: "greeting"

    • Rohit Dhamija

      #metadata: information about the flow
      #  platformVersion: the version of the bots platform that this flow was written to work with 
      metadata:
        platformVersion: "1.0"
      main: true
      name: TestSemicolon
      #context: Define the variables which will used throughout the dialog flow here.
      context:
        variables:
      #The syntax for defining the variables is variablename: "variableType".
      # The "variableType" can be defined as a primitive type ("string", "boolean", "int", "float", "double"), "list", "map", "resourcebundle", or an entity name. A variable can also hold the results returned by the Intent Engine. For these variables, the "variableType" must be "nlpresult" (for example, iResult: "nlpresult").
          greeting: "string"
          name: "string"
      #states is where you can define the various states within your flow.
      # The syntax for defining a state is
      # statename:
      #   component:Specify the component you want to use. This can be either a Built-In or custom component.
      #   properties:
      #     property1: "value" (These are the properties to the specified component
      #   transitions: You can specify one of the following four
      #     next: Specify the state you want to execute next after this state. By default it will execute the state specified after this
      #     error: Specify the state you want to execute in case the component encounters any error in execution.
      #     actions: You can handle various actions returned by the components here the syntax is actionName: "statename"
      #        action1: state1
      #     return: "done" You can exit the flow using the return statement

      states:
        askGreeting:
          component: "System.List"
          properties:
            options: ["red,s","green","blue"]
            prompt: "Hi there! What would you like me to echo back?"
            variable: "greeting"

        start:
          component: "System.Output"
          properties:
            text: "${greeting.value}  ${name.value}"
          transitions:
            return: "done"

    • Stefan Van Liempt

      Thanks Rohit,

      This works! You've made my day  :)

    • Steven Davelaar

      Note you can also use the "long" syntax for specifying the options, something like this:

          component: "System.List"
          properties:
            options: 
            - label: "Yes"
              value: "yes" 
            - label: "No, but please sent it again"
              value: "sendAgain" 
            - label: "I need to change my student number"
              value: "changeStudentNumber" 

      Also allows you to specify a different value for the value set on your variable, so you don't need to do routing based on strings like "No, but please sent it again" but simply checking "sendAgain". 

      Steven Davelaar,
      Oracle A-Team.

       

    • Stefan Van Liempt

      Hi Steven,

      That is actually a pretty solution as well, since it separates the key values from the labels. It keeps your YAML cleaner imo.

       

    • Steven Davelaar

      Yes, I agree it is cleaner, also allows you to translate labels if you need to support multiple languages. And you can also specify keywords, see the List component templates (accessible through green Components button at the top of the YAML editor).

      Steven.