Вот

аюсь разработать API для загрузки намеренияDialogflow V2. Я попробовал ниже фрагмент, который не работает, однако, если пытается связаться сDialogflow он работает (обнаружение намерения) и получает ответ отDialogflow для запросов.

РАЗРЕШЕНИЕ

Я & АДМИНИСТРАЦИЯ> СЧЕТА ОБСЛУЖИВАНИЯ> DIALOGFLOW ADMIN

ОШИБКА

Ошибка: 7 PERMISSION_DENIED: разрешение IAM «dialogflow.entityTypes.create» для «projects / dexter-47332 / agent» отклонено.

БЛОГИ / ССЫЛКИ

Dialogflow простой способ авторизацииhttps://github.com/dialogflow/dialogflow-nodejs-client-v2/blob/master/samples/resource.js#L26https://www.npmjs.com/package/dialogflowhttps://developers.google.com/apis-explorer/https://cloud.google.com/docs/authentication/production

//------- keys.json (test 1)

{
  "type": "service_account",
  "project_id": "mybot",
  "private_key_id": "123456asd",
  "private_key": "YOURKEY",
  "client_email": "[email protected]",
  "client_id": "098091234",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/yourID%40mybot.iam.gserviceaccount.com"
}


//--------------------- ** (test 2) ** ---------

let privateKey = 'key';
let clientEmail = "email";

let config = {
  credentials: {
    private_key: privateKey,
    client_email: clientEmail
  }
}

function createEntityTypes(projectId) {
  // [START dialogflow_create_entity]
  // Imports the Dialogflow library
  const dialogflow = require('dialogflow');

  // ******** Instantiates clients (Test 1)********
  const entityTypesClient = new dialogflow.EntityTypesClient({
    'keyFilename': './keys.json'
  });
  const intentsClient = new dialogflow.IntentsClient({
    'keyFilename': './keys.json'
  });

  // ******** Instantiates clients (Test 2)********
  const entityTypesClient = new dialogflow.EntityTypesClient(config);
  const intentsClient = new dialogflow.IntentsClient(config);


  // The path to the agent the created entity type belongs to.
  const agentPath = intentsClient.projectAgentPath(projectId);

  const promises = [];

  // Create an entity type named "size", with possible values of small, medium
  // and large and some synonyms.
  const sizeRequest = {
    parent: agentPath,
    entityType: {
      displayName: 'test',
      kind: 'KIND_MAP',
      autoExpansionMode: 'AUTO_EXPANSION_MODE_UNSPECIFIED',
      entities: [{
          value: 'small',
          synonyms: ['small', 'petit']
        },
        {
          value: 'medium',
          synonyms: ['medium']
        },
        {
          value: 'large',
          synonyms: ['large', 'big']
        },
      ],
    },
  };
  promises.push(
    entityTypesClient
    .createEntityType(sizeRequest)
    .then(responses => {
      console.log('Created size entity type:');
      logEntityType(responses[0]);
    })
    .catch(err => {
      console.error('Failed to create size entity type ----->:', err);
    })
  );
}

createEntityTypes(projectId);

Ответы на вопрос(1)

Ваш ответ на вопрос