I then dial the channel using the /ari/channels/X/dial method, but when the phone rings the caller ID is “anonymous”.
I’m wondering if the example is misleading and is just showing HOW to pass a body parameter (but CALLERID doesn’t really apply to this method)? In that case, would I instead have to pass the same body parameter to the dial method? ( I tried and it didn’t work)
If not, how do I set the caller ID? I thought of using the CONNECTEDLINE body parameters (as show below) on the create or dial methods, but that is supposed to be for setting the Caller ID during the call. (I tried this and it didn’t work)
The document referenced doesn’t say that it sets the caller ID. You would need to look at the documentation for the CALLERID function, to see what it actually does (which is subtly different).
* variables: containers - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }
So that’s where I got the idea of setting callerid in the variables. How are you suggesting I call the CALLERID function from the ARI so the desired name/num appear on ring?
Other users appear to have the same problems (reddit, stack overflow, and Asterisk forum). One user suggests calling setvar (see [voip - Asterisk ARI Caller id is always Anonymous - Stack Overflow] ), but this seems unnecessary as passing the CONNECTEDLINE(name) in the body of /channels/create should (according to the doc) do the same.
I’m simply saying that setting …(name) sets the name, not the ID. It may well be that CONNECTEDLINE is the right function, or even that there is no ARI mechanism to do this on the initial INVITE.
Ok if someone know how to make the /channels/create function set the caller ID (per the documentation), or how to set it on the /dial function, please jump in.
You may want to show your complete requests, or ideally provide a sample application, as well as show the PJSIP endpoint configuration. If noone immediately knows then if they want to take a look, they have to essentially recreate what you are doing. The easier you make it, the more likely someone will chime in.
I managed to get it to work by setting the channel variable CONNECTEDLINE(name)=“Caller Name” between the /create and the /dial.
My steps were:
/ari/channels/bridges (to create my bridge)
/ari/channels/create (to create my channel C)
/ari/bridges/B/addchannel (to add the channel C to my bridge B)
/ari/channels/C/variable (to set the caller ID using CONNECTEDLINE)
/ari/channels/C/dial (to dial the endpoint)
and then it successfully set the caller ID. Trying to set the caller ID in the /create and /dial functions using body parameters (variables) did not work (using CALLERID() or CONNECTEDLINE() variables). So if this is by design, the documentation needs to be updated. Otherwise I think it’s a bug.
I would post my code but it’s a big C mess and I’m just writing functions to experiment, so it would be too ugly to post. But I’m happy enough with this solution for now.
The documentation doesn’t say what the example does, but, in any case there are two caller IDs, one is the caller ID sent outbound and the other is that associated with the channel, which is notionally the incoming caller ID, although, as the call is physically outbound, there isn’t necessarily an actual inbound transfer of the caller ID. Basically what you are trying to set is the identity of the near end, whereas the example is manipulating the identity of the far end, and, in fact, its name, not its identity.
I was able to set the caller ID so it shows the calling parting during ring (using CONNECTEDLINE as per above).
However, during ringing the phone ALSO shows “alerting Asterisk”, and once answered says “connected Asterisk”. So there must be another variable I need to set. I’m lost where to look for how to change this too…and looking for far end/near end hasn’t gotten me closer.
Is this a separate variable I need to set? Or something I can put in the header during the /dial or /create calls?
So The CID name is showing correctly showing “MyName” as the calling party. But since I’m originating the call from the pbx itself, I’m guessing that explains the asterisk@192…
Is it possible to replace the “asterisk@” with some other string? (And of course how)
Yes, you set the identity. I’ve been pointing out all along that setting the name (especially on its own) doesn’t seem to match what you say you want to do.
@david551 I appreciate your help on the thread. I suspect I’m not advanced enough to fully understand what you posted, and your answer might have been right on (now your last message makes a lot more sense to me). I think you have to be more explicit (i.e. dumb down) your answer for us beginners. Thx!