How to Consume Short-Codes Agent SDK Side

This article builds on the Generating Short-Codes for Consumers guide. We recommend reviewing that first to properly set up your consumer app.

 

Additionally, this article assumes you’re building a custom Agent Console using the AssistAgentSDK. If you haven’t already, we also suggest working through the Custom Agent Console training material (please reach out to your account contact to access this).

 

With that foundation in place, the next step is enabling your agents to use the Short Code provided by the consumer to join a support session with cobrowsing capability.

 

To do this, you’ll need to implement a simple input form in your agent console where the agent can enter the short code. Once the short code is submitted, a client-side AJAX call should be made to convert the short code into a Correlation ID, which will connect the agent to the correct support session. Here’s the code you’ll need for that:

<!-- HTML -->
<form id="shortCodeForm">
  <input type="text" id="shortCode" placeholder="Enter short code" required />
  <button type="submit">Start Support</button>
</form>
// JavaScript
const gwUrl = "https://YOUR_GATEWAY_URL:PORT"; // Replace with your actual gateway URL
const sessionID = "YOUR_AGENT_SESSION_TOKEN";  // Replace with your actual agent session token

$("#shortCodeForm").on("submit", function(e) {
  e.preventDefault();
  const shortCode = $("#shortCode").val();

  $.get(`${gwUrl}/assistserver/shortcode/agent?appkey=${shortCode}`).done(function(response) {
    const cid = jQuery.parseJSON(response).cid;

    AssistAgentSDK.startSupport({
      sessionToken: sessionID,
      correlationId: cid,
      url: gwUrl
    });

    AssistAgentSDK.requestScreenShare();
  });
});

 

Finally, don’t forget—when calling AssistAgentSDK.startSupport({configJson}), you must include the agent’s sessionToken and the GW URL as parameters.