Обновить поле диалога «Передача вызова» из серверной части (Node.js) - PullRequest
0 голосов
/ 03 октября 2019

Я пытаюсь обновить номер телефона в поле «Перевести звонок» на вкладке «Ответы» («ТЕЛЕФОНИЯ» -> «ДОБАВИТЬ ОТВЕТЫ») для данного намерения, используя 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) })

1 Ответ

0 голосов
/ 17 октября 2019

Подробный ответ можно найти здесь однако вот правильный пример кода (проверено и работает)

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) })
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...