Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Agent Builder Auth for cloud function

I have created an agent builder app with a tool that calls a cloud function 2nd gen. It works if i select allow all in the corresponding cloud run. But if i set it to authorized, then i get a 401 error. This is while testing from the built in tester. i have set the dialog flow service agent to have the correct run role and I  also have cloud run role permissions. If i go to the console and test it from there by passing in my bearer token, it works fine. Somehow, i am still missing something that allows the UI to work properly. If anyone has a clue...  

4 4 1,237
4 REPLIES 4

Figured it out - it was using the default "AI Platform Service Agent" service account - once i added the invoker role to this, it worked fine.

Unfortunately - spoke too soon. It was probably a delay from switching from allow all to restricted. The issue still persists.

Hey, did you find a solution for this? Currently facing the same issue.

The solution is that you need to give `Dialogflow` the following role: "Cloud Function Invoker." To find your service, you can just type in `Principle` "Dialogflow," and it will show up there. If it still does not work then you should add the Principle manually: You cloud function -> Permissions -> Add Principle -> "Cloud Function Invoker". It should work after that.