Skip to main content

AI Assistants and Load Balancers

AI assistant connections and load balancers.

AiAssistant​

A connection to an external AI voice assistant.

Table: ai_assistants
Model: App\Models\AiAssistant
Tenant scoped: yes (OrganizationScope)
Traits: SoftDeletes

ColumnTypeNullableDefaultDescription
idbigint unsignedNoautoPrimary key
organization_idbigint unsignedNo-Tenant. Foreign key to organizations, on delete cascade
namevarchar(255)No-Assistant name
descriptiontextYesnullDescription
statusenumNoactiveActive or inactive. Values: active, inactive (cast to AiAssistantStatus)
providervarchar(100)No-Provider key from config/ai-providers.php
protocolenumNo-Connection protocol. Values: sip, websocket, dummy
configurationjsonNo-Provider settings (for example SIP URI or WebSocket fields)
created_bybigint unsignedYesnullUser who created it. Foreign key to users, on delete set null
updated_bybigint unsignedYesnullUser who last changed it. Foreign key to users, on delete set null
created_attimestampYesnull
updated_attimestampYesnull
deleted_attimestampYesnullSoft-delete timestamp

Indexes

  • ai_assistants_created_by_foreign: created_by
  • ai_assistants_deleted_at_index: deleted_at
  • ai_assistants_organization_id_protocol_index: organization_id, protocol
  • ai_assistants_organization_id_provider_index: organization_id, provider
  • ai_assistants_organization_id_status_index: organization_id, status
  • ai_assistants_updated_by_foreign: updated_by

Casts: configuration (array)

Relationships

$aiAssistant->organization() → Organization (organization_id) [BelongsTo]
$aiAssistant->creator() → User (created_by) [BelongsTo]
$aiAssistant->updater() → User (updated_by) [BelongsTo]
$aiAssistant->extensions() → Extension (ai_assistant_id) [HasMany]

Scopes: forOrganization(), active(), inactive(), byProtocol(), byProvider(), search(), withStatus()
Methods: isActive(), getProviderDefinition(), isWebSocket(), isSip(), isDummy(), getUsageCountAttribute(), isInUse()

usage_count counts the extensions whose ai_assistant_id is this assistant; isInUse() is true when it is above 0. getProviderDefinition() looks the provider up in the provider registry. Scopes: active(), inactive(), byProtocol(), byProvider(), search(), withStatus().

AiAssistantLoadBalancer​

Distributes calls across several AI assistants.

Table: ai_assistant_load_balancers
Model: App\Models\AiAssistantLoadBalancer
Tenant scoped: yes (OrganizationScope)
Traits: HasUnprovisionedState, SoftDeletes

ColumnTypeNullableDefaultDescription
idbigint unsignedNoautoPrimary key
organization_idbigint unsignedNo-Tenant. Foreign key to organizations, on delete cascade
namevarchar(255)No-Load balancer name
descriptiontextYesnullDescription
strategyenumNoround_robinDistribution strategy. Values: round_robin, priority, percentage (cast to AlbsStrategy)
follow_throughbooleanNofalseWhen the call to an assistant fails (busy, no answer), redirect it to the next available assistant
statusenumNoactiveActive or inactive. Values: active, inactive (cast to AlbsStatus)
fallback_actionenumNohangupWhere the call goes when no member can take it. Values: extension, ring_group, ivr_menu, ai_assistant, hangup, unavailable, ai_load_balancer, call_queue (cast to RingGroupFallbackAction)
fallback_extension_idbigint unsignedYesnullFallback extension. Foreign key to extensions, on delete set null
fallback_ring_group_idbigint unsignedYesnullFallback ring group. Foreign key to ring_groups, on delete set null
fallback_ivr_menu_idbigint unsignedYesnullFallback IVR menu. Foreign key to ivr_menus, on delete set null
fallback_ai_assistant_idbigint unsignedYesnullFallback AI assistant. Foreign key to ai_assistants, on delete set null
fallback_ai_load_balancer_idbigint unsignedYesnullFallback AI load balancer. Foreign key to ai_assistant_load_balancers, on delete set null
fallback_call_queue_idbigint unsignedYesnullFallback call queue. Foreign key to call_queues, on delete set null
created_bybigint unsignedYesnullUser who created it. Foreign key to users, on delete set null
updated_bybigint unsignedYesnullUser who last changed it. Foreign key to users, on delete set null
created_attimestampYesnull
updated_attimestampYesnull
deleted_attimestampYesnullSoft-delete timestamp

