Действия и параметры не обнаруживаются после создания намерения - PullRequest
0 голосов
/ 18 июня 2019

введите описание изображения здесь Я отправляю намерения с сущностями, используя API, но заданные сущности не отображаются в диалоговом потоке ....

Я попытался вставить 'entityType','псевдоним' для 'trainingPhrases'.

 trainingPhrases: [
    {
      type: 'EXAMPLE',
      parts: [
        {
          text: intent.question,
          entityType: '@pizza',
          alias: 'pizza',
        },
      ],
    },

.........

const parameter1 = [
  {
    displayName: 'pizza',
    value: 'pizza',
    entityTypeDisplayName: '@pizza',
    mandatory: true,
  },
]
// TODO
await this.intentsClient.batchUpdateIntents({
  parent: intentParent,
  languageCode,
  intentBatchInline: {
    intents: this.intents,
  },
  parameters: parameter1,
})

1 Ответ

0 голосов
/ 18 июня 2019

Вы тоже пытаетесь создать сущность через API?

Я делаю это также через API (создание сущности + создание намерения, но не пакетным способом):

Создание сущности:

exports.createEntity = async function(entityId, tags) {
    let aTags = [];
    for (var i = 0; i < tags.length; i++) {
        let tTags = {};
        let aSyn = [];
        aSyn.push(tags[i].text);

        tTags['value'] = tags[i].text;
        tTags['synonyms'] = aSyn;
        aTags.push(tTags);
    }
    const entityType = {
        displayName: entityId,
        kind: 'KIND_MAP',
        entities: aTags
    };

    const entityRequest = {
        parent: agentPath,
        entityType: entityType
    };

    const responses = await entitiesClient.createEntityType(entityRequest);
    console.log(`Intent ${responses[0].name} created`);
};

И вот как я создал намерения потом:

// The path to identify the agent that owns the created intent.
const agentPath = intentsClient.projectAgentPath(projectId);

const trainingPhrases = [];

const part = {
    text: tag1.text,
    entityType: '@' + entityId,
    alias: entityId,
};

const part1 = {
    text: tag2.text,
    entityType: '@' + entityId,
    alias: entityId,
};

const partX = {
    text: "news about ",
};

// Here we create a new training phrase for each provided part.
const trainingPhrase = {
    type: 'EXAMPLE',
    parts: [part],
};

const trainingPhrase1 = {
    type: 'EXAMPLE',
    parts: [part1]
};

const trainingPhrase2 = {
    type: 'EXAMPLE',
    parts: [partX, part]
};

const trainingPhrase3 = {
    type: 'EXAMPLE',
    parts: [partX, part1]
};

trainingPhrases.push(trainingPhrase);
trainingPhrases.push(trainingPhrase1);
trainingPhrases.push(trainingPhrase2);
trainingPhrases.push(trainingPhrase3);

const parameter = {
    displayName: entityId + "x1",
    entityTypeDisplayName: '@' + entityId,
    value: tag1.text,
};

const parameter1 = {
    displayName: entityId + "x2",
    entityTypeDisplayName: '@' + entityId,
    value: tag2.text,
};

const messageText = {
    text: 'messageText',
};

const message = {
    text: messageText,
};

const intent = {
    displayName: entityId,
    trainingPhrases: trainingPhrases,
    parameters: [parameter, parameter1],
};

const createIntentRequest = {
    parent: agentPath,
    intent: intent,
};

// Create the intent
const responses = await intentsClient.createIntent(createIntentRequest);

Надеюсь, это поможет вам.

...