How to get SIP headers in the application code?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • avc892578805570
    Member
    • Dec 2024
    • 8

    How to get SIP headers in the application code?

    Hi Guys,

    Can you please tell me how to get all the SIP headers on my own in the IVR application?

    I want to do it in the code.

    I know that part or SIP headers goes to session object but I would like to get them in my own code.

    Thanks in advance,
    Vasily.

    PS: I would be very grateful if you help me to change avc892578805570 to the normal nickname.
  • jtb1
    Whiz
    .
    • Feb 2017
    • 33

    #2
    To your second question - please review the related FAQs - https://support.avaya.com/forums/help I am not sure why my handle is what it is and not the autogenerated one, and I dont quickly find the answer you seek - perhaps you can. It may have to do with the level of SSO account you have.

    Comment

    • avc861193901584
      Whiz
      • Sep 2024
      • 44

      #3
      For the first question, you can add a Capture Expression to your AppRoot/starting node using an appropriate expression.
      For example, to get custom headers you would use session.connection.protocol.sip.unknownhdr .
      If you wanted to get all SIP information, you could use the expression session.connection.protocol.sip and assign it to a project-defined variable in your AOD application.
      You may need to use a JSON tool or library to properly navigate the data.
      Adam | Swampfox Technologies Inc. | Avaya Partner
      Solutioning in: Avaya Experience Portal | AXP Connect | AES

      Comment

      • wilsonyu
        Hot Shot
        .
        • Sep 2011
        • 24

        #4
        In VXML, you would use the <var name="", expression=""/> element. For example, <var name="sessionSip" expr="try {JSON.stringify(session.connection.protocol.sip)} catch (errMsg) {'undefined'}"/>

        Comment

        • avc892578805570
          Member
          • Dec 2024
          • 8

          #5
          Hi All,
          Just a report according to your hints. And for those who will need to get SIP headers in their projects.
          Yes, it is possible and it is simple.
          According to avc861193901584 the function "Capture Expression" in AppRoot does work well.
          For example, below are the screenshots from my project:
          Click image for larger version

Name:	image.png
Views:	146
Size:	99.2 KB
ID:	48850

          Click image for larger version

Name:	image.png
Views:	143
Size:	97.1 KB
ID:	48851
          And in the trace.log you will see the result.

          Click image for larger version

Name:	image.png
Views:	139
Size:	14.8 KB
ID:	48852

          If you want to set some custom sip header then the best way to do it is to use session.connection.protocol.sip.unknownhdr. (In the OD UG you can find the guide how to do it).

          The recommendation from wilsonyu does work well as well.
          In VXML, you would use the <var name="", expression=""/> element. For example, <var name="sessionSip" expr="try {JSON.stringify(session.connection.protocol.sip)} catch (errMsg) {'undefined'}"/>

          Thanks,
          Vasily.

          Comment

          • m218
            Aspiring Member
            • Jul 2025
            • 1

            #6
            Hi All,

            I have a call flow that has 2 modules, Let's say Module A and Module B, my call lands in module A and module A invokes Module B. I want to get SIP header in Module B by using the capture expression node in approot of the Module B. Is it possible? Unfortunately, I don't have Module A source code, and I only have module B source code where I can add the capture expression node in approot to get the sip headers. I tried using the above method but unable to retrieve the values. Can someone guide? Below is my OD code of module B.


            Click image for larger version  Name:	image.png Views:	0 Size:	42.7 KB ID:	49364

            My trace show always undefined when I trace the variable.

            Comment

            • avc892578805570
              Member
              • Dec 2024
              • 8

              #7
              Hi m218,
              It is very interesting question.
              The documentation says ...
              • Capture Expression is used to capture ECMA script values

              When your call lands in moduleA, your moduleA runs Start servlet (which is based on a Root Document block) which initialize session variable from SIP headers.

              When you add capture expression in moduleA then OD adds something like that
              Code:
              248:<var name="SIPHeaders" expr="try {objectToString(session.connection)} catch (errMsg) {'undefined'}"/>
              Start servlet is initialized and you will see SIP headers.

              It seems that when the moduleA invokes moduleB this kind of initialization does not work because it was already done in moduleA.
              (I am not sure how in that case session variable in moduleB is initialized).

              In my code I use Input variables to pass information from A to B.

              Seems that wilsonyu​ could bring some light to that question because It is really interesting question.

              Or if you already done with your case, you can share your experience here.

              Comment

              Loading