Smart forwarding

If assigning extension numbers to managers was implemented, then you can also perform the smart forwarding. When a call comes from a client saved in the Kommo account and has a responsible user, Kommo provides retrieving the responsible user ID along with the information about the caller ID as mentioned before in the search by phone method.

Once you get the responsible user id, following the smart forwarding API article, you can show a notification about the incoming call in the responsible user interface using the call event method from the call notification API, and get which extension they occupy, and then request forwarding the call from the VoIP service.

For example, as we previously implemented the database diagram, and assigned the manager an extension, we can get the extension the responsible user occupies by performing the following code

public static function smartForward(int $KommoAccountID, int $responsibleUserID)
{
  return VoIPUsers::query()
            ->where('KommoAccountId', '=', $KommoAccountId)
            ->where('KommoUserId', '=', $KommoUserId)
            ->first();
}

And then you can request the VoIP forwarding service.
Next making calls inside Kommo use case.