Skip to main content
Version: Current

Schedule.CreateScheduleAsync

Description​

Creates a new Schedule (Time Trigger) with specified NewScheduleInfo details inside the connected AI Command Center.

Signature [C#]​

Task<ScheduleInfo> CreateScheduleAsync(NewScheduleInfo newScheduleInfo);

Properties​

Input​

ParameterTypeRequired / defaultDescription
newScheduleInfoNewScheduleInfoRequiredSpecify the details to create new Schedule (Time Trigger).

Output​

TypeDescription
Task<ScheduleInfo>Returns newly created Schedule (Time Trigger) details.

Remarks​

Use CreateScheduleAsync API to create new Schedule (Time Trigger) with specified NewScheduleInfo details from the connected AI Command Center.

Example​

C#
public async Task CreateTimeTrigger()
{
IControlRoomContext context = LoginControlRoom();
try
{
int processId = 1;
int botId = 1;
string scheduleName = "TestSchedule";
DateTime? expiresOn = null;
// Creates a schedule of type Daily
List<TimeSpan> timeSpan = new List<TimeSpan>
{
DateTime.UtcNow.AddMinutes(1).TimeOfDay
};
ExecutionTimeInfo executionTimeInfo = new ExecutionTimeInfo();
executionTimeInfo.Times = timeSpan;
executionTimeInfo.TimeInterval = TimeSpan.Zero;
NewScheduleInfo newScheduleInfo = new NewScheduleInfo()
{
ProcessId = processId,
BotId = botId,
Name = scheduleName,
ScheduleType = ScheduleType.Daily,
StartDate = DateTime.UtcNow,
ExpiresOn = expiresOn,
Frequency = executionTimeInfo
};
ScheduleInfo createSchedule = await context.Schedules.CreateScheduleAsync(newScheduleInfo);
System.Console.WriteLine("Schedule Id: " + createSchedule.ScheduleId + "ScheduleName: " + createSchedule.Name);
}
finally
{
context.Close();
}
}
Connection helper
public IControlRoomContext LoginControlRoom()
{
string RequiredSetting(string name) => Environment.GetEnvironmentVariable(name) ?? throw new InvalidOperationException($"Set {name} before running this example.");
string serverUrl = RequiredSetting("INTELLIBUDDIES_SERVER_URL");
string userName = RequiredSetting("INTELLIBUDDIES_USERNAME");
string password = RequiredSetting("INTELLIBUDDIES_PASSWORD");
string connectionString = $"ServerUrl={serverUrl};UserName={userName};Password={password}";
IControlRoomContext context = new ControlRoomContext(connectionString);
context.Open();
return context;
}

See Get started for namespaces, configuration, and context cleanup, and SDK usage for error handling.