Skip to content

Commit

Permalink
try wrapping and completing task with settimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mythilytm committed Nov 14, 2024
1 parent 4ebb600 commit 4ef31d0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions functions/completeTaskAssignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,22 @@ const closeTaskAssignment = async (
assignmentStatus: 'wrapping',
attributes: event.finalTaskAttributes,
});

const aftertask = await client.taskrouter
.workspaces(context.TWILIO_WORKSPACE_SID)
.tasks(event.taskSid)
.fetch();
console.log(`Task ${aftertask} with attributes ${aftertask.attributes} has been completed`);

if (callSid) await client.calls(callSid).update({ status: 'completed' });
setTimeout(() => {
console.log('This will be executed in 10sec');
}, 10000);

// eslint-disable-next-line no-promise-executor-return
await new Promise((resolve) => setTimeout(resolve, 10000)); // Wait for 10 seconds

const completedTask = await task.update({
assignmentStatus: 'completed',
});

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

0 comments on commit 4ef31d0

Please sign in to comment.