DialogflowのAPIにv2が出たということなので、ローカル環境で動作するようにv1からの切り替え作業を行っているのですが、エラーが出てしまい困っています。
どのように対処したらよいのでしょうか。
また、session_idについて、v2ではどこから取得すればいいのかがよくわかっていません。
session_idはどのように扱えばいいのでしょうか。
■環境
python3.4.5
■参考にしたサイト
https://dialogflow-python-client-v2.readthedocs.io/en/latest/
こちらのDetecting Intent (Texts)を参考にしています。
■APIのコード
local.py
1project_id = "プロジェクトのID" 2session_id = "" 3language_code = "ja" 4session_client = dialogflow.SessionsClient() 5 6session = session_client.session_path(project_id, session_id) 7 8text_input = dialogflow.types.TextInput(text=query, language_code=language_code) 9query_input = dialogflow.types.QueryInput(text=text_input) 10response = session_client.detect_intent(session=session, query_input=query_input) 11print('Query text: {}'.format(response.query_result.query_text)) 12print('Detected intent: {} (confidence: {})\n'.format(response.query_result.intent.display_name,response.query_result.intent_detection_confidence)) 13print('Fulfillment text: {}\n'.format(response.query_result.fulfillment_text))
■コード実行時のエラー
2018-08-06 17:43:45,347 _default.py 303 WARNING No project ID could be determined. Consider running `gcloud config set project` or setting the GOOGLE_CLOUD_PROJECT environment variable Traceback (most recent call last): File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\grpc_helpers.py", line 54, in error_remapped_callable return callable_(*args, **kwargs) File "C:\Anaconda3\envs\py34\lib\site-packages\grpc\_channel.py", line 514, in __call__ return _end_unary_response_blocking(state, call, False, None) File "C:\Anaconda3\envs\py34\lib\site-packages\grpc\_channel.py", line 448, in _end_unary_response_blocking raise _Rendezvous(state, None, None, deadline) grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with: status = StatusCode.PERMISSION_DENIED details = "Dialogflow API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry." debug_error_string = "{"created":"@1533545026.267000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1095,"grpc_message":"Dialogflow API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","grpc_status":7}" > The above exception was the direct cause of the following exception: Traceback (most recent call last): File "local.py", line 42, in <module> response = session_client.detect_intent(session=session, query_input=query_input) File "C:\Anaconda3\envs\py34\lib\site-packages\dialogflow_v2\gapic\sessions_client.py", line 270, in detect_intent request, retry=retry, timeout=timeout, metadata=metadata) File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\gapic_v1\method.py", line 139, in __call__ return wrapped_func(*args, **kwargs) File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\retry.py", line 260, in retry_wrapped_func on_error=on_error, File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\retry.py", line 177, in retry_target return target() File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\timeout.py", line 206, in func_with_timeout return func(*args, **kwargs) File "C:\Anaconda3\envs\py34\lib\site-packages\google\api_core\grpc_helpers.py", line 56, in error_remapped_callable six.raise_from(exceptions.from_grpc_error(exc), exc) File "<string>", line 3, in raise_from google.api_core.exceptions.PermissionDenied: 403 Dialogflow API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。