Ayoub Hamoudi
Ayoub Hamoudi

Reputation: 1

UPDATE INTENT DIALOG FLOW VIA API V1

My problem is that when I want to update an intent via API DIALOGFLOW V1 it returns Unknown Error, BUT I can list and create the intent via API V1, here is my code for the update:

url : https://api.dialogflow.com/v1/intents/f5eedaaa-f7d1-4e4e-b1fa-6aa66c94ca6f?v=20150910
method : PUT
DATA : {"id":"f5eedaaa-f7d1-4e4e-b1fa-6aa66c94ca6f","name":"FORDEBUG","auto":false,"contexts":[],"responses":[{"resetContexts":false,"affectedContexts":[],"parameters":[],"messages":[{"type":0,"condition":null,"speech":["KOKOKOOOKK","KOJKFKF"]}],"defaultResponsePlatforms":[],"speech":[]}],"priority":500000,"webhookUsed":false,"webhookForSlotFilling":false,"fallbackIntent":false,"events":[],"userSays":[{"id":"d891eb29-7233-4f47-901c-751cbde5fff4","data":[{"text":"KOKOK","userDefined":false}],"isTemplate":false,"count":0,"updated":0,"isAuto":false},{"id":null,"data":[{"text":"FJFLFOPF"}]}],"followUpIntents":[],"liveAgentHandoff":false,"endInteraction":false,"conditionalResponses":[],"condition":null,"conditionalFollowupEvents":[],"templates":[]}

and here is the return that I have :

{
    "id": "e5bf8ebf-f5e6-4568-8237-f69dcef6f5db",
    "timestamp": "2021-06-07T16:53:36.748Z",
    "lang": "en",
    "status": {
        "code": 400,
        "errorType": "bad_request",
        "errorDetails": "Unknown error errorid=0a4ffdc6-907a-4049-965d-509490bb428e"
    }
}

Upvotes: 0

Views: 670

Answers (1)

Ricco D
Ricco D

Reputation: 7277

Unfortunately Dialogflow V1 is already deprecated last May 31, 2020 and no further operations can be performed. It is suggested to migrate to Dialogflow V2 so you can continue using the service.

We are extending the V1 API shutdown deadline to May 31st, 2020. Migrate to the V2 API as described here.

If you use Dialogflow exclusively for Actions on Google, you don't need to migrate your agent to the V2 API. However, note the following changes:

  • The Dialogflow simulator will show responses in the V2 format and the "Copy curl" button will generate requests in the V2 format. This should have no impact on the functionality of the Actions on Google simulator.
  • You will no longer be able to call API methods for the V1 intents and entities resources. You will still be able to modify your agent using the Dialogflow Console.

Once you have migrated to V2, you can update an intent by batch or per intent.

EDIT 20210609

Here are the request body and call using curl. I'm not knowledgeable in php, but I suppose you can convert this to curl php.

But I assume that the content of the json will go to data:, the endpoint used in the curl command will be url: and method: will be either PATCH (for single intent) or POST (for batch intent update).

Updating a single intent using request_patch.json

{
   "name":"projects/your-project-id/agent/intents/your-intent-id",
   "displayName":"Image please",
   "trainingPhrases":[
      {
         "type":"EXAMPLE",
         "parts":[
            {
               "text":"Show an image"
            }
         ]
      },
      {
         "type":"EXAMPLE",
         "parts":[
            {
               "text":"Show me an image"
            }
         ]
      },
      {
         "type":"EXAMPLE",
         "parts":[
            {
               "text":"Show me an image please"
            }
         ]
      }
   ]
}

Curl command:

curl -X PATCH -H "Content-Type: application/json" \
    -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
    https://dialogflow.googleapis.com/v2/projects/your-project-id/agent/intents/your-intent-id \
    -d @request_patch.json

Successful response:

{
  "name": "projects/your-project-id/agent/intents/your-intent-id",  "displayName": "Image please",
  "priority": 500000
}

Updating batch intents using request_batch.json

{
   "intentBatchInline":{
      "intents":[
         {
            "name":"projects/your-project-id/agent/intents/your-intent-id",
            "displayName":"Image please",
            "trainingPhrases":[
               {
                  "type":"EXAMPLE",
                  "parts":[
                     {
                        "text":"Show an image"
                     }
                  ]
               },
               {
                  "type":"EXAMPLE",
                  "parts":[
                     {
                        "text":"Show me an image"
                     }
                  ]
               },
               {
                  "type":"EXAMPLE",
                  "parts":[
                     {
                        "text":"Show me an image please"
                     }
                  ]
               }
            ]
         }
      ]
   }
}

Curl command:

curl -X POST -H "Content-Type: application/json" \
    -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
    POST https://dialogflow.googleapis.com/v2/projects/your-project-id/agent/intents:batchUpdate \
    -d @request_batch.json

Successful response:

{
  "name": "projects/your-project-id/operations/operation-id-here",
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.dialogflow.v2.BatchUpdateIntentsResponse",
    "intents": [
      {
        "name": "projects/your-project-id/agent/intents/your-intent-id",
        "displayName": "Image please",
        "priority": 500000
      }
    ]
  }
}

Upvotes: 1

Related Questions