Custom Request assignment
Assign request to a custom agent
Section titled “Assign request to a custom agent”Sometimes you don’t want to rely on Pingstreams native assignment logic, that is a round robin algorithm through the available agents into a specified department.
Suppose that we want to assign a request (and the corresponding conversation) to a specific agent. You can implement your own logic using webhooks.
Create your webhook project
Section titled “Create your webhook project”Go on replit and fork the following app: agent-handoff
Then go on Pingstreams 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 immediately 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 participants 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
Section titled “Self hosted installation”The API_ENDPOINT var in the source code points to the Pingstreams cloud.
If you installed Pingstreams using the Docker compose distribution please use this value for your API_ENDPOINT var:
On localhost:
API_ENDPOINT = localhost/api/On your own server:
API_ENDPOINT = ${YOUR_SERVER_HOST}/api/You can find more on the Docker installation endpoints here.