Pigeon Agents Development Demo Settings Class - DatasmithSA/Pigeon-Voice-Training GitHub Wiki

After creating an agents library, we will need to provide some settings in order to configure the demo Pigeon Voice Agents. Using the Figlut Server Toolkit, we will create a settings class that will be serialised and deserialised to an XML settings file.

  1. Add a new class in the agents library project and call it AgentsSettings.
  2. Add a reference to the Figlut.Server.Toolkit.dll to your agents library project.
  3. Add a using clause to the top of the new the AgentsSettings class file: using Figlut.Server.Toolkit.Utilities.SettingsFile;
  4. Inherit from the Figlut "Settings" class.
  5. We will only need two settings to supply the connection string to the demo SQL Server database and command timeout. Here is the complete code of this class:
    #region Using Directives

    using Figlut.Server.Toolkit.Utilities.SettingsFile;

    #endregion //Using Directives

    public class AgentsSettings : Settings
    {
        #region Properties

        #region Database Settings

        /// <summary>
        /// The connection string to the SQL Server database holding demo data for the agents.
        /// </summary>
        public string DatabaseConnectionString { get; set; }

        /// <summary>
        /// The database command timeout to the SQL Server database holding the demo data for the agents.
        /// </summary>
        public int DatabaseCommandTimeout { get; set; }

        #endregion //Database Settings

        #endregion //Properties

        #region Methods

        public AgentsSettings CreateDefaultSettings()
        {
            return new AgentsSettings()
            {
                DatabaseConnectionString = "Enter connection string here",
                DatabaseCommandTimeout = 30000
            };
        }

        #endregion //Methods
    }
  1. The Settings class has the Save() base method to save the the class to file, which essentially serialises the class to an XML settings file in the executing directory. To generate the settings you can instantiate a new AgentsClass in code, populate its properties and then call the Save() method. Alternatively you can simply create the settings file by adding an XML file named to your project and copy and paste the following XML code inside of it. N.B. the name of the settings file must be the same name as your settings class with the XML file extension added to the end i.e. AgentsSettings.xml.
<?xml version="1.0" encoding="utf-8" ?>
<AgentsSettings>
  <DatabaseConnectionString>Data Source=PAULKOLOZSV38D1\MSSQLEXPRESS2012;Initial Catalog=PigeonVoiceDemo;Persist Security Info=True;User ID=sa;Password=27830529</DatabaseConnectionString>
  <DatabaseCommandTimeout>30000</DatabaseCommandTimeout>
</AgentsSettings>
  1. Update your settings in the file as required to provide the connection string to the SQL Server database.
  2. Ensure that you set the "Copy to output directory" property on the file to "Copy if newer" in order for the file to be copied to the executable directory where the agents will be built to, which would typically be in the Pigeon Voice Server's installation folder. When the agents run they will look for this file in the execution directory and the AgentsGlobals singleton which we will develop will load (deserialise) the file into an "AgentsSettings" object available for the agents to use at runtime.
⚠️ **GitHub.com Fallback** ⚠️