Below is the complete set of detailed notes (including API configurations, JSON contracts,
and Python code examples) for real‐time data action integrations in Genesys Cloud CX and
Salesforce.
Summary of the Content
1. Genesys Cloud CX Data Actions – Real-Time Examples
1.1 Fetching Agent Availability Count Based on Queue
• Business Case: A contact center needs to determine how many agents are available in a
specific queue to efficiently route calls.
• API Endpoint:
GET /api/v2/routing/queues/{queueId}/members
• Input Contract (JSON):
{
"queueId": "12345-abcde-67890"
}
• Output Contract (JSON):
{
"totalMembers": 50,
"availableAgents": 10,
"offlineAgents": 40
}
• Mapping:
• Map the queueId from the Architect flow as input.
• Extract the availableAgents field from the API response.
• Python Code Example:
import requests, json
auth_token = 'YOUR_ACCESS_TOKEN'
url = 'https://api.mypurecloud.com/api/v2/routing/queues/12345-abcde-
67890/members'
headers = {
'Authorization': f'Bearer {auth_token}',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = json.loads(response.text)
print(json.dumps(data, indent=2))
else:
print(f'Error: {response.status_code}, {response.text}')
1.2 Getting Customer’s Last Interaction Details
• Business Case: To determine which agent handled a customer’s last interaction for quality
analysis.
• API Endpoint:
GET /api/v2/conversations/{conversationId}/participants
• Input Contract (JSON):
{
"conversationId": "abc123-456def-789ghi"
}
• Output Contract (JSON):
{
"participants": [
{
"userId": "agent123",
"role": "agent",
"startTime": "2024-03-12T08:15:30Z"
}
]
}
• Python Code Example:
url = 'https://api.mypurecloud.com/api/v2/conversations/abc123-456def-
789ghi/participants'
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=2))
else:
print(f'Error: {response.status_code}, {response.text}')
1.3 Getting Customer Details Based on ANI
• Business Case: Retrieve customer details from the CRM using their phone number (ANI).
• API Endpoint:
GET /api/v2/externalcontacts/contacts/{contactId}
• Input Contract (JSON):
{
"ANI": "+1234567890"
}
• Output Contract (JSON):
{
"id": "contact-12345",
"name": "John Doe",
"email": "[email protected]"
}
• Python Code Example:
url =
'https://api.mypurecloud.com/api/v2/externalcontacts/contacts/contact-
12345'
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=2))
else:
print(f'Error: {response.status_code}, {response.text}')
1.4 Additional Genesys Cloud Data Actions Examples
• Fetch Call Wrap-Up Codes for a Specific Agent:
Endpoint: GET /api/v2/users/{userId}/wrapupcodes
Example: Retrieve wrap-up codes after each call.
• Retrieve Queue Performance Metrics in Real Time:
Endpoint: POST /api/v2/analytics/queues/observations/query
Example: Get average wait time and current call volume.
• Send SMS Notification After Call Completion:
Endpoint: POST /api/v2/conversations/messages
Example: Send a follow-up SMS to customers after their call.
2. Salesforce Data Actions – Real-Time Examples
2.1 Fetching Customer Order Details from Salesforce
• Business Case: An agent needs to view the customer’s order history during a call.
• API Endpoint:
GET /services/data/v52.0/sobjects/Order/{orderId}
• Input Contract (JSON):
{
"orderId": "SF-00123"
}
• Output Contract (JSON):
{
"OrderNumber": "00123",
"CustomerName": "Jane Doe",
"Status": "Shipped",
"TotalAmount": 120.00
}
• Python Code Example:
access_token = 'YOUR_SALESFORCE_ACCESS_TOKEN'
url = 'https://your-
instance.salesforce.com/services/data/v52.0/sobjects/Order/SF-00123'
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print(json.dumps(data, indent=2))
else:
print(f'Error: {response.status_code}, {response.text}')
2.2 Additional Salesforce Data Actions Examples
• Fetch Customer Case Status:
Endpoint: GET /services/data/v52.0/sobjects/Case/{caseId}
Retrieve case details and status for ongoing support.
• Create a New Lead in Salesforce:
Endpoint: POST /services/data/v52.0/sobjects/Lead/
Create a lead using customer details gathered during an interaction.
• Update Customer Contact Information:
Endpoint: PATCH /services/data/v52.0/sobjects/Contact/{contactId}
Update contact details in real time to ensure data accuracy.
3. Converting API Responses to JSON Format in Genesys Cloud Data Actions
• Request Handling: Map the input contract to the API endpoint.
• Response Mapping: Convert the API response to JSON format so that Genesys Cloud can
use the data.
• Using Velocity Templates (VTL):
• Use VTL to manipulate JSON responses dynamically.
• For example, extract specific fields or reformat the JSON for use in your Architect flows.
4. List of Available APIs in Genesys Cloud CX
Routing APIs:
• GET /api/v2/routing/queues – Retrieve queue details.
• GET /api/v2/routing/queues/{queueId}/members – Retrieve members in a queue.
• POST /api/v2/routing/queues – Create a new queue.
Conversation APIs:
• GET /api/v2/conversations/{conversationId} – Get conversation details.
• GET /api/v2/conversations/calls/{callId} – Get call details.
• POST /api/v2/conversations/callbacks – Create a callback request.
User and Agent APIs:
• GET /api/v2/users – Retrieve a list of users.
• GET /api/v2/users/{userId} – Get details of a specific user.
• GET /api/v2/users/{userId}/queues – Retrieve queues assigned to a user.
Analytics APIs:
• POST /api/v2/analytics/conversations/details/query – Fetch conversation analytics.
• POST /api/v2/analytics/queues/observations/query – Get real-time queue performance.
External Contacts APIs:
• GET /api/v2/externalcontacts/contacts – Retrieve external contacts.
• POST /api/v2/externalcontacts/contacts – Create a new contact.
5. Best Practices for Data Action Handling
• Use OAuth 2.0 Authentication for secure access.
• Implement error handling for API failures.
• Map input and output contracts accurately to prevent data mismatches.
• Regularly monitor API performance to identify potential bottlenecks.
• Ensure compliance with data privacy regulations when handling sensitive data.