如何从检测意图 API 触发对话流事件?

ame*_*eya 3 python dialogflow-es

如何从 python 检测意图 API 在对话流中触发事件。我想在启动聊天窗口后立即触发欢迎意图。

Pri*_*ner 5

您需要将“WELCOME”事件作为查询输入的一部分发送到对detect_intent(). 它可能看起来像这样

import dialogflow

client = dialogflow.SessionsClient()

session = client.session_path('[PROJECT]', '[SESSION]')

event_input = dialogflow.types.EventInput(name='WELCOME', language_code='en-US')
query_input = dialogflow.types.QueryInput(event=event_input)
response = client.detect_intent(session=session, query_input=query_input)
Run Code Online (Sandbox Code Playgroud)