<div dir="ltr"><div dir="ltr">Tanner's playing 4D chess over here. Dayum!<div><br></div><div>PS I filed an Idea request for POST body content being available to us, and it was marked as a future consideration. If you were so inclined, you could vote on it, to help make it a reality, but if not, that's cool too.</div><div><br></div><div><a href="https://ciscocollaboration.ideas.aha.io/ideas/COLLAB-I-8308">https://ciscocollaboration.ideas.aha.io/ideas/COLLAB-I-8308</a><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 10, 2020 at 5:19 PM Tanner Ezell <<a href="mailto:tanner.ezell@gmail.com">tanner.ezell@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Anthony brought a support forums post (<a href="https://community.cisco.com/t5/contact-center/ccx-http-trigger-post-support/m-p/4020305" target="_blank">https://community.cisco.com/t5/contact-center/ccx-http-trigger-post-support/m-p/4020305</a>) to my attention with the request of how to use UCCX, essentially as middleware HTTP server, needing to parse contents passed as part of a HTTP POST request. </div><div><br></div><div>HTTP capabilities within UCCX are actually quite powerful, however there are no interfaces for directly interacting with the data. Now, it is my opinion that the <b>Get Http Contact Info </b>step should contact this functionality, and it would be trivial to this capability to it. Maybe Cisco will one day..</div><div><br></div><div>Until then, we're going to bend the spoon and spit out some content.</div><div><br></div><div>It is impractical to access the servlet object from the CCX editor on your machine because it is missing numerous required classes that are actually available to executing scripts. Because of this, you'll never be able to access the required methods directly. As a result, we'll use Java reflection to access the internal data objects for our manipulation.</div><div><br></div><div>Without further ado, here's the code:</div><div><br></div><div><div>{</div><div><span style="white-space:pre-wrap"> </span>// Author: Tanner Ezell (<a href="mailto:tanner.ezell@ctilogic.com" target="_blank">tanner.ezell@ctilogic.com</a>)</div><div><span style="white-space:pre-wrap"> </span>// USE AT YOUR OWN RISK</div><div><span style="white-space:pre-wrap"> </span>// Will probably break if Cisco makes underlying changes. </div><div><br></div><div><span style="white-space:pre-wrap"> </span>Class servletClass = Class.forName("javax.servlet.ServletRequest");</div><div><span style="white-space:pre-wrap"> </span>java.lang.reflect.Method getRequestMethod = contact.getClass().getDeclaredMethod("getRequest", null);</div><div><span style="white-space:pre-wrap"> </span>java.lang.reflect.Method getReaderMethod = servletClass.getDeclaredMethod("getReader", null);</div><div><span style="white-space:pre-wrap"> </span>getRequestMethod.setAccessible(true);</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>Object request = (getRequestMethod.invoke(contact, null));</div><div><span style="white-space:pre-wrap"> </span>java.io.BufferedReader reader = (java.io.BufferedReader) getReaderMethod.invoke(request, null);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>StringBuilder builder = new StringBuilder();</div><div><span style="white-space:pre-wrap"> </span>String line;</div><div><span style="white-space:pre-wrap"> </span>while( (line = reader.readLine()) != null) {</div><div><span style="white-space:pre-wrap"> </span>builder.append(line);</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>return builder.toString();</div><div>}</div></div><div><br></div><div>You need a contact variable (type: Contact, name: contact) that must not be null.</div><div><br></div><div>You'll need to set this expression in the Set step. After you have the response, you'll need to parse it appropriately, whatever that may look like towards your specific application.</div><div><br></div><div>Here's a simple application:</div><div><br></div><div><div><img src="cid:ii_kdp2nrol1" alt="image.png" width="542" height="327"><br></div></div><div><br></div><div>And demonstration of it working:</div><div><br></div><div><div><img src="cid:ii_kdp2mtvs0" alt="image.png" width="542" height="364"><br></div></div><div><br></div><div>That's it. Don't forget, this only works on Http Contacts, it's absolutely possible this stops working if Cisco makes underlying changes to how they process servlet requests.</div><div><br></div><div>Happy hacking.</div><div><br></div><div>Regards,</div><div>Tanner Ezell</div></div></div></div>
_______________________________________________<br>
cisco-voip mailing list<br>
<a href="mailto:cisco-voip@puck.nether.net" target="_blank">cisco-voip@puck.nether.net</a><br>
<a href="https://puck.nether.net/mailman/listinfo/cisco-voip" rel="noreferrer" target="_blank">https://puck.nether.net/mailman/listinfo/cisco-voip</a><br>
</blockquote></div>