Assign a conversation to a specific agent/teammate

To assign a conversation to a particular agent, you can use the special Operator selection webhook:

On every assignment the webhook is called. You can apply your own logic and call Tiledesk APIs to choose the right operator to assign the conversation to.

Use this simple replit application that implements some simple logic to assign the conversation to a specific teammate.

https://replit.com/@tiledesk/skill-routing#index.js

This is the main code, the webhook endpoint:

app.post('/webhooks', (req, res) => {
  if (req.body.hook.event === 'operator.select') {
    const payload = req.body.payload;
    const projectId = payload.project._id;
    const token = req.body.token;
    const tdclient = new TiledeskClient({projectId:projectId, token:token, APIURL: API_ENDPOINT, APIKEY: "___"});
    tdclient.getTeam((err, teammates) => {
      console.log("teammates:", teammates);
      payload.operators = [{id_user: teammates[0].id}];
      res.json(payload);
    });
  }
});

You can also use the newly added user-tags to implment some sort of “skill-based” routing.

Hope this helps

Andrea

1 Like

Thank you I used this as reference for the Dialogflow Fullfilment and Tiledesk Cloud

2 Likes