Generate Dialogflow Google Credentials File
In this tutorial you’ll learn how to generate a Dialogflow’s Service Account Google Credentials file (.json) to use in Pingstreams chatbot integrations.
In general, this file allows you to query your Dialogflow Agent from a Client component, like a web service, a proxy and so on.
Access Dialogflow Console
Section titled “Access Dialogflow Console”Go to your Dialogflow console and select the agent for whom you want to generate the Credentials file.
With the agent’s name shown in the top left corner, click on the ⚙︎ beside the name:

Access Service Account
Section titled “Access Service Account”The “General” tab is selected. Click on the Service Account link, as shown by the arrow in the following figure:

Create Service Account
Section titled “Create Service Account”In the Service accounts section click on the top menu option + CREATE SERVICE ACCOUNT:

Now choose a name for your service account (Service account name field). Service account ID is autogenerated based on name. Choose an optional Service account description if you prefer. Press “CREATE” button.

Assign Role
Section titled “Assign Role”In the next step you will be asked to select the role for this Service account. Press the menu pointed by the arrow in the figure (Select a role):

A menu will open with an autocompleting text box. Type “dialogflow” and, from the listed results choose Dialogflow API Client as role:

Then press “Continue”.
Create Key
Section titled “Create Key”In the last step, leaving all the options with their default value, press + CREATE KEY button on the Service Account form’s bottom.
Choose JSON (default option) from the right panel, then CREATE.

Download Credentials File
Section titled “Download Credentials File”Now Google Cloud Console will generate your private key (your Google Credentials file) that will allow you to call Dialogflow APIs from the Pingstreams proxy (or from whatever application you want):

:::warning Security Notice As highlighted in the popup you must securely save the file on your computer and never publish it online (for example never push this file on public Github repos). :::
Using the Credentials File
Section titled “Using the Credentials File”The downloaded JSON file contains all the necessary credentials to authenticate with Dialogflow APIs. The file structure typically looks like this:
{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "key-id",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "service-account@your-project.iam.gserviceaccount.com",
"client_id": "client-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account%40your-project.iam.gserviceaccount.com"
}Best Practices
Section titled “Best Practices”Security
Section titled “Security”- Never commit credentials to version control: Add
*.jsonto your.gitignore - Use environment variables: Store the file contents in environment variables for production
- Rotate keys regularly: Create new keys periodically and delete old ones
- Limit permissions: Only grant the minimum necessary permissions
Usage in Applications
Section titled “Usage in Applications”- Environment Variables: Store the entire JSON content as an environment variable
- File Storage: Store the file securely on your server with restricted access
- Container Secrets: Use container orchestration secrets for cloud deployments
Integration with Pingstreams
Section titled “Integration with Pingstreams”In some Pingstreams tutorials or documentation you will be asked to have this file on hand, so please refer to this tutorial to generate a new one when needed.
The credentials file enables your Pingstreams external chatbot to communicate securely with your Dialogflow agent, providing the foundation for all the advanced integration features covered in the other tutorials.
Enjoy your Pingstreams integration!