Assign phone extensions to managers

For more convenient business, you can provide matching between the extensions provided by the VoIP service and the managers of the Kommo account, in order to provide more information about the calls. This information will be used when storing the call like which manager is responsible for this call, and in smart forwarding if it’s implemented.

Here’s an example on how to implement this. The table voip_users contains the extensions provided by the VoIP service. Some of them are already assigned and some are not. We need to assign an unassigned extension to a new user. Review the suggested database diagram.

public static function assignExtension(
    int $kommoAccountId, 
    int $kommoUserId,
    int $extensionId
): void {
    $managerExtension = VoipUsers::query()
        ->where('kommo_account_id', '=', $kommoAccountId)
        ->where('extension_id', '=', $extensionId)
        ->first();

    if ($managerExtension === null) {
        $managerExtension = VoipUsers::create()
            ->setKommoAccountId($kommoAccountId)
            ->setExtensionId($extensionId);
    }
    $managerExtension
        ->setKommoUserId($kommoUserId)
        ->save();
}

What’s Next

Next smart forwarding use case.