Email Integration

Learn how to quickly integrate a Chime virtual agent with SMTP.

Join the Beta » Request a Demo »

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


Sending an email is a breeze with Virtual Agents. The API in Chime provides an email service for Virtual Agents to use. This sample calls into the email service to send an email to a predefined recipient (e.g., manager) with the Chime session data in the body of the message.

Before we get started...Check your references!

This post-conversation Virtual agent sample is written as a C# script file. It uses the following references:

using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Mail;
using System.Text;


1. Create a class that implements the IVirtualAgent interface

Create a .cs class that implements the IVirtualAgent interface. Then, in the Load method, return a VirtualAgentProps object that specifies this Virtual Agent type as Post-Conversation.

public bool Load()
    va_state = VirtualAgentState.Online;
    var vaData = new VirtualAgentProps("E-mail dispatcher", "1", VirtualAgentType.PostConversation,
            "sends an e-mail to the target e-mail address with all the session data formatted in the body",
            "Instant Technologies"); //name, version, VirtualAgentType, description, author
    return  new Tuple<bool, VirtualAgentProps>(true, vaData);


2. Connect with a session and get the session data from Chime

In the SeekerConnected method, the Virtual Agent asks the PluginManager for the session’s PostChatData, that is all the data that was known when the seeker entered the queue, and the other data the was added over the course of being connected with a live agent, such as chat messages, skill tags, etc. In this example, the “clean” PostChatData is used which is stripped of HTML markup and doesn't contain empty seeker data values. Then we send that data to be dispatched in an e-mail, and finally we tell the PluginManager to disconnect us. For post-conversation Virtual Agents, the keepAlive value is ignored by the PluginManager because the session is already completed. i.e., “terminated”.

public bool SeekerConnected(int sessionId)
    PostChatData chatData = _pluginManager.PostChatEventClean(sessionId);
    bool keepAlive = true;
    _pluginManager.DisconnectVirtualAgent(sessionId, keepAlive);
    return true;


3. Send the session data as an e-mail

Finally the session data is formatted into an e-mail message and sent to a mailbox, using the PluginManager's email service. (Note, the WriteToString method just builds a string out of the different object fields of PostChatData).

private void DispatchEmail(PostChatData chatData)
    if (_pluginManager.Email.Enabled) {
        var sent = _pluginManager.Email.SendEmail(chatData.question.Replace("\n", "")
                                                .Replace("\r", ""), WriteToString(chatData),
                                                new List<string>() { _targetEmailAddress });
            if (sent) {
                            "Success dispatching e-mail to target mailbox " + _targetEmailAddress);
            } else {
                            "Failure dispatching email to target mailbox " + _targetEmailAddress);
        } else {
                            "Error dispatching e-mail. PluginManager e-mail service is not enabled.");



Have a question about Chime integration with SMTP? Ask one of our developers at