Orchardcore telephony asterisk

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore telephony asterisk is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for integrating Asterisk with the CrestApps Orchard Core Telephony soft phone through the Asterisk REST Interface (ARI). Covers the CrestApps.OrchardCore.Asterisk feature, the tenant Asterisk provider and the host-configured Default Asterisk provider, the Default and Coordination configuration

How to use this skill

Skill file

Orchard Core Telephony Asterisk - Prompt Templates

Connect Asterisk to the Soft Phone

You are an Orchard Core expert. Generate accurate configuration, recipes, and troubleshooting guidance for the CrestApps Asterisk provider. It controls calls server-side through ARI over HTTP basic authentication, so ARI credentials never reach the browser. The provider-neutral soft phone, hub, and provider contracts are covered by orchardcore-telephony.

Guidelines

Enable the Feature

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.Telephony",
        "CrestApps.OrchardCore.Telephony.SoftPhone",
        "CrestApps.OrchardCore.Asterisk"
      ],
      "disable": []
    }
  ]
}

Two Providers

| Provider | Technical name | Configured by | Available when |

|---|---|---|---|

| Asterisk | Asterisk | Settings → Communication → Telephony → Asterisk (AsteriskSettings) | Enabled and BaseUrl, UserName, password and ApplicationName are set |

| Default Asterisk | Default Asterisk | Shell configuration section CrestApps:Asterisk:Default (DefaultAsteriskOptions) | BaseUrl, UserName, Password, and ApplicationName all have values, on every tenant that enables the module |

Both contribute to TelephonyProviderOptions through AsteriskProviderOptionsConfigurations. Saving the settings or importing them calls IOptionsUpdateNotifier.RequestUpdate<TelephonyProviderOptions>(), so the provider map refreshes without a tenant restart. Enabling Asterisk with no default provider makes it the default; disabling it while it is the default clears the default.

Capabilities

The provider advertises Dial, Hangup, SendDigits, ReceiveCalls, Hold, Resume, Mute, Merge, and Directory (ARI endpoints). It adds Transfer when the endpoint template resolves to a Local/...@context dialplan route, and Voicemail when a voicemail context and extension template are configured. It does not advertise AttendedTransfer, ExtensionDial, or ExtensionConference yet.

Audio: the provider reports TelephonyAudioCapabilities.Browser with the sipjs browser adapter when complete WebRTC settings are present, and None otherwise (ARI controls the call and audio stays on the PBX endpoint).

Tenant Settings

| Setting | Property | Notes |

|---|---|---|

| Enable Asterisk provider | IsEnabled | Makes the provider selectable |

| ARI base URL | BaseUrl | For example http://localhost:8088/ari/; /ari is appended when missing |

| ARI user name and password | UserName, Password | Password stored encrypted |

| Stasis application name | ApplicationName | Required, must match the dialplan Stasis() application |

| Endpoint template | EndpointTemplate | {number} placeholder, for example PJSIP/{number}@phones or Local/{number}@default |

| Outbound caller id | OutboundCallerId | Optional |

| Dial timeout | TimeoutSeconds | Default 30 |

| Voicemail context, extension template, priority | VoicemailContext, VoicemailExtensionTemplate, VoicemailPriority | Template tokens such as {voicemailRecipientUserName}, {voicemailRecipientUserId}, {calledAddress}, {queueName} |

| SIP WebSocket URL, SIP domain | WebSocketUrl, SipDomain | Required for browser audio; wss:// only |

| ICE server URLs, TURN shared secret, ICE transport policy | TurnUrls, TurnSharedSecret, IceTransportPolicy | Policy all (default) or relay; secret stored encrypted |

| Browser audio codecs | WebRtcCodecs | Default opus,g722,ulaw |

| PJSIP credential lifetime, contact expiration | PjsipCredentialLifetimeMinutes, PjsipContactExpirationSeconds | Defaults 15 minutes and 120 seconds |

| PJSIP Realtime provider, connection string, table prefix | PjsipRealtimeProviderInvariantName, PjsipRealtimeConnectionString, PjsipRealtimeTablePrefix | Required for browser audio; the prefix must be a strict SQL identifier with an optional schema. part |

Recipe

Settings export through the Asterisk Settings deployment step and import through the AsteriskSettings recipe step. Password, TurnSharedSecret, and PjsipRealtimeConnectionString are never exported; a hand-written recipe may supply them in clear text and they are encrypted on import. Members the step omits keep their stored values.

{
  "steps": [
    {
      "name": "AsteriskSettings",
      "Settings": {
        "IsEnabled": true,
        "BaseUrl": "https://pbx.example.com/ari/",
        "UserName": "orchard",
        "Password": "supply-in-clear-text-or-omit",
        "ApplicationName": "orchard-tenant-a",
        "EndpointTemplate": "PJSIP/{number}@phones",
        "TimeoutSeconds": 30,
        "WebSocketUrl": "wss://pbx.example.com:8089/ws",
        "SipDomain": "pbx.example.com",
        "IceTransportPolicy": "all",
        "WebRtcCodecs": "opus,g722,ulaw"
      }
    }
  ]
}

