Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/phone-integration-active-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@epilot/phone-integration-client": minor
"@epilot/sdk": minor
---

Phone Integration: the active call of the signed-in user — `getActiveCall` (is the user on a call, and the phone system's `conversation_id` that ties journey submissions, tickets and the `call` entity together), `reportActiveCall` and `clearActiveCall` (the epilot 360 phone reports the call it holds).
50 changes: 50 additions & 0 deletions clients/phone-integration-client/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ describe('Phone Integration client', () => {
expect(client.defaults.baseURL).toBe('https://phone-integration-api.sls.epilot.io');
expect(client.api.getOperations().map((operation) => operation.operationId)).toEqual([
'batchSearchCustomers',
'getActiveCall',
'reportActiveCall',
'clearActiveCall',
'getManagerStatus',
'listPhoneAgents',
'assignPhoneAgent',
Expand Down Expand Up @@ -84,6 +87,53 @@ describe('Phone Integration client', () => {
expect(response.data).toEqual(result);
});

it('reads, reports and clears the active call on one path', async () => {
const client = createClient();
const onCall: Components.Schemas.ActiveCall = {
on_call: true,
conversation_id: '01KW704DAM1PM5SDGKFDY9BNK0',
started_at: '2026-11-10T10:00:00.000Z',
source: 'softphone',
expires_at: '2026-11-10T10:02:00.000Z',
};
const requests: Array<{ method?: string; url?: string; params?: unknown; data?: unknown }> = [];
client.defaults.adapter = async (config) => {
requests.push({ method: config.method, url: config.url, params: config.params, data: config.data });
return config.method === 'delete'
? { config, data: '', status: 204, statusText: 'No Content', headers: {} }
: { config, data: onCall, status: 200, statusText: 'OK', headers: {} };
};

const reported = await client.reportActiveCall(null, {
conversation_id: '01KW704DAM1PM5SDGKFDY9BNK0',
started_at: '2026-11-10T10:00:00.000Z',
});
const read = await client.getActiveCall();
const cleared = await client.clearActiveCall({ conversation_id: '01KW704DAM1PM5SDGKFDY9BNK0' });

expect(reported.data).toEqual(onCall);
expect(read.data.conversation_id).toBe('01KW704DAM1PM5SDGKFDY9BNK0');
expect(cleared.status).toBe(204);
expect(requests).toEqual([
{
method: 'put',
url: '/v1/calls/active',
params: {},
data: JSON.stringify({
conversation_id: '01KW704DAM1PM5SDGKFDY9BNK0',
started_at: '2026-11-10T10:00:00.000Z',
}),
},
{ method: 'get', url: '/v1/calls/active', params: {}, data: undefined },
{
method: 'delete',
url: '/v1/calls/active',
params: { conversation_id: '01KW704DAM1PM5SDGKFDY9BNK0' },
data: undefined,
},
]);
});

it('caches getClient and keeps fresh client credentials isolated', () => {
const singleton = getClient();
singleton.defaults.headers.common.Authorization = 'Bearer singleton-token';
Expand Down
31 changes: 29 additions & 2 deletions clients/phone-integration-client/src/openapi-runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,33 @@
"responses": {}
}
},
"/v1/calls/active": {
"get": {
"operationId": "getActiveCall",
"responses": {}
},
"put": {
"operationId": "reportActiveCall",
"requestBody": {
"required": true,
"content": {
"application/json": {}
}
},
"responses": {}
},
"delete": {
"operationId": "clearActiveCall",
"parameters": [
{
"name": "conversation_id",
"in": "query",
"required": false
}
],
"responses": {}
}
},
"/v1/manager/status": {
"get": {
"operationId": "getManagerStatus",
Expand Down Expand Up @@ -395,7 +422,7 @@
"name": "tag",
"in": "path",
"required": true,
"description": "The skill, URL-encoded (e.g. `language%3Agerman`)"
"description": "The skill, URL-encoded (e.g. `language%3Agerman`), in any letter case (see `Skill`)"
}
],
"delete": {
Expand All @@ -415,7 +442,7 @@
"name": "tag",
"in": "path",
"required": true,
"description": "The skill, URL-encoded (e.g. `language%3Agerman`)"
"description": "The skill, URL-encoded (e.g. `language%3Agerman`), in any letter case (see `Skill`)"
}
],
"put": {
Expand Down
Loading
Loading