Virtual Agent - Resolve All Sessions

Simple virtual agent for resolving all Chime sessions.

Request a Demo »

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

Overview

This sample demonstrates a Post-Conversation type of Virtual Agent by simply resolving every session after it ends. This shows the Virtual Agents ability to update details in Chime after the session has ended.

Code Samples

In the IncomingSeekerOffer method the virtual agent accepts all sessions.

public bool IncomingSeekerOffer(int sessionId, string queueName, int queueID, string email, string question, PreviousSessionState? prevState)
{
    return true;
}

    
Then, when the SeekerConnected method is invoked, the session Resolved tag is set to true and the Virtual Agent disconnects with the session.

public bool SeekerConnected(int sessionId)
{
    _pluginManager.SetSessionResolvedTag(sessionId, true);
    bool continueToRouting = true; //this varible is for deflection purposes, and only makes sense for Conversational Virtual Agents that might deflect a seeker away from a live agent and to some other resource instead
    _pluginManager.DisconnectVirtualAgent(sessionId, continueToRouting);
    return true;
}

    

Full Source Code


using System;
using System.Collections.Generic;

/* © Instant Technologies 2016
 *
 *  This is a simple virtual agent script file that will set the "Resolved" tag on every session after it ends.
 *  The "Resolved" tag can be viewed for a session from the Details or History tabs in the Queue Dashboard.
 *
 *  In the IncomingSeekerOffer method the virtual agent accepts all sessions.
 *  Then the session Resolved tag is set to true in the SeekerConnected method.
 *
 *  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 "Resolves All Sessions"
 *  Finally, assign this virtual agent to a queue in queue settings, under the People tab, then Virtual Agents.
 *  Select the Post-Conversation virtual agent and save your changes.
 *
 */
public class SimpleVA_ResolveSession : IVirtualAgent
{
    IPluginManager _pluginManager; //This is how you make calls to Chime.
    VirtualAgentState va_state;

    /// <summary>
    /// Method called by the PluginManager when Chime starts, when an Office 365 queue starts,
    /// when global setting for virtual agents is turned on, and when the Plugin Manager is reloaded.
    /// </summary>
    /// <returns>The boolean represents whether this virtual agent is ready to be routed to. A virtual agent that returns false will be unavailable.
    /// The VirtualAgentProps is the properties that describe this virtual agent and is the data that will be displayed in Chime</returns>
    public Tuple<bool, VirtualAgentProps> Load()
    {
        va_state = VirtualAgentState.Online;
        bool isLoaded = true;
        var vaData = new VirtualAgentProps("Resolves All Sessions", "1", VirtualAgentType.PostConversation, "Sets the \"resolved\" tag on all sessions to true", "Instant Technologies"); //name, version, VirtualAgentType, description, author
        return new Tuple<bool, VirtualAgentProps>(isLoaded, vaData);
    }

    /// <summary>
    /// This method is called when the global setting for virtual agents is turned off. 
    /// This gives a chance for the virtual agent to do any necessary house keeping before it is unloaded by the system.
    /// </summary>
    /// <returns>A bool representing whether this virtual agent was able to "shut down" correctly</returns>
    public bool UnLoad()
    {
        return true;
    }

    /// <summary>
    /// If the virtual agent returns true in the Tuple it returns from the Load method, then the Plugin Manager will call this method and give this virtual agent a reference to itself. 
    /// This allows the virtual agent to have a reference to call the IPluginManager methods on.
    /// </summary>
    /// <param name="pm">Instance provided by the PluginManager after succesfully loading</param>
    public void SetPluginManager(IPluginManager pm)
    {
        _pluginManager = pm;
    }

    /// <summary>
    /// The Plugin Manager asks the virtual agent for its state.
    /// The virtual agent state must be Online to receive a seeker offer, to be connected with a seeker,
    /// to receive a message from the seeker, and to be notified that the seeker has left the session.
    /// </summary>
    /// <returns>The current state of the virtual agent</returns>
    public VirtualAgentState GetState()
    {
        return va_state;
    }

    /// <summary>
    /// The Plugin Manager will call this method when a seeker enters a queue and state that this virtual agent is associated with.
    /// These parameters are designed for certain virtual agents that can quickly tell if they want to be connected with the session or not,
    /// for example, only e-mail addresses from the @acme.com domain, or only questions that contain the word 'password'.
    /// </summary>
    /// <param name="sessionId">The Chime session ID associated with the session being offered</param>
    /// <param name="queueName">Name of the queue the seeker is coming from</param>
    /// <param name="queueID">ID of the queue the seeker is coming from</param>
    /// <param name="email">The email address of the seeker that is being offered</param>
    /// <param name="question">The question of the seeker that is being offered</param>
    /// <param name="prevState">The previous state of the session that is being offered</param>
    /// <returns>This boolean value represents whether the virtual agent will be connected with the session,
    /// if false, the Plugin Manager will move this session along to the next state in the session life-cycle</returns>
    public bool IncomingSeekerOffer(int sessionId, string queueName, int queueID, string email, string question, PreviousSessionState? prevState)
    {
        return true;
    }

    /// <summary>
    /// This method will be called by the Plugin Manager if true was returned from IncomingSeekerOffer for this session ID.
    /// </summary>
    /// <param name="sessionId">The Chime session ID associated with the session being connected</param>
    /// <returns>The bool value represents if the virtual agent was able to connect successfully, if the virtual agent returns false the session will move to the next state in the session lifecycle.
    /// If the virtual agent returns true, the session will stay connected until either the virtual agent or the seeker disconnect (virtual agents disconnect by called the PluginManager.DisconnectVirtualAgent method).</returns>
    public bool SeekerConnected(int sessionId)
    {
        _pluginManager.SetSessionResolvedTag(sessionId, true);
        bool continueToRouting = true; //this varible is for deflection purposes, and only makes sense for Conversational Virtual Agents that might deflect a seeker away from a live agent and to some other resource instead
        _pluginManager.DisconnectVirtualAgent(sessionId, continueToRouting);
        return true;
    }

    /// <summary>
    /// The Plugin Manager will call this method to notify the virtual agent if the seeker closes their chat window, i.e., leaves the session.
    /// </summary>
    /// <param name="sessionId">The Chime session ID associated with the session being disconnected</param>
    public void SeekerDisconnected(int sessionId)
    {
    }

    /// <summary>
    /// The Plugin Manager will call this method to broker a message it received from the seeker while connected with the virtual agent.
    /// </summary>
    /// <param name="sessionId">The Chime session ID associated with the seeker sending the message</param>
    /// <param name="email">The email address of the sender</param>
    /// <param name="msg">The text of the message</param>
    /// <returns></returns>
    public bool ReceiveMessage(int sessionId, string email, string msg)
    {
        return true;
    }
}

    

Questions?

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