Assign chats to your agents in Round Robin style

Jahnavi Prasad Updated by Jahnavi Prasad

Use Case: We have users that come to our WhatsApp phone number and start chats with us. These incoming chat requests must be assigned in a round-robin fashion so that each agent receives their fair share of work without any manual effort from Admin users.

This solution requires a WATI Professional or Enterprise account to implement.Solution

Solution logic:

How to implement:

  1. Create a contact in WATI with a random invalid phone number
    Eg. Name: Robin, Phone: 1234567890
  2. Create a New Flow in the Automation Section, Keep the API Docs page open in a different tab
  3. Choose the Webhook node as starting step and enter details as shown below:
    1. URL & Method: GET <api_endpoint>/api/v1/getContacts?name=Robin
      Replace <api_endpoint> with your API Endpoint found in the API Docs section
    2. Enable Save Responses as Variables and add a Response Variable
      Variable Name: robin_value
      Entire Response Body: contact_list[0].customParams[2].value
  4. Connect the Webhook Node to a 'Send a Message' node to print the for robin_value testing
  5. Connect this to a 'Set a condition' node to check if is robin_value = 1
    1. If yes, we make an API call to the updateContactAttributes endpoint that will update robin_value to 2
      Then we assign the chat to Agent 1 using the 'Assign Agent' Node
    2. If no, we use the 'Set a condition' node to check if is robin_value = 2
      1. If yes, we make an API call to the updateContactAttributes endpoint that will update robin_value to 3
        Then we assign the chat to Agent 2 using the 'Assign Agent' Node
      2. If no, we use the 'Set a condition' node to check if is robin_value = 3
        1. If yes, we make an API call to the updateContactAttributes endpoint that will update robin_value to 4
          Then we assign the chat to Agent 3 using the 'Assign Agent' Node
        2. And so on until we reach the last agent, in that case, we make an API call to the updateContactAttributes endpoint that will update robin_value back to 1
  6. How to make an API call to the updateContactAttributes endpoint to update robin_value
    1. URL & Method: GET <api_endpoint>/api/v1/updateContactAttributes/1234567890
      Replace <api_endpoint> with your API Endpoint found in the API Docs section
    2. Customize Headers: Add an Authorization header with your access token
    3. Customize Body:
      Update the numerical value of robin_value in the value field
      {
      "customParams": [
      {
      "name": "robin_value",
      "value": "2"
      }
      ]
      }

Make sure you enabled the 'Send the following welcome message' setting under the Automation section and chose the Round Robin flow we created.

How did we do?

How to test a flow?

Contact