Node.js
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 SDK using npm or yarn:
npm install @acro-sdk/conversations
or
yarn add @acro-sdk/conversations
Using the Sdk
To send conversation data to the Acro platform, follow these steps:
Initialize the SDK
Log in to app.acro.so, create an application, and obtain your credentials:
import SDK from "@acro-sdk/conversations";
const sdk = new SDK({
applicationId: "your_application_id",
secret: "your_secret",
});
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
const conversationData = {
conversationId: "123e4567-e89b-12d3-a456-426614174000",
source: "mywebsite.com",
customerId: "cust_123",
start: new Date(),
lines: [
{
role: "AI_ASSISTANT",
content: "Hello! How can I help you today?",
timestamp: new Date()
},
{
role: "USER",
content: "I need help with my order",
timestamp: new Date()
}
]
};
const result = await sdk.send(conversationData);
if (!result.conversationId) {
console.error("Acro SDK Error:", result.error);
} else {
console.log("Successfully sent conversation:", result.conversationId);
}
Response Types
Success Response
type AcroApiSuccess = {
conversationId: string;
requestId: string;
};
Error Response
type AcroApiError = {
error: string;
requestId: string;
};
Need help? Join our Discord community or Schedule a meeting with us.