How to update the Case Owner to Chat agent when the Chat is accepted using Trigger in Salesforce?

We can use a trigger on the AgentWork entity to update the Case Owner to Chat agent when the Chat is accepted in Salesforce. Sample Trigger: Output: