This section describes steps undertaken to configure GCP modules to work with eachother. In other words, provide a filtered list of tweaks I made in a long trial-and-error pursuit to get all the modules authenticated with each other. These steps shouldn’t really need to be repeated, unless we need to rebuild from scratch.
Cloud functions have their own authentication that dictates what tools can call them. In our case, Dialogflow must be able to send POST requests to the Cloud Function webhooks. This is managed with IAM principals and roles.
In our case, we had to manually create the appropriate service agent for Dialogflow and then grant it the appropriate permissions. Make sure the project IAM settings have an entry for the account [email protected] with these roles granted -
We use a combination of two official python packages for interacting with our Firestore instance -
firebase_admin - for univresal tasks across firebase, including Firestore, but we use it for most reads across Firestoregoogle.cloud.firestore_v1- more granular access to firestore REST functions, refFor integration with Facebook, we need a Facebook Page and a Developer App. Here’s a visual describing how this pieces together -
sequenceDiagram
participant User
participant Messenger
participant Facebook Page
participant Facebook App
participant DialogFlow
User->>Messenger: Sends a message
Messenger->>Facebook Page: Relays the message to your page
Facebook Page->>Facebook App: Notifies of the new message event
Facebook App->>DialogFlow: Sends a POST request (Webhook Event)
DialogFlow->>Facebook App: Processes & optionally responds
Facebook App->>Messenger: Sends your response
Messenger->>User: Displays the response