从后端(Node.js)更新Dialogflow“转移呼叫”字段

问题描述 投票:0回答:1

我尝试使用Node.js为给定的意图在“响应”选项卡(“电话”->“添加响应”按钮)下的“转移呼叫”字段中更新电话号码,但我不能。新更新删除了带有旧电话号码的旧“转接呼叫”字段(我是在控制台中手动创建的,用于测试)请帮助

这里是示例代码:

const dialogflow = require('dialogflow')
const intentsClient = new dialogflow.IntentsClient({ keyFilename: 'key.json' })

const fulfillmentMessages = [ { platform: 'TELEPHONY',
telephonySynthesizeSpeech: { text: 'Hello World' } },
{ platform: 'TELEPHONY',
telephonyTransferCall: { phoneNumber: '+12132954242' } },
{ text: { text: [ '' ] } } ]

const intent = {
name: 'projects/example/agent/intents/2ef3e0b6-6cd7-4d5b-a8ca-ce11111125e019',
displayName: 'Test',
fulfillmentMessages: fulfillmentMessages
}

const updateIntentRequest = { intent: intent }

intentsClient.updateIntent(updateIntentRequest).then((data) =>{ console.log(data)}, (e) => { 
console.log(e) })
dialogflow
1个回答
0
投票

可以找到详细的回复here,但是这里是正确的代码示例(已测试并且可以正常工作)

const dialogflow = require('dialogflow');
const intentsClient = new dialogflow.v2beta1.IntentsClient({ keyFilename: 'key.json' }) //Note that dialogflow will be using v2beta1 api

const message_to_set = [
  { 
      platform: 10,
      telephonySynthesizeSpeech: {
             text : 'Hello World'
         },
         telephonyTransferCall: {
             phoneNumber: '+12132954242'
      }
  }
]

const intent = {
   name: 'projects/example/agent/intents/2ef3e0b6-6cd7-4d5b-a8ca-ce11111125e019',
   displayName: 'Forward',
   messages: message_to_set //Note parameter was switched from fulfillmentMessages to messages
}

const updateIntentRequest = { intent: intent }

intentsClient.updateIntent(updateIntentRequest).then((data) =>{ console.log(data)}, (e) => { console.log(e) })
© www.soinside.com 2019 - 2024. All rights reserved.