<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 2/24/21 1:01 AM, Jaco Kroon wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:f82aed56-60b7-0f28-b0d0-25032bc10295@uls.co.za">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi,</p>
      <p>I still think the changes for forcecommit should be done for
        func_odbc, however, after various discussions we've decided to
        give the daemon route a shot.<br>
      </p>
      <p>So just looking at the raw AMI event via UserEvent, this seems
        to have a problem with quoting, for example:<br>
        <br>
        Set(ODBC_trace()=CallerID: ${CALLERID(all)})<br>
        UserEvent(trace,Message: CallerID: ${CALLERID(all)})<br>
        <br>
        The former in the DB ends up as:  CallerID: "name"
        <number><br>
      </p>
      <p>The quotes are missing in the AMI event:</p>
      <p>Message: CallerID name <number><br>
      </p>
      <p>Is this a bug, or am I missing some escaping that needs to
        happen prior to passing to UserEvent?</p>
      <p>Kind Regards,<br>
        Jaco<br>
      </p>
    </blockquote>
    <p>Interesting, I couldn't find anyone having similar problems nor
      any working examples. I tried <tt><i>UserEvent(trace,Message:
          CallerID: ${QUOTE(${CALLERID(all)})})</i></tt> but that
      becomes <i><tt>AppData: trace, CallerID: "\"2000\" <2000>"</tt></i>.
      I guess UserEvent() is having a bad day. While trying to encode
      the body as JSON (which also doesn't work) I did find the
      workaround below which I think is pretty close:</p>
    <p><tt>UserEvent(trace,CallerID:{${QUOTE(${CALLERID(all)})}},Val:{${QUOTE("quoted")}})</tt></p>
    <p><tt>Event: UserEvent</tt><tt><br>
      </tt><tt>Privilege: user,all</tt><tt><br>
      </tt><tt>Channel: SIP/2000-00000016</tt><tt><br>
      </tt><tt>ChannelState: 6</tt><tt><br>
      </tt><tt>ChannelStateDesc: Up</tt><tt><br>
      </tt><tt>CallerIDNum: 2000</tt><tt><br>
      </tt><tt>CallerIDName: 2000</tt><tt><br>
      </tt><tt>ConnectedLineNum: <unknown></tt><tt><br>
      </tt><tt>ConnectedLineName: <unknown></tt><tt><br>
      </tt><tt>Language: en</tt><tt><br>
      </tt><tt>AccountCode: </tt><tt><br>
      </tt><tt>Context: sub-speakextennum</tt><tt><br>
      </tt><tt>Exten: s</tt><tt><br>
      </tt><tt>Priority: 3</tt><tt><br>
      </tt><tt>Uniqueid: 1614152491.107</tt><tt><br>
      </tt><tt>Linkedid: 1614152491.107</tt><tt><br>
      </tt><tt>UserEvent: trace</tt><tt><br>
      </tt><tt>CallerID: {"2000" <2000>}</tt><tt><br>
      </tt><tt>Val: {"quoted"}</tt><br>
      <br>
    </p>
    <p>In any case, the UserEvent itself already contains the CID
      (CallerIDNum, CallerIDName) but I assume you were testing quoting
      behavior.<br>
    </p>
    <p>There is also the alternative of listening to VarSet events. It
      is much more spammy but is more straight-forward in dialplan and
      works with arrays:<br>
    </p>
    <p><tt>Set(ARRAY(CallerID,Val)=${QUOTE(${CALLERID(all)})},${QUOTE("quoted")})</tt></p>
    <p><tt>Event: VarSet<br>
        Privilege: dialplan,all<br>
        Channel: SIP/2000-0000001a<br>
        ChannelState: 6<br>
        ChannelStateDesc: Up<br>
        CallerIDNum: 2000<br>
        CallerIDName: 2000<br>
        ConnectedLineNum: <unknown><br>
        ConnectedLineName: <unknown><br>
        Language: en<br>
        AccountCode: <br>
        Context: sub-speakextennum<br>
        Exten: s<br>
        Priority: 3<br>
        Uniqueid: 1614153653.127<br>
        Linkedid: 1614153653.127<br>
        Variable: CallerID<br>
        Value: \"2000\" <2000><br>
        <br>
        Event: VarSet<br>
        Privilege: dialplan,all<br>
        Channel: SIP/2000-0000001a<br>
        ChannelState: 6<br>
        ChannelStateDesc: Up<br>
        CallerIDNum: 2000<br>
        CallerIDName: 2000<br>
        ConnectedLineNum: <unknown><br>
        ConnectedLineName: <unknown><br>
        Language: en<br>
        AccountCode: <br>
        Context: sub-speakextennum<br>
        Exten: s<br>
        Priority: 3<br>
        Uniqueid: 1614153653.127<br>
        Linkedid: 1614153653.127<br>
        Variable: Val<br>
        Value: \"quoted\"<br>
      </tt><tt></tt><br>
    </p>
    <p>Another alternative would be to format the event per your own
      preferences:</p>
    <p><tt>UserEvent(CallerID=${QUOTE(${CALLERID(all)})}|Val=${QUOTE("quoted")})</tt></p>
    <p><tt>Event: UserEvent</tt><tt><br>
      </tt><tt>Privilege: user,all</tt><tt><br>
      </tt><tt>Channel: SIP/2000-00000019</tt><tt><br>
      </tt><tt>ChannelState: 6</tt><tt><br>
      </tt><tt>ChannelStateDesc: Up</tt><tt><br>
      </tt><tt>CallerIDNum: 2000</tt><tt><br>
      </tt><tt>CallerIDName: 2000</tt><tt><br>
      </tt><tt>ConnectedLineNum: <unknown></tt><tt><br>
      </tt><tt>ConnectedLineName: <unknown></tt><tt><br>
      </tt><tt>Language: en</tt><tt><br>
      </tt><tt>AccountCode: </tt><tt><br>
      </tt><tt>Context: sub-speakextennum</tt><tt><br>
      </tt><tt>Exten: s</tt><tt><br>
      </tt><tt>Priority: 3</tt><tt><br>
      </tt><tt>Uniqueid: 1614153302.122</tt><tt><br>
      </tt><tt>Linkedid: 1614153302.122</tt><tt><br>
      </tt><tt>UserEvent: CallerID="2000" <2000>|Val="quoted"</tt><br>
    </p>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Dennis Buteyn
Xorcom Ltd</pre>
  </body>
</html>