我正在尝试通过使用本dialogflow-nodejs-client-v2 中给出的示例来创建Intent,但是问题在于它使用短语来创建Intent。但是它不会产生行动和回应。我什至使用下面示例中给出的确切代码进行了尝试
createIntents('myprojectid')
function createIntents(projectId) {
const dialogflow = require('dialogflow');
const contextsClient = new dialogflow.ContextsClient();
const intentsClient = new dialogflow.IntentsClient();
const agentPath = intentsClient.projectAgentPath(projectId);
const pizzaOutputContexts = [
{
name: contextsClient.contextPath(
projectId,
'' / sessionId */,
'pizza_order'
),
lifespanCount: 5,
},
];
const pizzaResult = {
action: 'pizza',
parameters: [
{
displayName: 'size',
value: '$size',
entityTypeDisplayName: '@SiZe',
mandatory: true,
prompts: [
'What size pizza would you like to order?',
'Would you like a large, medium, or small pizza?',
],
},
{
displayName: 'topping',
value: '$topping',
entityTypeDisplayName: '@Topping',
mandatory: true,
prompts: ['What toppings would you like?'],
isList: true,
},
{
displayName: 'address',
value: '$address',
// The API provides a built-in entity type @sys.address for addresses.
entityTypeDisplayName: '@sys.location',
mandatory: true,
prompts: ['What is the delivery address?'],
},
],
messages: [
{
platform: 'PLATFORM_UNSPECIFIED',
text: {
text: [
'No problem. Getting a $size pizza with $topping and delivering ' +
'to $address.',
]
}
},
{
text: {
text: [
'Reply "check" to place your order. Reply "cancel" to cancel ' +
'your order. You can change your delivery address as well.',
]
}
}
],
outputContexts: pizzaOutputContexts,
};
const pizzaPhrases = [
{type: 'EXAMPLE', parts: [{text: 'Order pizza'}]},
{type: 'EXAMPLE', parts: [{text: 'Pizza'}]},
{
type: 'EXAMPLE',
parts: [
{text: 'Get me a '},
{text: 'large', entityType: '@SiZe', alias: 'size'},
{text: ' '},
{text: 'mushrooms', entityType: '@Topping', alias: 'topping'},
{text: ' for '},
{
text: '1 1st st, New York, NY',
entityType: '@sys.location',
alias: 'address',
},
],
},
{
type: 'EXAMPLE',
parts: [
{text: "I'd like to order a "},
{text: 'large', entityType: '@SiZe', alias: 'size'},
{text: ' pizza with '},
{text: 'mushrooms', entityType: '@Topping', alias: 'topping'},
],
},
{
type: 'TEMPLATE',
parts: [{text: "I'd like a @SiZe:size pizza"}],
},
];
const pizzaIntent = {
displayName: 'Pizza',
events: ['order_pizza'],
// Webhook is disabled because we are not ready to call the webhook yet.
webhookState: 'WEBHOOK_STATE_DISABLED',
trainingPhrases: pizzaPhrases,
mlEnabled: true,
priority: 500000,
result: pizzaResult,
};
const pizzaRequest = {
parent: agentPath,
intent: pizzaIntent,
};
intentsClient
.createIntent(pizzaRequest)
.then(responses => {
console.log('Created Pizza intent:');
// logIntent(responses[0]);
})
.catch(err => {
console.error('ERROR:', err);
});
}
以上代码创建意图,但未设置动作名称和响应
正如我之前所说,它与dialogflow-nodejs-client-v2中给出的代码完全相同。那是一个错误还是我做错了什么,请帮忙