Last agent smart routing ensures that returning callers are automatically connected to the agent who last contacted them. By using Aircall’s Ring-to (via API) widget in Smartflows, you can enhance your outbound calling efforts and deliver a more seamless experience for your returning customers.
Important: The Ring-to (via API) widget must be enabled via a feature flag. Please contact your Aircall representative to enable this before proceeding.
Note: The video tutorial may show the previous version of the Test Response section. Always rely on the written steps in this article for the most current guidance.
Why use last agent smart routing?
Using the Ring-to (via API) widget to configure last agent routing provides several advantages:
- Improved caller experience by connecting returning customers to the agent familiar with their case
- Reduced call abandonment since calls go directly to a known point of contact
- Increased efficiency, preventing the entire team from being interrupted by unrelated inbound calls
- Better lead handling as agents focus on their own prospects
Create your Aircall API key
To begin, you need an Aircall API key. This will allow the Ring-to (via API) widget to authenticate and fetch call history.
Steps
- In the Aircall Dashboard, go to Integrations & API > API Keys.
- Click Generate an API Key.
- Name your key, then copy the API ID and API token.
- Save them securely, as this is the only time the token will be visible.
- Click Confirm.
Note: If you lose the token, you will need to generate a new one.
Set up the Ring-to (via API) widget in Smartflows
Now, configure your Smartflow using the API key to enable dynamic routing.
Steps
- In the Aircall Dashboard, navigate to the Smartflows number you want to configure.
-
Insert the Ring-to (via API) widget at your desired position in the call flow.
Note: Users routed via the API do not need to be assigned to the Smartflows call distribution. However, if they are assigned, they will receive missed call notifications in their To-Do list.
- Configure the Request in the widget editor:
-
URL: Copy and paste in the following URL - https://api.aircall.io/v1/calls/search?direction=outbound&order=desc&phone_number={{callerNumber}}
- This URL will search for the most recent outbound call made to the current inbound caller’s number, returning the corresponding Aircall user.
- Method: In the Method drop down, POST and GET will be available options. Make sure that you have selected GET
-
Authentication: In the Authentication drop down, the following options will be available - Basic Auth (User & Password), Bearer token, API Key, OAuth, and None. Make sure that you have selected Basic Auth (User & Password)
-
Credentials: Select Set credentials and enter the following information -
- Username = your API ID
- Password = your API token
-
URL: Copy and paste in the following URL - https://api.aircall.io/v1/calls/search?direction=outbound&order=desc&phone_number={{callerNumber}}
- Scroll down and configure the Response:
- Response type: In the Response type dropdown, User (ID or email), Team (ID), Aircall number (internal), External number, and Dynamic Target (ID) will be available as options. Make sure that you have selected User (ID or email)
-
Path: Copy and paste the following into the Path field - calls[0].user.id
- To conclude, you must run a test on the response in the dedicated Test response field. This field accepts a JSON object containing one or more input variables used in your request URL or body.
- For this example, you will need to provide the callerNumber in E.164 format, but you may also include other variables if your configuration requires them.
-
Example:
{
"callerNumber": "+15551234567"
} - When you run the test, the widget will substitute the variable(s) in your request with the values from the JSON and display the parsed result based on your configured path (calls[0].user.id). Make sure the returned payload contains the expected data so the widget can correctly route the call.
- Adjust ringing settings below the test field as needed to match your operational preferences.
Tip: Always run a test to validate the path returns a correct Aircall user ID.
Optional: Add a fallback team
Consider adding a fallback team after the Ring-to (via API) widget to ensure that no calls are missed if the last agent is unavailable.
Note: All routing targets (users, teams, numbers) must exist before configuring the Ring-to (via API) widget.
Need help?
If you'd like support implementing this setup or want to explore other automation options, visit our Professional Services page to book time with a Technical Consultant.