Search code examples
asteriskvoipasterisk-ari

Asterisk ARI Caller id is always Anonymous


I'm trying to make a outgoing call using asterisk and stasis.

From my app, i send a simple post to /ari/channels/create, like this:

params = {
  endpoint: `PJSIP/${trunkPrefix}${numberOriginal}@${trunkName}`,
  app: 'stasisApp',
  channelId: uuidv4(),
  appArgs: `digital,"${JSON.stringify(appArgs).replace(/\"/g, '\\"')}"`,
  formats: 'ulaw',
};
url = `http://${asteriskHost}/ari/channels/create`;

const variables = {
  'CALLERID(num)': callerId,
};
  
(async () => {
    await axios.post(url, {
    variables,
  }, {
      auth: {
        username: '',
        password: '',
      },
      params,
    }).then(({ data }) => {
    console.log(data);
  }).catch(({response: {data}}) => {
    console.log('Error', data);
  });
})();

Then, i do dial() on the channel, but asterisk sets the From parameter like this:

 From:  "Anonymous" <sip:[email protected]> 

I need to be able to set the callerid on outbound calls, i tried using CONNECTEDLINE(number), but isnt working either, also tried to set the callerid using /channels/{channelId}/variable endpoint, but when the call goes out, the From header is still anonymous. Any ideas?

I'm using asterisk 19.


Solution

  • I managed to solve my problem, after creating the channel I was doing another things before using dial() method, nothing fancy, just creating a bridge, start a recording on the bridge and putting another channel on the bridge, but apparently something during those operations made the callerid on the original channel go away, I just did an request to setChannelVar endpoint with CONNECTEDLINE(num) just before the dial() and it worked.

    Thanks for the help