我正在尝试调用一个自定义事件以触发我的代理中的意图EnteredRoom
。
我这样做的方法是使用nodejs dialogflow包。我已经为代理成功创建了一个授权的SessionsClient实例。在第一次启动代理程序时,我将处理服务器上的欢迎意图,并从session
参数中提取conv
值。
然后我使用detectIntent
中的SessionsClient
方法根据用户的动作发送请求,在这种情况下,用户进入了房间。
async sendEventRoomEnetered() {
logRoomState('Sending event room entered with session ' + this.session);
const request = {
session: this.session,
queryInput: {
event: {
name: EVENT_ROOM_ENTERED,
languageCode: LANGUAGE_CODE
}
}
}
this.sessionClient
.detectIntent(request)
.then(response => {
logRoomState('Entered room event sent');
consoleLogDialogFlow(JSON.stringify(response));
})
.catch(error => {
logRoomState('Something went wrong with sending event room entered')
console.log(JSON.stringify(error, null, 2));
});
}
以下是发送事件请求时响应的日志(成功):
[
{
"responseId":"c3a3d117-8f68-4ca6-a092-682ec5f8e8c5",
"queryResult":{
"fulfillmentMessages":[
{
"platform":"PLATFORM_UNSPECIFIED",
"text":{
"text":[
"Shhhhhh! Someone just went inside the room."
]
},
"message":"text"
}
],
"outputContexts":[
{
"name":"projects/zoe-mortimer/agent/sessions/ABwppHFrI1mZWiEz_73YtWOTdHatg3gGfqLEn9rJNn5wTHI9HCDFdnFuvOqSQAxSoKCsiDk-9zPiQgZL/contexts/welcome-context",
"lifespanCount":4,
"parameters":null
},
{
"name":"projects/zoe-mortimer/agent/sessions/ABwppHFrI1mZWiEz_73YtWOTdHatg3gGfqLEn9rJNn5wTHI9HCDFdnFuvOqSQAxSoKCsiDk-9zPiQgZL/contexts/welcome-default-followup",
"lifespanCount":1,
"parameters":null
},
{
"name":"projects/zoe-mortimer/agent/sessions/ABwppHFrI1mZWiEz_73YtWOTdHatg3gGfqLEn9rJNn5wTHI9HCDFdnFuvOqSQAxSoKCsiDk-9zPiQgZL/contexts/_actions_on_google",
"lifespanCount":98,
"parameters":{
"fields":{
"data":{
"stringValue":"{}",
"kind":"stringValue"
}
}
}
}
],
"queryText":"event-entered-room",
"speechRecognitionConfidence":0,
"action":"",
"parameters":{
"fields":{
}
},
"allRequiredParamsPresent":true,
"fulfillmentText":"Shhhhhh! Someone just went inside the room.",
"webhookSource":"",
"webhookPayload":null,
"intent":{
"inputContextNames":[
],
"events":[
],
"trainingPhrases":[
],
"outputContexts":[
],
"parameters":[
],
"messages":[
],
"defaultResponsePlatforms":[
],
"followupIntentInfo":[
],
"name":"projects/zoe-mortimer/agent/intents/2fea6b60-2751-443d-96fb-872f85605956",
"displayName":"EnteredRoom",
"priority":0,
"isFallback":false,
"webhookState":"WEBHOOK_STATE_UNSPECIFIED",
"action":"",
"resetContexts":false,
"rootFollowupIntentName":"",
"parentFollowupIntentName":"",
"mlDisabled":false
},
"intentDetectionConfidence":1,
"diagnosticInfo":null,
"languageCode":"en-us"
},
"webhookStatus":null
},
null,
null
]
它具有正确的fulfillmentMessage
值,但是代理没有根据文本触发意图。自定义事件调用如何发生?用户是否需要在事件实际被触发并且具有自定义事件的正确事件被触发之前给出响应?
编辑
我在EnteredRoom
意图上打开了Webhook,该意图实际上在发送事件请求后被触发了。在处理EnteredRoom
意图的服务器端,我正在用ask
的fulfillmentText调用conv
上的EnteredRoom
方法,但是代理没有激发意图。代理一直在等待默认的欢迎意图之后的整个响应时间。触发欢迎意图后,我发送事件请求调用。
app.dialogFlow.intent('EnteredRoom', async (conv) => {
conv.ask("Shhhh! Someone entered the room");
});
此刻,座席对以上文字没有回应。它仍在等待最后一个意图(欢迎意图)的响应