static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); // update a task's attributes Task task = client.UpdateTask(WorkspaceSid, TaskSid, "{\"type\":\"support\"}", null, null, null); Console.WriteLine(task.Attributes); Console.WriteLine(task.Age); // update a task attributes with a dictionary to map to json Dictionary<string,string> attributes = new Dictionary<string,string>(); attributes.Add("type", "support"); task = client.UpdateTask(WorkspaceSid, TaskSid, attributes, null); Console.WriteLine(task.Attributes); Console.WriteLine(task.Age); // cancel a task task = client.UpdateTask(WorkspaceSid, TaskSid, null, null, "canceled", "waiting too long"); Console.WriteLine(task.AssignmentStatus); Console.WriteLine(task.Reason); // cancel a task #2 task = client.CancelTask(WorkspaceSid, TaskSid, "waiting too long"); Console.WriteLine(task.AssignmentStatus); Console.WriteLine(task.Reason); }
public void ShouldSetProperApiVersion() { var client = new TaskRouterClient("XXXXXX", "XXXXXXX"); Assert.AreEqual("v1", client.ApiVersion); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); client.DeleteWorkspace(WorkspaceSid); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); Workspace workspace = client.GetWorkspace(WorkspaceSid); Console.WriteLine(workspace.FriendlyName); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); TaskQueue taskQueue = client.AddTaskQueue (WorkspaceSid, "English", "WAxxxx", "WAyyyy", "languages HAS 'english'", null); Console.WriteLine(taskQueue.FriendlyName); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); Activity activity = client.AddActivity(WorkspaceSid, "NewAvailableActivity", true); Console.WriteLine(activity.FriendlyName); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); Workspace workspace = client.AddWorkspace("NewWorkspace", "http://requestb.in/vh9reovh", "FIFO"); Console.WriteLine(workspace.FriendlyName); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); WorkersStatistics stats = client.ListWorkersStatistics(WorkspaceSid); Console.WriteLine(stats.Cumulative.ReservationsAccepted); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); Task task = client.AddTask(WorkspaceSid, "{\"type\":\"support\"}", WorkflowSid, null, null); Console.WriteLine(task.Attributes); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); WorkflowResult workflowResult = client.ListWorkflows(WorkspaceSid); foreach(Workflow workflow in workflowResult.Workflows) { Console.WriteLine(workflow.FriendlyName); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); ActivityResult activityResult = client.ListActivities(WorkspaceSid); foreach(Activity activity in activityResult.Activities) { Console.WriteLine(activity.FriendlyName); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); TaskQueueResult taskQueueResult = client.ListTaskQueues(WorkspaceSid); foreach(TaskQueue taskQueue in taskQueueResult.taskQueues) { Console.WriteLine(taskQueue.FriendlyName); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); EventResult eventsResult = client.ListEvents(WorkspaceSid); foreach(Event trEvent in eventsResult.Events) { Console.WriteLine(trEvent.EventType); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); TaskQueue taskQueue = client.UpdateTaskQueue(WorkspaceSid, TaskQueueSid, null, null, null, "languages HAS 'english'", 100); Console.WriteLine(taskQueue.FriendlyName); Console.WriteLine(taskQueue.TargetWorkers); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); WorkspaceStatistics stats = client.GetWorkspaceStatistics(WorkspaceSid); Console.WriteLine(stats.Cumulative.AvgTaskAcceptanceTime); Console.WriteLine(stats.Cumulative.TasksCreated); Console.WriteLine(stats.Realtime.TasksByStatus.Pending); Console.WriteLine(stats.Realtime.TasksByStatus.Assigned); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string ReservationSid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); // reject a reservation Reservation reservation = client.UpdateReservation(WorkspaceSid, TaskSid, ReservationSid, "rejected", null); Console.WriteLine(reservation.ReservationStatus); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string WorkerSid = "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); ReservationResult reservationResult = client.ListReservationsForWorker(WorkspaceSid, WorkerSid); foreach(Reservation reservation in reservationResult.Reservations) { Console.WriteLine(reservation.ReservationStatus); Console.WriteLine(reservation.WorkerName); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); StatisticsRequest request = new StatisticsRequest(); request.Minutes = 500; request.EndDate = DateTime.Now; TaskQueueStatistics stats = client.GetTaskQueueStatistics(WorkspaceSid, TaskQueueSid, request); Console.WriteLine(stats.Cumulative.ReservationsAccepted); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); Task task = client.GetTask(WorkspaceSid, TaskSid); Console.WriteLine(task.Attributes); // alternatively Dictionary<string,string> fetchedAttributes = task.ParseAttributes(); string value = fetchedAttributes["foo"]; Console.WriteLine(value); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); Worker worker = client.AddWorker(WorkspaceSid, "Support Worker 1", null, "{\"type\":\"support\"}"); Console.WriteLine(worker.FriendlyName); // create a worker with a dictionary to map to json Dictionary<string,string> attributes = new Dictionary<string,string>(); attributes.Add("type", "support"); worker = client.AddWorker(WorkspaceSid, "Support Worker 1", null, attributes); Console.WriteLine(worker.FriendlyName); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string ReservationSid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); // Update a Reservation with a Dequeue instruction Reservation reservation = client.GetReservation(WorkspaceSid, TaskSid, ReservationSid); Console.WriteLine(reservation.ReservationStatus); Console.WriteLine(reservation.WorkerName); client.UpdateReservation(WorkspaceSid, "Tasks", TaskSid, ReservationSid, instruction: "dequeue", dequeueFrom: "+18001231234"); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string ReservationSid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); // Update a Reservation with a Redirect instruction Reservation reservation = client.GetReservation(WorkspaceSid, TaskSid, ReservationSid); Console.WriteLine(reservation.ReservationStatus); Console.WriteLine(reservation.WorkerName); client.UpdateReservation(WorkspaceSid, "Tasks", TaskSid, ReservationSid, instruction: "Redirect", redirectCallSid: "CA123456789", redirectUrl: "http://example.com/assignment_redirect"); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); WorkerListRequest filters = new WorkerListRequest(); filters.TaskQueueSid = "WQf855e98ad280d0a0a325628e24ca9627"; WorkerResult workerResult = client.ListWorkers(WorkspaceSid, filters); foreach(Worker worker in workerResult.Workers) { Console.WriteLine(worker.FriendlyName); } filters = new WorkerListRequest(); filters.TargetWorkersExpression = "type == 'leads'"; workerResult = client.ListWorkers(WorkspaceSid, filters); foreach(Worker worker in workerResult.Workers) { Console.WriteLine(worker.FriendlyName); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); TaskListRequest filters = new TaskListRequest(); filters.TaskQueueSid = "WQf855e98ad280d0a0a325628e24ca9627"; TaskResult taskResult = client.ListTasks(WorkspaceSid, filters); foreach(Task task in taskResult.Tasks) { Console.WriteLine(task.Attributes); } filters = new TaskListRequest(); filters.AssignmentStatus = "pending"; taskResult = client.ListTasks(WorkspaceSid, filters); foreach(Task task in taskResult.Tasks) { Console.WriteLine(task.Attributes); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string ReservationSid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); // Update a Reservation with a Call instruction Reservation reservation = client.GetReservation(WorkspaceSid, TaskSid, ReservationSid); Console.WriteLine(reservation.ReservationStatus); Console.WriteLine(reservation.WorkerName); client.UpdateReservation(WorkspaceSid, "Tasks", TaskSid, ReservationSid, instruction: "call", callFrom: "+19876543210", callUrl: "http://example.com/agent_answer", callStatusCallbackUrl: "http://example.com/agent_answer_status_callback", callAccept: "true"); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string salesQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string marketingQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string supportQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string everyoneQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; var client = new TaskRouterClient(AccountSid, AuthToken); // sales var salesRule = new Filter() { FriendlyName = "Sales", Expression = "type == 'sales'", Targets = new List<Target>() { new Target { Queue = salesQueue } } }; // marketing var marketingRule = new Filter() { FriendlyName = "Marketing", Expression = "type == 'marketing'", Targets = new List<Target>() { new Target { Queue = marketingQueue } } }; // support var supportRule = new Filter { FriendlyName = "Support", Expression = "type == 'support'", Targets = new List<Target>() { new Target { Queue = supportQueue } } }; var workflowConfiguration = new WorkflowConfiguration(); workflowConfiguration.Filters.Add(salesRule); workflowConfiguration.Filters.Add(marketingRule); workflowConfiguration.Filters.Add(supportRule); workflowConfiguration.DefaultFilter = new Target() { Queue = everyoneQueue }; // convert to json var workflowJSON = workflowConfiguration.ToString(); // call rest api Workflow workflow = client.AddWorkflow(WorkspaceSid, "Sales, Marketing, Support Workflow", workflowJSON, "http://example.com", "http://example2.com", 30); Console.WriteLine(workflow.FriendlyName); }
public void ShouldSetProperBaseUrl() { var client = new TaskRouterClient("XXXXXX", "XXXXXXX"); Assert.AreEqual("https://taskrouter.twilio.com/", client.BaseUrl); }