Chat with us if you have any questions!

Virtual Agent - Detect Questions That Are Too Short

Simple virtual agent for detecting if questions are too short.

Note: The Virtual Agent can be downloaded here » Virtual Agent SDK (zip) (VirtualAgentSDK\Samples\CS-ScriptVirtualAgents\SimpleVA_ShortQuestionResolver.cs)

Overview

It’s second nature to start an IM session with a greeting. This is often the case when clients enter the queue using Skype for Business and it poses a challenge for management to train users to start their IM with a question. This simple Conversational type of Virtual Agent detects questions that are less than 10 characters (and may be a greeting) and asks the client to enter a longer question. When more information is provided, the virtual agent will update the client’s question in Chime so that when the session is routed to a live agent they will have enough context to start helping immediately.

Code Samples

When the IncomingSeekerOffer method is invoked, the Virtual Agent will only accept session where the question is less than 10 characters long.

public bool IncomingSeekerOffer(int sessionId, string queueName, int queueID, string email, string question, PreviousSessionState? prevState)
{
    if (question.Length <= 10)
    {
        return true;
    }
    return false;
}

    
After the SeekerConnected method returns true the session is connected and the Virtual Agent receives the client’s question from Chime in the ReceiveMessage method.

public bool SeekerConnected(int sessionId)
{
    return true;
}

    
When ReceiveMessage is invoked, the Virtual Agent removes any prefixes that Chime adds to the question such as the client’s name and determines if the question is less than 10 characters. If it is, the Virtual Agent sends a message to the client asking them to enter a longer question. When the Virtual Agent receives a message from the client that is long enough, it updates the question in Chime and disconnects from the session so that it can route to a live agent.

public bool ReceiveMessage(int sessionId, string email, string msg)
{
    _pluginManager.LogMessageInChime(LoggingLevel.Debug, "message received: " + msg);
    msg = msg.Replace("\n", ""); //remove line breaks
    if (msg.Contains(":"))
    {
        int colonIndex = msg.IndexOf(":");
        msg = msg.Remove(0, colonIndex + 1).Trim(); //remove client's name prefix such as "Jane Doe: Hi"
    }
    if (msg.Contains("-"))
    {
        int colonIndex = msg.IndexOf("-");
        msg = msg.Remove(0, colonIndex + 1).Trim(); //remove client's name prefix such as "Jane Doe- Hi"
    }
    if (msg.Length <= 10)
    {
        _pluginManager.SendIMToSeeker(sessionId,
            "Your question must be greater than 10 characters. Please enter another question.");
    }
    else if (!msg.Contains("Your question must be greater than 10 characters. Please enter another question.")) //ignore messages that the virtual agent sent
    {
        _pluginManager.SendIMToSeeker(sessionId, "Thank you.");
        _pluginManager.AppendToQuestion(sessionId, ". " + msg);
        bool continuteToRouting = true;
        _pluginManager.DisconnectVirtualAgent(sessionId, continuteToRouting);
    }
    return true;
}

    

Full Source Code


using System;
using System.Collections.Generic;
using System.Linq;


/* © Instant Technologies 2016
 *
 *  This is a simple Virtual Agent script file that will ask clients to enter a longer question, if their initial text is shorter than 10 characters.
 *  Sometimes clients enter the queue with a greeting or not enough information in their original question, this Virtual Agent will ask them to enter more information.
 *
 *  In the IncomingSeekerOffer method the Virtual Agent only accepts sessions where the question is less than 10 characters.
 *  Once the session is connected (in the SeekerConnected method) the Virtual Agent waits to receive a message (the seeker's question is resent).
 *  In the ReceiveMessage method, the Virtual Agent tells the seeker their question must be greater than 10 characters and instructs them to enter a new question.
 *  Once the Virtual Agent receives a valid question, the Virtual Agent tells Chime to append the new question to the client's old one and disconnects.
 *
 *  To deploy the virtual agent, copy this file to "C:\Program Files\Instant Technologies\Chime For Lync\Plugins" on the Chime server.
 *  Go to the Admin page in Chime and then the Virtual Agents section.
 *  First "Enable Virtual Agent Manager", then "Enable" the virtual agent named "Short Question Resolver"
 *  Finally, assign this virtual agent to a queue in queue settings, under the People tab, then Virtual Agents.
 *  Select the Conversational virtual agent and save your changes.
 *
 */
public class SimpleVA_ShortQuestionResolver : IVirtualAgent
{
    IPluginManager _pluginManager;
    VirtualAgentState va_state;

    VirtualAgentProps vaData = new VirtualAgentProps("Short Question Resolver", "1", VirtualAgentType.Conversational, "Catch questions that are less than 10 characters and ask for more information. Then append the answer to the client's question.", "Instant Technologies");

    public Tuple<bool, VirtualAgentProps> Load()
    {
        va_state = VirtualAgentState.Online;
        return new Tuple<bool, VirtualAgentProps>(true, vaData);
    }

    public bool UnLoad()
    {
        return true;
    }

    public void SetPluginManager(IPluginManager pm)
    {
        _pluginManager = pm;
    }

    public VirtualAgentState GetState()
    {
        return va_state;
    }

    public bool IncomingSeekerOffer(int sessionId, string queueName, int queueID, string email, string question, PreviousSessionState? prevState)
    {
        if (question.Length <= 10)
        {
            return true;
        }
        return false;
    }

    public bool SeekerConnected(int sessionId)
    {
        return true;
    }

    public void SeekerDisconnected(int sessionId)
    {
    }

    public bool ReceiveMessage(int sessionId, string email, string msg)
    {
        _pluginManager.LogMessageInChime(LoggingLevel.Debug, "message received: " + msg);
        msg = msg.Replace("\n", ""); //remove line breaks
        if (msg.Contains(":"))
        {
            int colonIndex = msg.IndexOf(":");
            msg = msg.Remove(0, colonIndex + 1).Trim(); //remove client's name prefix such as "Jane Doe: Hi"
        }
        if (msg.Contains("-"))
        {
            int colonIndex = msg.IndexOf("-");
            msg = msg.Remove(0, colonIndex + 1).Trim(); //remove client's name prefix such as "Jane Doe- Hi"
        }
        if (msg.Length <= 10)
        {
            _pluginManager.SendIMToSeeker(sessionId,
                "Your question must be greater than 10 characters. Please enter another question.");
        }
        else if (!msg.Contains("Your question must be greater than 10 characters. Please enter another question.")) //ignore messages that the virtual agent sent
        {
            _pluginManager.SendIMToSeeker(sessionId, "Thank you.");
            _pluginManager.AppendToQuestion(sessionId, ". " + msg);
            bool continuteToRouting = true;
            _pluginManager.DisconnectVirtualAgent(sessionId, continuteToRouting);
        }
        return true;
    }
}

    

Questions?

Have a question about Chime virtual agents? Ask one of our developers at InstantDev@instant-tech.com.