Indexes

  • ai_assistant_load_balancers_created_by_foreign: created_by
  • ai_assistant_load_balancers_fallback_ai_assistant_id_foreign: fallback_ai_assistant_id
  • ai_assistant_load_balancers_fallback_ai_load_balancer_id_foreign: fallback_ai_load_balancer_id
  • ai_assistant_load_balancers_fallback_call_queue_id_foreign: fallback_call_queue_id
  • ai_assistant_load_balancers_fallback_extension_id_foreign: fallback_extension_id
  • ai_assistant_load_balancers_fallback_ivr_menu_id_foreign: fallback_ivr_menu_id
  • ai_assistant_load_balancers_fallback_ring_group_id_foreign: fallback_ring_group_id
  • ai_assistant_load_balancers_organization_id_name_unique (unique): organization_id, name
  • ai_assistant_load_balancers_organization_id_status_index: organization_id, status
  • ai_assistant_load_balancers_organization_id_strategy_index: organization_id, strategy
  • ai_assistant_load_balancers_updated_by_foreign: updated_by

Relationships

$aiAssistantLoadBalancer->organization() → Organization (organization_id) [BelongsTo]
$aiAssistantLoadBalancer->members() → AiAssistantLoadBalancerMember (load_balancer_id) [HasMany]
$aiAssistantLoadBalancer->fallbackExtension() → Extension (fallback_extension_id) [BelongsTo]
$aiAssistantLoadBalancer->fallbackRingGroup() → RingGroup (fallback_ring_group_id) [BelongsTo]
$aiAssistantLoadBalancer->fallbackIvrMenu() → IvrMenu (fallback_ivr_menu_id) [BelongsTo]
$aiAssistantLoadBalancer->fallbackAiAssistant() → AiAssistant (fallback_ai_assistant_id) [BelongsTo]
$aiAssistantLoadBalancer->fallbackCallQueue() → CallQueue (fallback_call_queue_id) [BelongsTo]
$aiAssistantLoadBalancer->fallbackAiLoadBalancer() → AiAssistantLoadBalancer (fallback_ai_load_balancer_id) [BelongsTo]
$aiAssistantLoadBalancer->creator() → User (created_by) [BelongsTo]
$aiAssistantLoadBalancer->updater() → User (updated_by) [BelongsTo]

Scopes: forOrganization(), withStrategy(), withStatus(), search(), active(), unprovisioned()
Methods: isActive(), isInactive(), getActiveMembers(), getActiveMemberCount()

getActiveMembers() returns active members whose assistant is active, ordered by position. unprovisioned() is true when fallback_action is unavailable.

AiAssistantLoadBalancerMember​

An AI assistant in a load balancer.

Table: ai_assistant_load_balancer_members
Model: App\Models\AiAssistantLoadBalancerMember
Tenant scoped: no

ColumnTypeNullableDefaultDescription
idbigint unsignedNoautoPrimary key
load_balancer_idbigint unsignedNo-Load balancer. Foreign key to ai_assistant_load_balancers, on delete cascade
ai_assistant_idbigint unsignedNo-Assistant. Foreign key to ai_assistants, on delete cascade
priorityintNo0Priority for the priority strategy (lowest number first)
weightintNo100Weight for the percentage strategy
positionintNo0Order in the list
statusenumNoactiveActive or inactive. Values: active, inactive
created_attimestampYesnull
updated_attimestampYesnull

Indexes

  • ai_assistant_load_balancer_members_ai_assistant_id_foreign: ai_assistant_id
  • albs_members_lb_position_idx: load_balancer_id, position
  • albs_members_lb_priority_idx: load_balancer_id, priority
  • albs_members_lb_status_idx: load_balancer_id, status
  • albs_members_unique (unique): load_balancer_id, ai_assistant_id

Relationships

$aiAssistantLoadBalancerMember->loadBalancer() → AiAssistantLoadBalancer (load_balancer_id) [BelongsTo]
$aiAssistantLoadBalancerMember->aiAssistant() → AiAssistant (ai_assistant_id) [BelongsTo]