Skip to main content
Learn how to set up call routing automation that ensures clients are always connected to the last agent they spoke with. This guide walks you through configuring the logic step-by-step, improving customer experience by maintaining continuity and personalizing support with every call.
User level: Admin
Routing calls to the last agent a client spoke with is a powerful strategy to enhance customer experience. This approach is especially beneficial for businesses with recurring interactions, ongoing support cases, or high-value clients. It builds trust, reduces repetition, and ensures smoother, more personalized conversations -ultimately boosting satisfaction and efficiency.

How to Set Up Routing to the Last Agent

To implement this use case effectively, the setup involves two key components working together.
  • An automation scenario in CloudTalk Workflow Automation ensures the agent who last spoke with the client is automatically assigned as their favorite agent.
  • A routing logic is configured in the Call Flow Designer to prioritise connecting incoming calls to this favorite agent.
This two-part setup guarantees both continuity and flexibility in customer interactions.

Automating Favorite Agent Assignment

  1. Navigate to Cloudtalk Dashboard > Settings > Workflow Automations and click + Add Workflow
  2. Select Call ended as the trigger event.
  3. Define conditions to determine when a favorite agent should be assigned. For example, only after an outgoing call where conversation with contact lasted longer than 5 seconds.
  4. To assign a favorite agent to the contact profile, set up an API Request to CloudTalk’s Update a contact endpoint. Configure the API Request action using the structure below:
    1. Endpoint:
      https://api.cloudtalk.io/v1/contacts/#{{ event.properties.contacts[0].id }}
    2. Method: PATCH
    3. Headers:
      • Authorization: Basic your_encoded_credentials
    4. Values:
      • favoriteUserId → #{{ event.properties.agent.id }} (Format: String)
  5. Once all steps are configured, save the setup and activate the workflow to start assigning favorite agents automatically based on your defined conditions.
Important: The contacts endpoints use the base URL https://api.cloudtalk.io/v1. The API overview lists the base URL of each CloudTalk API.

Assigning a favorite agent to unknown numbers

The workflow above updates contacts that already exist. For numbers that aren’t saved as a contact or lead, set up a second workflow that creates the contact with the favorite agent already set:
  1. Navigate to CloudTalk Dashboard > Settings > Workflow Automations and click + Add Workflow. Select Call ended as the trigger event.
  2. Add a condition so the workflow only continues when the number isn’t saved under any contact or lead:
    • Property: {% if event.properties.contacts[0].id %}false{% else %}true{% endif %}
    • Operand: is equal to
    • Value: true
  3. Add an API Request action to CloudTalk’s Create a contact endpoint:
    1. Endpoint: https://api.cloudtalk.io/v1/contacts
    2. Method: POST
    3. Headers: Authorization: Basic your_encoded_credentials
    4. Values:
      • name → #{{ event.properties.external_number }}@cloudtalk (you can change this format)
      • phones.0 → #{{ event.properties.external_number }}
      • favoriteUserId → #{{ event.properties.agent.id }} (Format: String)
  4. Save the setup and activate the workflow.
Contacts created this way also sync to any integrations you have connected. When you copy the values, check that the quote marks stay straight: some editors turn them into curly quotes, which break the request.

Prioritising Favorite Agent in Call Routing

  1. Go to your CloudTalk Dashboard → Numbers, and click + Configure (or the flow name) in the Call Flow column next to the number you want to apply the routing logic to.
  2. Once the Call Flow Designer opens, click the + button at the appropriate point in your routing sequence and add a Ring to step. In the config panel, set Ring target to Favorite agent. Set the Ring for duration and click Save.
  3. Set up follow-up actions for both Answered and If unanswered branches, if needed (e.g., forward to team or voicemail).
  4. Click Save in the top-right corner to make your flow live.
  5. Save you Call flow.
If the contact doesn’t have a favorite agent yet, the Ring to step (target: Favorite agent) will be skipped automatically. The call will then continue with the next step you’ve set up under the “If unanswered” path in your call flow.

Need help or have a question? Just reach out through our Support portal — we’re here for you.