首页 > 解决方案 > Dialogflow:未找到 agentId 的代理元数据

问题描述

我正在尝试detect_intent在 Python 中使用 Dialogflow,但我不断得到:

404 com.google.apps.framework.request.NotFoundException:找不到 agentId 的代理元数据:####-####-####-####-####

这是我的代码片段:

import google.cloud.dialogflow as dialogflow

from CONFIG import DIALOGFLOW_PROJECT_ID
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'credentials/dialogflow.json'

def predict_intent(text, language):
    session_client = dialogflow.SessionsClient()
    session = session_client.session_path(DIALOGFLOW_PROJECT_ID, SESSION_ID)
    text_input = dialogflow.TextInput(text=text, language_code=language)
    query_input = dialogflow.QueryInput(text=text_input)
    response = session_client.detect_intent(session=session, query_input=query_input)  # ERROR
    return response.query_result.intent.display_name

我尝试多次运行该函数,其中一些成功,但大多数都属于异常。

我可以使用相同的界面训练机器人,而且效果很好。

我正在使用 Python 3.7 和以下 Google Cloud 模块:google-api-core==2.0.1、google-auth==2.0.2、google-cloud-dialogflow==2.7.1、googleapis-common-protos= =1.53.0。

标签: google-cloud-platformdialogflow-es

解决方案


推荐阅读