This sample demonstrates how to use the Business Communications Python client library for performing operations with the Business Communications API.
This application assumes that you're signed up with Business Messages.
The documentation for the Business Commmunications API can be found here.
You must have the following software installed on your machine:
- Python - version 3.7.3 or above
- Register with Business Messages.
- Once registered, follow the instructions to enable the APIs for your project.
This sample application uses a service account key file to authenticate the Business Communication API calls for your registered Google Cloud project. You must download a service account key and configure it for the sample.
To download a service account key and configure it for the sample, follow the instructions below.
-
Open Google Cloud Console with your Business Messages Google account and make sure you select the project that you registered for Business Messages with.
-
Create a service account.
-
Navigate to Credentials.
-
Click Create service account.
-
For Service account name, enter your agent's name, then click Create.
-
For Select a role, choose Project > Editor, then click Continue.
-
Under Create key, choose JSON, then click Create.
Your browser downloads the service account key. Store it in a secure location.
-
Click Done.
-
Copy the JSON credentials file into this sample's /resources folder and rename it to "bc-agent-service-account-credentials.json".
-
In a terminal, navigate to this sample's project directory and install the dependencies.
python -m venv <your-env>
source <your-env>/bin/activate
pip install -r requirements.txt
This sample demonstrates how to create a new brand, get brand details, update a brand, list all brands, and remove the created brand.
View the source code.
Usage:
python brand_sample.py
Alternative usage:
python brand_sample.py NO-DELETE
If the NO-DELETE argument exists, the brand that gets created by the sample will not be deleted.
This sample demonstrates how to create a new agent, get agent details, update the agent, list all agent, and remove the created agent.
View the source code.
Usage:
python agent_sample.py <BRAND_NAME>
Replace BRAND_NAME with a valid brand ID in "brands/BRAND_ID" format. If you haven't created a brand, run the brand sample with the NO-DELETE argument to create a brand to reference.
Alternative usage:
python agent_sample.py <BRAND_NAME> NO-DELETE
Replace BRAND_NAME with a valid brand ID in "brands/BRAND_ID" format. If you haven't created a brand, run the brand sample with the NO-DELETE argument to create a brand to reference.
This sample demonstrates how to create a new location, get location details, update the location, list all location, and remove the created location.
View the source code.
Usage:
python location_sample.py <AGENT_NAME>
Replace AGENT_NAME with a valid agent ID in "brands/BRAND_ID/agents/AGENT_ID" format. If you haven't created an agent, run the agent sample with the NO-DELETE argument to create an agent to reference.
This sample lists all template questions provided by Google. You can configure an Agent to send these questions when a survey is triggered.
View the source code.
Usage:
python list_template_questions.py