The import and the settings screen both refuse to disable the provider or change its ARI URL or Stasis application while calls are still bound to it.

Default Asterisk from Configuration

{
  "OrchardCore": {
    "CrestApps": {
      "Asterisk": {
        "Default": {
          "BaseUrl": "http://pbx.example.com:8088/ari/",
          "UserName": "<ari-user>",
          "Password": "<ari-password>",
          "ApplicationName": "crestapps-telephony",
          "EndpointTemplate": "Local/{number}@default",
          "TimeoutSeconds": 30,
          "VoicemailContext": "crestapps-voicemail",
          "VoicemailExtensionTemplate": "{voicemailRecipientUserName}",
          "VoicemailPriority": 1
        }
      }
    }
  }
}
OrchardCore__CrestApps__Asterisk__Default__BaseUrl=http://pbx.example.com:8088/ari/
OrchardCore__CrestApps__Asterisk__Default__Password=<ari-password>

Coordination Options

Section CrestApps:Asterisk:Coordination binds AsteriskCoordinationOptions:

| Key | Default |

|---|---|

| CredentialLockTimeout | 00:00:05 |

| CredentialLockExpiration | 00:00:30 |

| ChannelBindingCreateLockTimeout | 00:00:10 |

| PendingReclamationThreshold | 00:05:00 |

| HttpTotalRequestTimeout | 00:00:30 |

| HttpAttemptTimeout | 00:00:10 |

| RealtimeEventBufferCapacity | 1000 (at most 100000) |

| RealtimeEventBackpressureTimeout | 00:00:05 |

| MaxRealtimeMessageBytes | 1048576 |

The ARI HTTP client retries only safe methods, so a lost response to an originate can never place a second call.

Browser WebRTC Audio

stun:turn.example.com:3478
turn:turn.example.com:3478?transport=udp
turns:turn.example.com:5349?transport=tcp

Call Control and Real-Time State

Voicemail Routing

Send to voicemail copies the provider-neutral call metadata (voicemailRecipientUserId, voicemailRecipientUserName, voicemailRecipientDisplayName, calledAddress, callerAddress, queueId, queueName) into channel variables prefixed CRESTAPPS_METADATA_ (for example CRESTAPPS_METADATA_VOICEMAILRECIPIENTUSERNAME) and continues the channel into the configured voicemail context, extension, and priority. Map those to mailboxes in the dialplan with a fallback.

Contact Center Adapters

These adapters are integration glue described here from the provider side; queues, routing, recording governance, supervision, and the media session API are in orchardcore-contact-center.

Development Hosts

Monitoring

AsteriskDiagnostics publishes the CrestApps.OrchardCore.Asterisk meter (no activity source; matched by CrestApps.OrchardCore.*, see orchardcore-opentelemetry). Every instrument is tagged provider, a technology name, so on a node hosting several Asterisk tenants the counts aggregate per process.

| Instrument | Kind | Measures |

|---|---|---|

| crestapps.asterisk.realtime.connected | UpDownCounter | Listeners currently connected. Zero means call events are not arriving: alert on it |

| crestapps.asterisk.realtime.connections | Counter | ARI event-stream connections made, first and every reconnection |

| crestapps.asterisk.realtime.reconnect_attempts | Counter | Attempts to re-establish the stream; a steady rate means churn and possibly missed events between sweeps |

| crestapps.asterisk.realtime.ingestion.saturated | Counter | Episodes where the ingestion buffer filled (CrestApps:Asterisk:Coordination:RealtimeEventBufferCapacity, default 1000) |

| crestapps.asterisk.realtime.events | Counter | ARI events by event_type and result (applied, ignored, failed) |

| crestapps.asterisk.realtime.event.lag | Histogram (s) | An event's timestamp to its dispatch |

| crestapps.asterisk.realtime.last_event_age, .ingestion.queue_depth | ObservableGauge | Staleness and buffered events of the connected listeners |

The Telephony meter adds crestapps.telephony.reconcile.corrections (calls the inbound channel sweep ended), crestapps.telephony.softphone.credentials (PJSIP credentials) and crestapps.telephony.recording.ingest.* (see orchardcore-telephony).

Upgrading from 2.x

Troubleshooting

| Symptom | Check |

|---|---|

| Provider missing from the default provider list | IsEnabled, base URL, user name, password, and application name are all required; for Default Asterisk all four configuration keys must be present |

| No inbound calls or events | The dialplan must hand calls to the exact Stasis application (per tenant for Default Asterisk) and Orchard must reach ARI over ws or wss |

| Calls stuck connected after a PBX hangup | Confirm the ARI listener connected (crestapps.asterisk.realtime.connected above zero, application logs) and only one node runs the provider |

| One-way or no browser audio | Configure TURN with a shared secret, or try relay to validate TURN |

| Transfer or voicemail button missing | Use a Local/...@context endpoint template, and set the voicemail context and extension template |

| Settings save refused | Calls are still bound to the old ARI identity; end or reconcile them first |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.