<!-- Download Links -->
Microsoft Office 2000 uses animated characters, which it
calls Office Assistants, to help users and provide assistance. With Microsoft
Agent, you can add such characters to your own applications. You can even use
the Office Assistants themselves – like The Genius or F1. Characters designed
for use with Agent can do a variety of tasks – like speech synthesis and
recognition, in addition to displaying a variety of animations.
To be able to use this technology, you must have:
- The Microsoft Agent Core components.
- The Microsoft Agent Characters – Genie, Merlin,
Robby, and Peedy.
- The Lernout and Hauspie Text-to-Speech engines for at
least US English.
- The Microsoft Speech API 4.0a runtime.
- The Microsoft Speech Recognition Engine.
All these components are available from
In addition, to use the Microsoft Office characters, you must have Office 2000.
Office 97 characters are not compatible with Agent.
Microsoft Agent is provided as an ActiveX control DLL. To
use it within .NET, you can use the AxImp.exe utility provided with the .NET
Framework SDK. Create a folder where you want to keep the imported libraries,
and then use the command:
The makefile included in the download does this for you. This command should create two files: AxAgentObjects.dll
and AgentObjects.dll. You are now ready to use Agent with
Agent programming is easy because it
relies completely on COM, and we don’t have to mess around with PInvoke or
something. The first step to using Agent is to add the Agent ActiveX control in
AxAgentObjects.dll to your project. Put it anywhere on a form; it is invisible
at runtime. Next, you should add a member variable of type
AgentObjects.IAgentCtlCharacterEx (from AgentObjects.dll) to your class. You
should import the AgentObjects namespace into your application; this simplifies
several tasks. Essentially, you must, at a minimum:
- Load the character you want, and provide a descriptive name to refer to it. In
the Hello World sample, this is accomplished by the line AxAgent.Characters.Load("Genie", (object)"GENIE.ACS");
- Set your character variable to the character you just loaded. In the Hello
World sample, this is accomplished by the line Character = AxAgent.Characters["Genie"];
- Set the correct language to use: Character.LanguageID = 0x409; sets the language to
- Show the character: Character.Show(null);
These steps shall simply load and
display the character.
The mandatory Hello World sample requires
the Genie character. The sample simply loads the character and displays him.
You can also make him say something. To make the character talk, the character’s
speak method is called, like this:
if(TextToSpeak.Text.Length == 0) // Don't speak a zero-length
return; // string.
//Make the character speak.
As you can see, it’s very simple to use Agent.
Unlike the office assistants, you can make Agent characters
talk and also respond to voice commands. Any commands you add shall also be
available in the character’s context menu. Speech recognition is, by default,
enabled only when you hold down the scroll lock key. All you have to do is to add
new commands to the character object’s Commands collection. Then, you must add an
event handler for the Agent control’s Command event. A boxed IAgentCtlUserInput
object is supplied to the event handler as a parameter. You can access the
command recognised by the IAgentCtlUserInput object’s Name property.
The Interactive Hello World sample demonstrates basic speech
recognition, as well as playing animation. First, the control and the character
(Robby) are loaded and initialised, and then two commands are added:
protected void LoadButton_Click(object sender, System.EventArgs e)
// Load the Robby character.
Character = AxAgent.Characters["Robby"];
StatusLabel.Text = Character.Name + " loaded.";
// Set the language to US English.
Character.LanguageID = 0x409;
// Display the character.
LoadButton.Enabled = false;
// Display name for the commands.
Character.Commands.Caption = "Hello World";
Character.Commands.Add("Hello", // Command name
(object)"Say Hello", // Display name
(object)"([say](hello | hi) | good (day | morning | evening))", // SR String
(object)true, // Enabled
(object)true); // Visible
Character.Commands.Add("Goodbye", // Command name
(object)"Goodbye", // Display name
(object)"(bye | goodbye | exit | close | quit)", // SR String
(object)true, // Enabled
(object)true); // Visible
PromptLabel.Visible = true;
The speech recognition strings offer several options that
the user can say; for example, saying ‘goodbye’, ‘bye’ and ‘close’ have the
same effect. In all cases, the command name is passed to the event handler, so
you don’t have to account for the various variations of the recognised string.
In the event handler, a test is done for the command:
protected void AxAgent_Command(object sender, AxAgentObjects._AgentEvents_CommandEvent e)
ui = (IAgentCtlUserInput)e.userInput;
if(ui.Name == "Hello")
Character.Speak((object)"Hello. My name is Robby." +
" Pleased to meet you.", null);
PromptLabel.Text = "Say goodbye to dismiss Robby.";
if(ui.Name == "Goodbye")
Character.Speak((object)"It was nice talking to" +
" you. Goodbye.", null);
Animations are played with the character object’s play
If you see the
Microsoft Agent site, you will see a Visual Basic sample that enumerates all
animations present in a character. The AgentDemo application also does the same
thing, only in C#. You can load all Agent and Microsoft Office characters and
see a list of animations. Here’s a screenshot (with the Office 2000 F1
This app is kinda redundant now, because Microsoft ships just such a sample with Beta 2.
I just converted what I had done for Beta 1 to Beta 2 code.
Many people think that the Office Assistants are irritating.
You must take care not to make your characters irritating, but instead helpful,
and always provide an easily accessible option to turn them off.
15 Mar 2002 - updated source files.