Search code examples
google-cloud-platformdialogflow-es

Dialogflow Training Phrases through Dialogflow REST API


I have created a custom entity "toppings", I have an agent Pizza. I am creating an intent by using Dialogflow REST API and I am trying to put multiple training phrases. But in the console I am unable to get all those training phrases. All the Training Phrases are getting combined to a single line.

"trainingPhrases": [
   {
     "name":"",
     "type": "EXAMPLE",
     "parts": [
       {
         "text": "I want a pizza  with extra   "
       },
       {
           "text": "cheese",
           "entityType":"@toppings",
           "alias": "pizza",
           "userDefined": "True"
       },
       {
           "text" : "where is my pizza"
       },
       {
           "text" : "get me a  pizza"
       }
     ]
   }
 ]

enter image description here

TIA


Solution

  • This is happening because, the intent file that you are creating through Dialogflow API, in the training phrase section, you are putting all your user expressions inside the field parts[] of the training Phrase, for which only a single training phrase is created as a result of which all your user expressions are getting combined to a single expression that you are seeing in your dialogflow console. Try creating multiple training phrases in your intent file so that all user expressions will be treated individually.

    you can refer to this piece of code:

      "trainingPhrases": [
        {
          "name":"",
          "type": "EXAMPLE",
        "parts":[
            {
              "text": "I want a pizza with extra  "
            },
            {
                "text": "cheese",
                "entityType":"@toppings",
                "alias": "pizzas",
                "userDefined": "True"           
            }
          ]
        }
    ],
    "trainingPhrases": [
        {
          "name":"",
          "type": "EXAMPLE",
        "parts":[
            {
              "text": "order me a pizza"
            }
          ]
        }
    ],
    "trainingPhrases": [
        {
          "name":"",
          "type": "EXAMPLE",
        "parts":[
            {
              "text": "where is my pizzza "
            }
          ]
        }
    ]
    

    enter image description here