dialogflow-es - 如何在 Dialogflow 中的检测意图文本 API 中发送 accessToken

标签 dialogflow-es actions-on-google

我正在使用 Python 中的检测意图 API 开发我的聊天机器人后端,一旦识别出意图,它就会转到我的 webhook 并获取适当的数据。

这是我的 detectorIntent 代码,用于从文本中获取数据

def detect_intent_texts(project_id, session_id, text, language_code='en-US'):
   session_client = dialogflow.SessionsClient().from_service_account_file(
    'my_service_account_json.json')
   session = session_client.session_path(project_id, session_id)
   print('Session path: {}\n'.format(session))
   text_input = dialogflow.types.TextInput(text=text, language_code=language_code)
   query_input = dialogflow.types.QueryInput(text=text_input)
   response = session_client.detect_intent(session=session, query_input=query_input)
   data = MessageToDict(response.query_result)
   print (json.dumps(data, indent=4))
   response = parse_response(data)
   return response

How can I sent access_token with it so that my webhook can identify which user is accessing the bot

P.S. 我的 webhook 正在此路径中寻找访问 token

req.get("originalDetectIntentRequest").get("payload").get("user").get("accessToken")

最佳答案

“有效负载”属性下的所有内容均取决于平台。例如,Assistant 平台将用户信息放在此处,这就是您的 webhook 当前正在尝试处理的内容。

如果您想将访问 token 放在同一位置,您可以将 query_params 命名参数与您要调用的文本一起传递给 detect_intent() 调用重新查询,以及任何其他可能相关的内容。 ( Reference ) 该参数可以是一个字典,如果是这样,则必须具有与 QueryParameters 相同的字段名称。对象。

关于dialogflow-es - 如何在 Dialogflow 中的检测意图文本 API 中发送 accessToken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53045720/

相关文章:

node.js - 如何重定向到 Google Action 中的另一个意图(Google Assistant Action)

actions-on-google - DialogFlow Webhook API V2 - 如何获取授权用户的 accessToken?

chatbot - 对话流 : handling given-names with multiple segments

oauth - Google 帐户链接操作 - 根据我们的帐户链接政策,Google 帐户不能用作身份验证端点 URL

node.js - 是否可以等到ask方法返回响应

actions-on-google - 在 Actions on Google 模拟器中重置用户 lastSeen 属性

php - 谷歌上的操作/Dialogflow : Could not find a RichResponse or SystemIntent in the platform response for agentId

rest - Dialogflow 未检测上下文意图

dialogflow-es - 使用 Dialogflow 时,后续意图与父意图中需要参数有什么区别?

javascript - 在谷歌上设置一个带有 Action 的计时器