Skip to content

Commit

Permalink
Merge pull request #721 from techmatters/CHI-2763-close-voice-calls
Browse files Browse the repository at this point in the history
CHI-2763 Task completion for voice call for the client
  • Loading branch information
mythilytm authored Nov 12, 2024
2 parents f098299 + 48e7498 commit ecd6310
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions functions/completeTaskAssignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@ const closeTaskAssignment = async (
.workspaces(context.TWILIO_WORKSPACE_SID)
.tasks(event.taskSid)
.fetch();
const attributes = JSON.parse(task.attributes);
const callSid = attributes?.call_sid;

await task.update({ attributes: event.finalTaskAttributes });
// Ends the task for the worker and client for chat tasks, and only for the worker for voice tasks
const completedTask = await task.update({
assignmentStatus: 'completed',
attributes: event.finalTaskAttributes,
});

const completedTask = await task.update({ assignmentStatus: 'completed' });
// Ends the call for the client for voice
if (callSid) await client.calls(callSid).update({ status: 'completed' });

return { type: 'success', completedTask } as const;
} catch (err) {
Expand Down

0 comments on commit ecd6310

Please sign in to comment.