Python
Overview
The Acro SDK allows developers to seamlessly integrate with the Acro platform, providing detailed observability into the performance of your AI Assistants and chatbots. With this SDK, you can monitor conversations, analyze interactions, and enhance user experiences with ease.
Installation
Install the required dependencies using pip:
pip install requests
Using the API
To send conversation data to the Acro platform, follow these steps:
Initialize the configuration
Log in to app.acro.so, create an application, and set up your credentials:
import requests
from datetime import datetime
import uuid
APPLICATION_ID = "your_application_id"
APPLICATION_SECRET = "your_application_secret"
ACRO_URL = f"https://data.acro.so/{APPLICATION_ID}/conversation"
Properties
Required Information
Property | Type | Required | Description | Constraints |
---|---|---|---|---|
conversationId | UUID string | Yes | Unique identifier for the conversation | Valid UUID format |
lines | Array | Yes | Complete transcript of the conversation | See Lines Schema below |
start | Date/string | Yes | When the conversation began | ISO date string or Date object |
End User Information
The person interacting with your AI Agent.
Property | Type | Required | Description | Constraints |
---|---|---|---|---|
customerId | string | No | Unique identifier for the customer | Max 64 chars |
customerEmail | string | No | Customer’s email address | Max 320 chars, valid email |
customerPhone | string | No | Customer’s phone number | Max 128 chars |
Agent Information
The AI Agent properties.
Property | Type | Required | Description | Constraints |
---|---|---|---|---|
agentId | string | No | Identifier for the AI agent | Max 64 chars |
agentVersion | string | No | Version of the AI agent | Max 128 chars |
Client Information
This refers to the business using your AI Agent to run their operations.
Property | Type | Required | Description | Constraints |
---|---|---|---|---|
externalCompanyId | string | No | Client company identifier | Max 64 chars |
externalCompanyName | string | No | Client company name | Max 256 chars |
externalCompanyType | string | No | Industry/category of client | Max 128 chars |
Conversation Metadata
More optional metadata so that we can analyze your agent.
Property | Type | Required | Description | Constraints |
---|---|---|---|---|
source | Enum | No | Origin of conversation | Max 64 chars |
end | Date/string | No | When conversation ended | ISO date string or Date object |
duration | number | No | Length of conversation | Integer (seconds) |
transfer | boolean | No | Whether conversation was transferred | - |
completed | boolean | No | Whether conversation finished normally | - |
textUrl | string | No | URL to conversation transcript | Valid URL |
audioUrl | string | No | URL to conversation recording | Valid URL |
Lines Schema
Each line in the lines
array must conform to this structure:
Property | Type | Required | Description |
---|---|---|---|
role | Enum | Yes | Who is speaking/acting |
content | string|null | Yes | The message content |
timestamp | Date/string | No | When this line occurred |
Valid Role Values
"AI_ASSISTANT"
: AI agent messages"USER"
: End user messages"HUMAN"
: Human agent messages"TOOL"
: System actions/events"assistant"
: Alternative for AI_ASSISTANT"user"
: Alternative for USER"tool"
: Alternative for TOOL"system"
: System messages
Example Usage
import requests
from datetime import datetime
import uuid
# Configuration
APPLICATION_ID = "your_application_id"
APPLICATION_SECRET = "your_application_secret"
ACRO_URL = f"https://data.acro.so/{APPLICATION_ID}/conversation"
# Prepare headers
headers = {
"Authorization": f"Bearer {APPLICATION_SECRET}",
"Content-Type": "application/json"
}
# Prepare conversation data
conversation_data = {
"conversationId": str(uuid.uuid4()),
"source": "mywebsite.com",
"customerId": "cust_123",
"start": datetime.now().isoformat(),
"lines": [
{
"role": "AI_ASSISTANT",
"content": "Hello! How can I help you today?",
"timestamp": datetime.now().isoformat()
},
{
"role": "USER",
"content": "I need help with my order",
"timestamp": datetime.now().isoformat()
}
]
}
# Send request
try:
response = requests.post(ACRO_URL, json=conversation_data, headers=headers)
response.raise_for_status()
result = response.json()
print(f"Successfully sent conversation: {result['conversationId']}")
except requests.exceptions.RequestException as e:
print(f"Error sending conversation: {str(e)}")
if hasattr(e, 'response') and e.response is not None:
print(f"Error details: {e.response.text}")
Response Types
Success Response
{
"conversationId": "123e4567-e89b-12d3-a456-426614174000",
"requestId": "req_abc123"
}
Error Response
{
"error": "Error message description",
"requestId": "req_abc123"
}
Need help? Join our Discord community or Schedule a meeting with us.