static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "{{ account_sid }}"; string AuthToken = "{{ auth_token }}"; string WorkspaceSid = "{{ workspace_sid }}"; string WorkflowSid = "{{ workflow_sid }}"; var client = new TaskRouterClient(AccountSid, AuthToken); Task task = client.AddTask(WorkspaceSid, "{\"type\":\"support\"}", WorkflowSid, null); Console.WriteLine(task.Attributes); // create a task with a dictionary to map to json Dictionary <string, string> attributes = new Dictionary <string, string>(); attributes.Add("type", "support"); Task task = client.AddTask(WorkspaceSid, taskAttributes, WorkflowSid, null); Console.WriteLine(task.ParseAttributes()['type']);
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); }
public async Task <dynamic> CreateTask(int caseId, string agentSid, Skill requiredSkill) { int?timeout = null; int?priority = 1; var skill = requiredSkill.ToLowerCaseString(); var attributes = new Dictionary <string, string> { { "selected_skill", skill }, { "case_id", $"{caseId}" }, { "agent_sid", agentSid } }; var attributesJson = JsonConvert.SerializeObject(attributes); var task = client.AddTask( settings.TaskRouter.Workspace.Sid, attributesJson, settings.TaskRouter.Workflow.Sid, timeout, priority); var model = CreateTaskModel(task); return(model); }
public ActionResult Message(string body, string AddOns) { var response = new TwilioResponse(); dynamic addons = JsonConvert.DeserializeObject(AddOns); if (addons["status"] == "successful") { var language = addons["results"]["ibm_watson_insights"]["result"]["language"].Value; if (language == "spanish") { response.Message("Gracias por contactar con nuestro equipo de soporte. Uno de nuestros agentes de soporte estará con usted pronto."); } else if (language == "french") { response.Message("Merci de contacter notre équipe d’assistance. Un de nos agents de soutien fera avec vous sous peu."); } else { response.Message("Thank you for contacting our support team. One of our support agents will be with you shortly."); } var client = new TaskRouterClient("YOUR_ACCOUNT_SID", "YOUR_AUTH_TOKEN"); var result = client.AddTask( "YOUR_WORKSPACE_SID", JsonConvert.SerializeObject(new { language = language, body = body }), "YOUR_WORKFLOW_SID", null, null); if (result.RestException != null) { throw new HttpException(result.RestException.Message); } } else { response.Message("We're really sorry but something seems to have gone wrong when we tried to read your message. Can you try sending it again? If it keeps happening us, try giving us a call at 1-800-555-5555"); } return(TwiML(response)); }