Fallback Routing can be used to route chats to a different team if the current is full of capacity in Salesforce.
Please check the following implementation. If Team A from Chat Button A is full of capacity or not available, then the chats will be routed to the Team B of Chat Button B.
1. Create Two queues for the two teams.
2. Create two Chat buttons.
Button for Team A:
Button for Team B:
3. Use the fallback routing.
//An array of button IDs, user IDs, or userId_buttonId
embedded_svc.settings.fallbackRouting = [ '5738c000000QrsX', '5738c000000Qrsc' ];
Output: