如何让SIP电话发起外呼时显示“outgoing call”而非“incomming call”
I've run into this exact issue before—using AMI's Originate command often makes the SIP phone think it's receiving a call instead of making one, since Asterisk initiates the INVITE to the phone by default. Here are the most reliable ways to get your phone to show "Outgoing Call" instead:
1. Adjust AMI Originate Parameters to Spoof the Call Direction
The key here is to make sure the SIP phone sees its own number in the From header of the INVITE, which tricks it into recognizing the call as outgoing. Use this AMI command structure:
Action: Originate Channel: SIP/phone1 Context: default Exten: 1234 ; Target number you want to call Priority: 1 CallerID: "Your Desk Phone" <1001> ; Replace with your phone's actual number/name Variable: SIPFROMUSER=1001 Variable: SIPFROMDOMAIN=your-asterisk-domain.com
Then update your Asterisk SIP config to allow custom From headers:
- For chan_sip (legacy): Add
sendrpid=yesandtrustrpid=yesto your phone's peer/endpoint config - For pjsip: Add
callerid_privacy=allowedto your endpoint config, and setfrom_user=1001to match your phone's number
2. Trigger the SIP Phone to Initiate the Call (Device-Dependent)
Many SIP phones (like Yealink, Grandstream) support triggering outgoing calls via SIP NOTIFY messages. You can send this directly via AMI to make the phone initiate the call itself (which will naturally show "Outgoing Call"):
Action: SIPnotify Channel: SIP/phone1 Variable: Event: yealink-xml ; Use the event type your phone supports Variable: Content-Type: text/xml Variable: Content: <?xml version="1.0" encoding="UTF-8"?><YealinkIPPhoneExecute><ExecuteItem URI="dial:1234"/></YealinkIPPhoneExecute>
Note: The exact Event and XML content varies by phone model—check your device's documentation for the correct trigger syntax.
3. Hack the SIP Header in Dialplan (Last Resort)
If the above methods don't work, you can force the From header to match the phone's number in your Dialplan, which most phones will interpret as an outgoing call. Add this to your extensions.conf:
[default] exten => _X.,1,Set(PJSIP_HEADER(add,From)="sip:1001@your-domain.com") ; Replace with your phone's number/domain exten => _X.,n,Dial(SIP/${EXTEN},20) exten => _X.,n,Hangup()
Then use your original AMI Originate command—this overrides the From header so the phone thinks it's initiating the call.
I'd start with method 1, since it's the most consistent across devices. If that doesn't work, check your phone's documentation for the NOTIFY trigger syntax (method 2) as it's the cleanest solution when supported.
内容的提问来源于stack exchange,提问作者Manticore

