Как создать намерение в диалоге с каруселью в ответ? - PullRequest
1 голос
/ 16 апреля 2019

Цель моей "функции" - создать "намерение" в диалоге с каруселью.Я взял код, предоставленный Google API функцией "createIntent".Мой проект закодирован в node.js.Вот моя функция:

async function createIntentCustom(
) {
  const dialogflow = require('dialogflow');
  const intentsClient = new dialogflow.IntentsClient();
  const agentPath = intentsClient.projectAgentPath(ID_PROJECT);
  //Question
  const part = {
    text: "Question",
  };
  const trainingPhrase = {
    type: 'EXAMPLE',
    parts: [part],
  }
  const trainingPhrases = [trainingPhrase];  

  // carousel  
  const SelectItemInfo = {
    key : "cle",
  };

  const Image = {
    image_uri : "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
    accessibility_text : "imageText",
  };

  const Item = {
    info :  SelectItemInfo,
    title : "titre",
    description : "description",
    image: Image,
  };

  const SelectItemInfo1 = {
    key : "cle1",
  };

  const Image1 = {
    image_uri : "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
    accessibility_text : "imageText1",
  };

  const Item1 = {
    info :  SelectItemInfo1,
    title : "titre1",
    description : "description1",
    image: Image1,
  };

  const carousel = {
    items : [Item,Item1],
  };
  const Text = {
    text: ["reponse :"],
  };

  const message = {
    text: Text,
    carousel_select : carousel,
  };

  const intent = {
    displayName: "FirstIntent",
    trainingPhrases: trainingPhrases,
    messages: [message],
  };
  const createIntentRequest = {
    parent: agentPath,
    intent: intent,
  };
  // Create the intent
  const responses = await intentsClient.createIntent(createIntentRequest);
  console.log(`Intent ${responses[0].name} created`);
}

Я случайно создал «намерение» за исключением того, что карусели нет.Пока что во время выполнения ошибки нет. У вас есть представление о проблеме?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...