The Node.js SDK is continually evolving, with new endpoints being added for notifications, events, and more. Stay tuned for updates!

Overview

The Roark Node.js SDK provides a streamlined way to interact with the Roark API. This guide will help you quickly set up the SDK and start analyzing call recordings in your application.

Prerequisites

Before you begin, ensure you have:

Installation

Choose your preferred package manager:

npm install @roarkanalytics/sdk

Quick Start

1

Import the SDK

import Roark from '@roarkanalytics/sdk';
2

Initialize the Client

const client = new Roark({
  bearerToken: 'YOUR_ROARK_API_KEY'
});

Replace YOUR_ROARK_API_KEY with your actual API key from Roark.

3

Create an evaluation job for one or many calls

You can find the evaluator slug from the Evaluators section on the dashboard. Or you can use all to evaluate with all available evaluators.

// Create an evaluation for a single call
const response = await client.evaluation.create({
  /**
   * You can find the evaluator slug from the Evaluators section on the dashboard
   * Or you can use 'all' to evaluate with all available evaluators.
   * 
   * Evaluators to evaluate the call
   * Usage examples:
   * - Specific evaluators: evaluators: ['evaluator-slug-1', 'evaluator-slug-2']
   * - All evaluators: evaluators: 'all'
   */
  evaluators: ['evaluator-slug-1', 'evaluator-slug-2'],
  call: {
    recordingUrl: 'https://example.com/recording.wav',
    callDirection: 'INBOUND' as CallDirectionEnum,
    interfaceType: 'WEB' as CallInterfaceTypeEnum,
    startedAt: new Date(),
    isTest: false,
    participants: [
      {
        name: 'Sales Agent',
        phoneNumber: '+15551234567',
        role: 'AGENT' as CallParticipantRoleEnum,
        spokeFirst: true,
      },
      {
        name: 'John Doe',
        phoneNumber: '+15557654321',
        role: 'CUSTOMER' as CallParticipantRoleEnum,
        spokeFirst: false,
      },
    ],
    properties: {
      // any custom properties
      business_name: 'customer-business-name',
      business_id: 'customer-business-id',
    },
    toolInvocations: [
      {
        name: 'getDentalAppointments',
        description: 'Get available dental appointments',
        startOffsetMs: 2000,
        endTimeOffsetMs: 3000,
        parameters: {},
        result: { appointments: ['cleaning', 'whitening', 'rootCanal'] },
      },
      {
        name: 'bookAppointment',
        description: 'Book an appointment for the client',
        startOffsetMs: 7000,
        endTimeOffsetMs: 7500,
        parameters: {
          patientName: 'John Doe',
          patientPhone: '+1234567890',
          appointmentType: {
              // Parameter values can alternatively be objects which include the value and an optional description and type
              value: 'cleaning',
              description: 'Type of dental appointment',
              type: 'string',
          },
        },
        // Result can be a string or an object
        result: 'Success',
      },
    ],
  },
});

console.log('Evaluation created:', response.data);
4

You're All Set

That’s it! You can now use the SDK to create evaluations

Additional Resources