簡體   English   中英

dialogflow BatchUpdateIntents重復的意圖

[英]dialogflow BatchUpdateIntents duplicates intents

我正在構建一個dialogflow代理。 我正在使用Node.js客戶端庫進行對話。 當我調用BatchUpdateIntents時,它可以完美工作,但是如果它已經存在於代理中,它也可以創建這些intent,這意味着api調用不會阻止重復的intent,而必須這樣做。

代碼樣本

const createIntentRequest = {
    parent: agentPath,
    intentBatchInline: {
        intents: intents
    }
};

const [operation] = await intentsClient.batchUpdateIntents(createIntentRequest);

const [ response ] = await operation.promise();

有人可以指導我如何使用Node.js客戶端庫防止意圖重復嗎?

為了能夠正確查找和更新一個Intent,Dialogflow需要該Intent的name屬性(不僅僅是displayName ),包括首次創建時自動分配給該Intent的ID。

這是所需格式的示例(ID到第二個星號所在的位置):

{ 
  displayName: 'myIntent',
  name: 'projects/*/agent/intents/*',
  trainingPhrases: []
}

我不知道intentBatch中的意圖是什么樣子,但是如果缺少name屬性,那可能是重復的原因。

獲取ID的最簡單方法是將ListIntentsRequest發送到API-結果數組將把您的代理中的所有意圖都包含為對象,每個細節都包含namedisplayName等屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM