Note: The Virtual Agent can be downloaded here » Virtual Agent SDK (zip) (VirtualAgentSDK\Samples\CS-ScriptVirtualAgents\SimpleVA_AddCustomTabs.cs)
A popular feature for Virtual Agents is their ability to send an additional tab to the agent’s Context Window Extension (CWE). The new tab embeds a web page in the Skype for Business IM client and can greatly improve the agent’s efficiency. This sample demonstrates a Pre-Conversation type of Virtual Agent that simply adds two custom web pages to the CWE: one for Google.com and one for Youtube.com.
The two custom tabs are slightly different in their behavior. The tab for Google.com opens in a new browser page while the tab for Youtube.com is embedded in the CWE. This is because Youtube.com can be embedded in an iframe, while Google.com cannot.
public bool IncomingSeekerOffer(int sessionId, string queueName, int queueID, string email, string question, PreviousSessionState? prevState)
{
return true;
}
public bool SeekerConnected(int sessionId)
{
List<CustomTab> customTabs = new List<CustomTab>();
customTabs.Add(new CustomTab("http://www.google.com", "Virtual Agent Custom Tab 1", false)); //the false argument means this Google.com cannot be embedded in an IFrame
customTabs.Add(new CustomTab("https://www.youtube.com/embed/tlugWhl-Te0", "Virtual Agent Custom Tab 2", true)); //the true argument means Youtube.com can be embedded in an IFrame
_pluginManager.SendCustomTabToAgent(sessionId, customTabs); //send custom tabs to Chime
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;
}
using System;
using System.Collections.Generic;
/* © Instant Technologies 2016
*
* This is a simple virtual agent script file that will add two additional web pages to the agent's Context Window Extension (CWE):
* - Google.com. This will appear as a button on the left hand side of the CWE that will open a web page in a new window.
* - Youtube.com. This will appear as an embedded web page within the CWE because Youtube.com can be embedded in an iFrame.
*
* In the IncomingSeekerOffer method the virtual agent accepts all sessions.
* Then the tabs for Google.com and Youtube.com is sent to the agent 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 "Add Custom Tabs to CWE"
* Finally, assign this virtual agent to a queue in queue settings, under the People tab, then Virtual Agents.
* Select the Pre-Conversation virtual agent and save your changes.
*
*/
public class SimpleVA_AddCustomTabs : 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("Add Custom Tabs to CWE", "1", VirtualAgentType.PreConversation, "Adds 2 new web pages to the agent Context Window Extension (CWE): Google.com and Youtube.com", "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)
{
List<CustomTab> customTabs = new List<CustomTab>();
customTabs.Add(new CustomTab("http://www.google.com", "Virtual Agent Custom Tab 1", false)); //the false argument means this Google.com cannot be embedded in an IFrame
customTabs.Add(new CustomTab("https://www.youtube.com/embed/tlugWhl-Te0", "Virtual Agent Custom Tab 2", true)); //the true argument means Youtube.com can be embedded in an IFrame
_pluginManager.SendCustomTabToAgent(sessionId, customTabs); //send custom tabs to Chime
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;
}
}
Have a question about Chime virtual agents? Ask one of our developers at InstantDev@instant-tech.com.