Once you identify a recipient and optionally confirm that the recipient can receive verified calls, you can register a call. Registered calls appear as verified in recipients' incoming call screens.
Be sure to register the call before placing the call to the recipient. If you register a call after placing it, the recipient's incoming call screen will not update with your agent information after their device receives your call registration information. You must place the call within 5 minutes of registering the call. Otherwise, the registration will expire and the call will not be verified.
Prerequisites
Before you can register a call, you need to gather some information:
- Path to your GCP project's service account key on your development machine
- The brand phone number placing the call, in E.164 format (for example, "+12223334444")
- The recipient's phone number, in E.164 format (for example, "+56667778888")
- (Optional) The reason for the call
Additionally, you need the
gcloud
command line tool
installed on your development machine.
Register a call
To register a call with Verified Calls, run the following command. Replace variables with values you identified in Prerequisites.
- Prepare your credentials.
cURL
export GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_SERVICE_ACCOUNT_KEY
ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
Python
import json import os import time import jwt import requests service_account_path = PATH_TO_SERVICE_ACCOUNT_KEY current_time = round(time.time()) # Open the json service account key with open(service_account_path) as f: service_key = json.load(f) # Prepare the payload and headers for OAuth payload = { 'iss': service_key['client_email'], 'scope': 'https://www.googleapis.com/auth/businesscommunications https://www.googleapis.com/auth/cloud-platform', 'aud': 'https://oauth2.googleapis.com/token', 'exp': current_time + 3600, 'iat': current_time} additional_headers = {'kid': service_key['private_key']} # Encode the jwt signed_jwt = jwt.encode(payload, service_key['private_key'], headers=additional_headers, algorithm='RS256') # Prepare the data and make the OAUTH request data = { 'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion': signed_jwt } response = requests.post('https://oauth2.googleapis.com/token', data=data) # Save the access token token = json.loads(response.text)['access_token']
For full example see our client samples
Java/Node.js/PHP
For more examples see our client samples
- Register the call.
cURL
curl -X POST "https://businesscalls.googleapis.com/v1:sendVcallVerification" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/verified-calls" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d "{ 'brandNumber': 'BRAND_PHONE_NUMBER', 'deviceNumber': 'RECIPIENT_PHONE_NUMBER', 'callReason': 'CALL_REASON', }"
Python
headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {}'.format(token), } data = { 'brandNumber': '+16400000001', 'deviceNumber': '+16400000000', 'callReason': 'Test call reason.', } response = requests.post( 'https://businesscalls.googleapis.com/v1:sendVcallVerification', headers=headers, data=json.dumps(data)) print(response.content)
For full example see our client samples
Java/Node.js/PHP
For more examples see our client samples
Next steps
Now that you've registered a call with Verified Calls, you can update the state of a verified call.