Skip to main content

Activity

An activity is a synonym for a call. It is used to describe the current state of a call.

The activity has different shapes depending on the type of the call.

Shapes

Common shape

interface CommonActivityPayload {
id: number;
callUuid: string;
// null is used when the call is not yet finished
duration: number | null;
line: {
id: number;
name: string;
number: string;
};
state: 'finished' | 'ongoing';
createdAt: string;
tags: Tag[];
notes: Note[];
}

Regular call

Regular call is a call that an agent could have with an external number.

This call is split into two categories.

Answered Call

export interface AnsweredRegularCall extends CommonActivityPayload {
agent: {
id: number;
fullName: string;
};
external: {
phoneNumber: string;
};
direction: 'outgoing' | 'incoming';
type: 'regular';
subtype: 'answered';
}

Missed Call

interface BaseMissedCall extends CommonActivityPayload {
subtype: 'missed' | string;
type: 'regular';
}

type MissedReason =
| 'abandoned_in_classic'
| 'abandoned_in_ivr'
| 'agents_did_not_answer'
| 'no_available_agent'
| 'out_of_opening_hours'
| 'short_abandoned';

export interface MissedOutboundCall extends BaseMissedCall {
direction: 'outgoing';
subtype: 'missed' | 'follow_up';
agent: {
id: number;
fullName: string;
};
missed: {
reason: MissedReason | null;
};
}

export interface MissedInboundCall extends BaseMissedCall {
direction: 'incoming';
subtype: 'missed' | 'callback' | 'voicemail';
agent: null;
missed:
| {
reason: MissedReason | null;
}
| {
reason: MissedReason | null;
proxied_voicemail_url: string;
duration: number;
};
}

export type MissedRegularCall = MissedOutboundCall | MissedInboundCall;
export type RegularCall = AnsweredRegularCall | MissedRegularCall;

Transfer call

export interface TransferCall extends CommonCallPayload {
transferer: SimpleUser;
transferee: External | SimpleUser;
external: External;
direction: 'outgoing' | 'incoming';
type: 'transfer';
}

Activity

So the final shape is a union of all the above shapes.

export type Activity = RegularCall | TransferCall;