Custom Request assignment

Assign request to a custom agent

Sometimes you don't want to rely on Tiledesk native assignment logic, that is a round robin alghoritm through the available agents into a specied department.
Suppose that we want to assign a request (and the corrispondenr conversation) to a specific agent. You can implmemente your own logic using webhooks.

Create your webhook project

Go on replit and fork the following app: agent-handoff
Then go on Tiledesk and create a new project. You can call it "Custom routing".
Now move in the Settings > Project Settings > Developer section and click on "MANAGE WEBHOOK"
Add this new webhook, taking care that the endpoint corresponds to the endpoint of your forked replit application followed by /webhooks:
In our case this is the endpoint.
Please use your application endpoint so you can modify the code as needed.
Create the subscription.
Now move to the Bots section and create a new bot. Choose "Resolution" as the bot type.
Name it as you prefer, create it and press "Activate" when asked. This will "attach" the new chatbot to the Default Department making the bot immediatly available to end users.
Leave all settings on the default.
Now move to "Routing & Departments" section.
Select the "Default department" and change the Routing rules from the (default) "Assigned" to the "Pooled" mode.
Well, it's done. Now let's test.
As soon as a new request is updated the code on your web application will receive an event "request.update".
The code will check if no participiants are present in the conversation. If participantsAgents[] is empty this means that the request is in the Unassigned queue (aka in the "pool"). The code then simply queries all the teammates and select the first one, who the request will be assigned to. Feel free to choose your own logic to implement the assignment.

Self hosted installation

The API_ENDPOINT var in the source code points to the Tiledesk cloud.
If you installed Tiledesk using the Docker compose distribution please use this value for your API_ENDPOINT var:
On localhost:
API_ENDPOINT = localhost/api/
On your own server:
You can find more on the Docker installation endpoints here.