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
- Install
CrestApps.OrchardCore.Asteriskin the web/startup project and enableCrestApps.OrchardCore.Asterisk. It depends onCrestApps.OrchardCore.Telephony, which enables the settings screen. - There is only one selectable feature. The Contact Center voice adapter activates automatically when
CrestApps.OrchardCore.ContactCenter.Voiceis also enabled, and the media adapter whenCrestApps.OrchardCore.ContactCenter.Voice.Mediais enabled. Install the Contact Center package in the startup project for those. - Always set a Stasis application name; a blank value fails closed. Give each tenant sharing one Asterisk server a unique application name.
- Keep ARI and PJSIP Realtime credentials in tenant settings (encrypted) or a secret store, never in committed
appsettings.json. - Run real-time Asterisk voice on a single active application node; the ARI application claim is node-local.
- All recipe JSON must be wrapped in
{ "steps": [...] }.
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>
- The browser WebRTC keys are available here too.
- Each tenant resolves the shared connection under
<ApplicationName>-<ShellName>(for examplecrestapps-telephony-Default,crestapps-telephony-blog1) so Stasis event streams stay isolated. Inbound dialplans must route each tenant's calls toStasis(<ApplicationName>-<ShellName>). - In the
Productionenvironment a tenant refuses to start when this section holds a development credential published in the repository.
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
- Agent media flows directly between the browser (SIP.js) and Asterisk
chan_pjsipover WSS, DTLS-SRTP and ICE; Orchard does not relay agent RTP. - Browser audio is advertised only when the
wss://URL, SIP domain, codecs, positive credential lifetime and contact expiration, and PJSIP Realtime provider and connection string are all set. Missing values make browser audio unavailable instead of failing startup. - Orchard issues short-lived PJSIP credentials per authenticated session, records a durable lease in the tenant's YesSql store first, then writes the Realtime
ps_endpoints,ps_auths, andps_aorsrows. Each user is capped at a few live credentials (the oldest is revoked first), and signing out revokes all of them. - Asterisk advertises only the ICE servers you configure. Without a TURN server, agents behind strict NAT may get one-way or no audio. With a TURN shared secret, each registration gets an ephemeral coturn
use-auth-secretcredential (username{unixExpiry}:{tenant}:{session}, credentialBase64(HMAC-SHA1(secret, username))); set the same value as coturnstatic-auth-secret.
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
- ARI operations used:
POST /channels(originate),DELETE /channels/{id},POST /channels/{id}/answer,hold,mute?direction=both,continue(Local-route blind transfer and voicemail),variable,dtmf,POST /bridgeswithaddChannel(merge), andGET /endpoints(directory). - A tenant-scoped ARI WebSocket listener per configured provider normalizes channel events into
ProviderVoiceEvent, updates call history, and pushes state to the soft phone. It reconnects with jittered backoff and reconciles after each connect. Events from the Default Asterisk connection are tagged with the canonicalAsteriskprovider identity. - Reconciliation reads the
CRESTAPPS_STATE_ONHOLDandCRESTAPPS_STATE_MUTEDchannel variables. An ARI404is authoritative: the orphaned record is removed and the soft phone is told the call ended. - An accepted originate starts in Connecting; the soft phone waits for the ARI event before showing Connected.
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.
- Voice adapter (with
CrestApps.OrchardCore.ContactCenter.Voice) registersAsteriskContactCenterVoiceProvider. It advertises theServerSideAcddelivery model, bridge recording, supervisor monitor, whisper and barge, blind transfer to another agent, attended consult phases, and multi-party conference on the canonical conversation bridge. It also registers recording ingest jobs and per-tenant channel bindings, and fails closed on a channel the current tenant does not own. Connecting a parked call to a browser agent currently returnsagent_bridge_unavailablerather than a false success. Transfers to a queue, external number, or entry point return a confirmed failure. - Media adapter (with
CrestApps.OrchardCore.ContactCenter.Voice.Media, an opt-in feature an administrator turns on from the Features page; its transport certification is still pending and it is outside the GA-Core profiles) registersAsteriskContactCenterVoiceMediaProvider. It uses ARI External Media over RTP/UDP with G.711 mu-law, 8 kHz mono, attached to the call bridge. The session request must carryexternalHost(AsteriskConstants.ExternalMediaHostMetadataKey); optionalbindAddressandbindPort. It is not production-certified; isolate the unencrypted RTP path on a private network and pin the session to its node. - There is no Asterisk AI voice processor: automated AI calls (the AI voice agent on an entry point, AI outbound loads) are placed and answered over Telnyx only (
orchardcore-telephony-telnyx,orchardcore-omnichannel-voice).
Development Hosts
src/Startup/CrestApps.Aspire.AppHostprovisions an Asterisk container (with coturn) and injects the Default Asterisk environment variables; theCrestApps.OrchardCore.Cms.Weblaunch profile injects the same values. The demoLocal/{number}@defaultroute answers, plays a tone, and echoes.src/Startup/CrestApps.OrchardCore.Asterisk.Webis a development-only dashboard and inbound simulator. It refuses to start outsideDevelopment; supplyAsteriskWeb:AsteriskUserNameandAsteriskWeb:AsteriskPasswordthrough user secrets.- Quick checks against ARI are
GET /ari/asterisk/info,GET /ari/channels, andGET /ari/bridges.
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
- Remove
CrestApps.OrchardCore.Telephony.Adminfrom recipes; the Asterisk tab is registered by the main AsteriskStartup, andAsteriskAdminStartupis gone. - The Default Asterisk provider is now available on every tenant, not only the default shell. A default-shell deployment that routes inbound calls must change its dialplan to
Stasis(<ApplicationName>-Default). - Code that reads
TelephonyProviderOptionsmust useIOptionsMonitor<TelephonyProviderOptions>. - The old meter instruments
asterisk.realtime.connected,asterisk.realtime.reconnect_attemptedandasterisk.realtime.ingestion.saturatedare no longer emitted. Usecrestapps.asterisk.realtime.connections(connections made),crestapps.asterisk.realtime.reconnect_attemptsandcrestapps.asterisk.realtime.ingestion.saturated;crestapps.asterisk.realtime.connectedis now an up-down count of connected listeners.
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 |