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

PropertyTypeRequiredDescriptionConstraints
conversationIdUUID stringYesUnique identifier for the conversationValid UUID format
linesArrayYesComplete transcript of the conversationSee Lines Schema below
startDate/stringYesWhen the conversation beganISO date string or Date object

End User Information

The person interacting with your AI Agent.

PropertyTypeRequiredDescriptionConstraints
customerIdstringNoUnique identifier for the customerMax 64 chars
customerEmailstringNoCustomer’s email addressMax 320 chars, valid email
customerPhonestringNoCustomer’s phone numberMax 128 chars

Agent Information

The AI Agent properties.

PropertyTypeRequiredDescriptionConstraints
agentIdstringNoIdentifier for the AI agentMax 64 chars
agentVersionstringNoVersion of the AI agentMax 128 chars

Client Information

This refers to the business using your AI Agent to run their operations.

PropertyTypeRequiredDescriptionConstraints
externalCompanyIdstringNoClient company identifierMax 64 chars
externalCompanyNamestringNoClient company nameMax 256 chars
externalCompanyTypestringNoIndustry/category of clientMax 128 chars

Conversation Metadata

More optional metadata so that we can analyze your agent.

PropertyTypeRequiredDescriptionConstraints
sourceEnumNoOrigin of conversationMax 64 chars
endDate/stringNoWhen conversation endedISO date string or Date object
durationnumberNoLength of conversationInteger (seconds)
transferbooleanNoWhether conversation was transferred-
completedbooleanNoWhether conversation finished normally-
textUrlstringNoURL to conversation transcriptValid URL
audioUrlstringNoURL to conversation recordingValid URL

Lines Schema

Each line in the lines array must conform to this structure:

PropertyTypeRequiredDescription
roleEnumYesWho is speaking/acting
contentstring|nullYesThe message content
timestampDate/stringNoWhen 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.