Note: The Virtual Agent can be downloaded here » Virtual Agent SDK (zip) (VirtualAgentSDK\Samples\SolarWinds)
The SolarWinds Virtual Agent SDK sample includes two Virtual Agents that automatically create and update ticket records. The Pre-Conversation Virtual Agent looks for an existing ticket (from field in the Web Client – see below) or creates a ticket in SolarWinds and fills out the following fields:
This Virtual Agent sample uses additional information from Web Client. The Web Client should be changed to have the following fields:
The Virtual Agent sample uses the following references:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
In the IncomingSeekerOffer method, the Pre-Conversation Virtual Agent caches the guest’s question, e-mail address, and session ID.
public bool IncomingSeekerOffer(int sessionId, string queueName, int queueID, string email, string question, PreviousSessionState? prevState)
{
var seekerInfo = new SeekerInfo(email, question);
if (!_openSessions.ContainsKey(sessionId))
{
_openSessions.Add(sessionId, seekerInfo);
}
else
{
_openSessions[sessionId] = seekerInfo;
}
return true;
}
const string RoomNumber = "RoomNumber";
const string Extension = "Extension";
const string AssetNumber = "AssetNumber";
const string RequestType = "RequestType";
public bool SeekerConnected(int sessionId)
{
_va_state = VirtualAgentState.Busy;
if (_openSessions.ContainsKey(sessionId))
{
var seekerInfo = _openSessions[sessionId];
var data = _pluginManager.GetSeekerDictionary(sessionId);
var roomNumber = "";
var extension = "";
var assetNumber = "";
var requestType = -1;
if (data.ContainsKey(RoomNumber))
{
roomNumber = data[RoomNumber];
}
if (data.ContainsKey(Extension))
{
extension = data[Extension];
}
if (data.ContainsKey(AssetNumber))
{
assetNumber = data[AssetNumber];
}
if (data.ContainsKey(RequestType))
{
try
{
requestType = int.Parse(data[RequestType]);
}
catch (Exception ex)
{
_pluginManager.LogMessageInChime(LoggingLevel.Error, "Exception parsing RequestType from seeker data. This field is required to create a ticket in SolarWinds.");
}
}
var ticket_url = _api.PreConversation(sessionId, requestType, seekerInfo, roomNumber, extension, assetNumber);
var custom_tabs = new List<CustomTab>() { new CustomTab(ticket_url, "SolarWinds Ticket", false) };
_pluginManager.SendCustomTabToAgent(sessionId, custom_tabs);
}
else
{
_pluginManager.LogMessageInChime(LoggingLevel.Error, "No seeker info found for session ID");
}
_pluginManager.DisconnectVirtualAgent(sessionId, true);
_va_state = VirtualAgentState.Online;
return true;
}
public bool SeekerConnected(int sessionId)
{
_api.PostConversation(sessionId, _pluginManager.GetChatMessagesClean(sessionId));
_pluginManager.DisconnectVirtualAgent(sessionId, false);
return true;
}
public void PostConversation(int sessionId, List<string> chatMessages)
{
var chatHistory = "";
if (chatMessages.Any())
{
chatHistory = chatMessages.Aggregate((next, workingSentence) => next + Environment.NewLine + workingSentence);
}
if (_sessionIdToTicket.ContainsKey(sessionId))
{
var ticket = _sessionIdToTicket[sessionId];
var note = new Note(chatHistory, ticket.id);
CreateNote(note);
RemoveSeeker(sessionId);
}
else
{
_pluginManager.LogMessageInChime(LoggingLevel.Error, "Chime session ID was not found in virtual agent cache of session Tickets in SolarWinds");
}
}
Have a question about Chime virtual agents? Ask one of our developers at InstantDev@instant-tech.com.