I want to use the chatbot I created with Dialogflow as the main page of my website. Yet it tells me that google.api_core.exceptions.PermissionDenied: 403 IAM permission 'dialogflow.sessions.detectIntent' on 'projects/pollingagent-jnscpa/agent' denied.
when trying to talk to him.
I followed this tutorial that tells how to do it with Flask but I'm ready to shift to the easiest solution. I tried the following thing from the answers to a similar question:
- In Dialogflow's console, going to settings ⚙ > under the general tab, there is the project ID section with a Google Cloud link to open the Google Cloud console > Open Google Cloud.
- In google cloud, going to IAM Admin > IAM under tab Members. Find the name of my agents and then click on edit.
- Give admin permissions to the agent to give permissions to list intent.
So I don't know, maybe the problem is from my index.py?
from flask import Flask, request, jsonify, render_template
import os
import dialogflow
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
def detect_intent_texts(project_id, session_id, text, language_code):
session_client = dialogflow.SessionsClient()
session = session_client.session_path(project_id, session_id)
if text:
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)
return response.query_result.fulfillment_text
@app.route('/send_message', methods=['POST'])
def send_message():
message = request.form['message']
project_id = os.getenv('DIALOGFLOW_PROJECT_ID')
fulfillment_text = detect_intent_texts(project_id, "unique", message, 'en')
response_text = { "message": fulfillment_text }
return jsonify(response_text)
# run Flask app
if __name__ == "__main__":
app.run()