Remote SIP Transfer w/PJSIP


I’m trying to perform a remote SIP transfer using PJSIP According to the documentation, in order to perform the transfer, 3 things are needed from the originating call:

  • Call-ID
  • from-tag
  • to-tag

Using CHANNEL(pjsip,call-id) it is possible to get the call ID; however, I don’t seem to be able to obtain the from and to tags on the outbound channel.

The question is: how does one obtain the from and to tags on the outbound channel after a call has been established?

Background on the project:

  1. Alice calls IVR
  2. Alice selects option that requires an outbound call
  3. The outbound call is placed to Bob
  4. Bob receives a pre-recorded announcement based on IVR selection
  5. Alice is connected to Bob without joining a bridge. <=== This is where the redirect is needed.
1 Like

There is no ability to initiate this from Asterisk itself. The documentation you’ve referenced is for externally initiated.

Thanks! I now understand the article, it is a blueprint for handling the REFER on the asterisk side.

I’d still like to know “How does one obtain the from and to tags on the outbound channel after a call has been established?”

If they aren’t available through the CHANNEL dialplan function then we probably don’t have a mechanism currently in order to do it.

+1 this would be a great addition to the api!

We are going to need to fetch the from and to tags on the outbound channel after the call is established. From what you said this does not exist today. Can you provide a bit of guidance on the best way to implement this? We are going to need to implement this in Asterisk. Any help/guidance is appreciated!

If you have specific questions then someone may be able to answer them on the asterisk-dev mailing list or IRC channel, otherwise stuff is contained and split up in PJSIP so you’d need to define exactly what you want/need to do, find the appropriate location, and go from there.

I finally found the way to get the tags. We were able to leverage the ARI using this rest endpoint /channels/{channelId}/variable by passing in the channel id and the variable CHANNEL(pjsip,local_tag) to get the “From tag” and CHANNEL(pjsip,remote_tag) to get the “To tag”. It appears that these 2 types for PJSIP are not mentioned in the docs. I hope helps someone!

@jcolp I do appreciate your quick and friendly responses on this issue! Keep fighting the good fight!

1 Like