在Dialogflow中使用自定义事件通过Detect Intent API调用事件

时间:2018-10-10 22:49:48

标签: dialogflow

我正在根据documentation向/ query发送一个带有参数名称和参数值的请求。但是,我无法获得任何参数槽来填充意图本身。

有效负载示例:

(SELECT m.id
, m.userId1
, m.userId2
, m.message
, m.sentDate
, m.readDate
, (SELECT Count() from messages mm where mm.userId1 = 7) as countUserId1
, u1.id id1
, u1.ad ad1
, u1.avatar avatar1
, u2.id id2
, u2.ad ad2
, u2.avatar avatar2 
FROM 
    (messages m 
    inner join users u1 
    on m.userId1 = u1.id) 
inner join users u2 
on m.userId2 = u2.id 
where (userId1 = 7 or userId2 = 7) 
and (userId2 = 8 or userId1 = 8) 
order by sentDate)

}

我在每个文档中引用我的参数,即{ "contexts": ["member"], "event": { "name": "memberLookup", "parameters": { "baseState": "az", "occurrenceState": "ny" }, "languageCode": "en-US" }, "lang": "en", "sessionId": "1"

响应片段

#memberLookup.baseState

有人能使用此功能吗?

2 个答案:

答案 0 :(得分:0)

这真的对我有用。当我将单词parameters替换为data时,我收到了包含必要参数的正确答案:

[{'name': 'itbooking-vcs_error-followup', 'parameters': {'room_type.original': 
'', 'description.original': 'test', 'room_number.original': '', 'description':
 'test', 'room_number': '10.12', 'branch': 'headquarter', 'branch.original': '',
 'room_type': 'meeting_room'}, 'lifespan': 1}]

答案 1 :(得分:-1)

V1格式略有不同。正文中的Parameters应该为data,然后将填充参数。感谢Dialogflow为我提供帮助并解决了这个问题。

{
    "contexts": ["member"],
        "event": {
                "name": "memberLookup",
                "data": {
                        "baseState": "az",
                        "occurrenceState": "ny"
                },
                "languageCode": "en-US"
        },
"lang": "en",
"sessionId": "1"
}

新结果:

"result": {
    "source": "agent",
    "resolvedQuery": "memberLookup",
    "action": "",
    "actionIncomplete": true,
    "parameters": {
        "baseState": "az",
        "occurrenceState": "ny",
},