static void Main(string[] args) { // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var jokeActions = new JObject { { "actions", new JObject { { "say", "I was going to look for my missing watch, but I could never find the time." } } } }; var task = TaskResource.Create( pathAssistantSid: "UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", uniqueName: "tell-a-joke", actions: jokeActions ); Console.WriteLine("Tell-a-joke task has been created!"); }
static void Main(string[] args) { // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var taskActions = new JObject { { "actions", new JObject { { "say", "Hi there, I'm your virtual assistant! How can I help you?" }, { "listen", true } } } }; var task = TaskResource.Create( pathAssistantSid: "UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", uniqueName: "hello-world", actions: taskActions ); Console.WriteLine($"Hello-world task has been created!"); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var actions = new Dictionary <string, Object>() { { "actions", new object [] { new Dictionary <string, Object>() { { "say", new Dictionary <string, Object>() { { "speech", "I was going to look for my missing watch, but I could never find the time." } } } } } } }; var task = TaskResource.Create( friendlyName: "tell-a-joke", actions: actions, uniqueName: "tell-a-joke", pathAssistantSid: "UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(task.Sid); }
static void Main(string[] args) { const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var taskActions = new JObject { { "actions", new JObject { { "say", "Hi there, I'm your virtual assistant! How can I help you?" }, { "listen", true } } } }; var task = TaskResource.Create( pathAssistantSid: "UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", uniqueName: "hello-world", actions: taskActions ); Console.WriteLine($"Hello-world task has been created!"); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var task = TaskResource.Create( pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(task.Sid); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"age\": 25200,\"assignment_status\": \"pending\",\"attributes\": \"{\\\"body\\\": \\\"attributes\\\"}\",\"date_created\": \"2014-05-14T18:50:02Z\",\"date_updated\": \"2014-05-15T07:26:06Z\",\"priority\": 1,\"reason\": \"Test Reason\",\"sid\": \"WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"task_queue_sid\": \"WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"task_channel_sid\": \"TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"task_channel_unique_name\": \"unique\",\"timeout\": 60,\"url\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"workspace_sid\": \"WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"workflow_sid\": \"WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"workflow_friendly_name\": \"Example Workflow\",\"task_queue_friendly_name\": \"Example Task Queue\",\"addons\": \"{}\",\"links\": {\"task_queue\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"workflow\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"workspace\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reservations\": \"https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations\"}}" )); var response = TaskResource.Create("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"unique_name\": \"unique_name\",\"links\": {\"fields\": \"https://preview.twilio.com/understand/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Fields\",\"samples\": \"https://preview.twilio.com/understand/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Samples\",\"task_actions\": \"https://preview.twilio.com/understand/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Actions\",\"statistics\": \"https://preview.twilio.com/understand/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics\"},\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"friendly_name\": \"friendly_name\",\"url\": \"https://preview.twilio.com/understand/Assistants/UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"sid\": \"UDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_updated\": \"2015-07-30T20:00:00Z\",\"assistant_sid\": \"UAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"2015-07-30T20:00:00Z\",\"actions_url\": \"https://example.com/actions_url\"}" )); var response = TaskResource.Create("UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "UniqueName", client: twilioRestClient); Assert.NotNull(response); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TwilioClient.Init(accountSid, authToken); var task = TaskResource.Create( workspaceSid, "{\"type\":\"support\"}", workflowSid); Console.WriteLine(task.Attributes); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var task = TaskResource.Create( friendlyName: "tell a joke", uniqueName: "tell-a-joke", pathAssistantSid: "UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(task.Sid); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); const string workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TwilioClient.Init(accountSid, authToken); var task = TaskResource.Create( workspaceSid, attributes: "{\"type\":\"support\"}", workflowSid: workflowSid); Console.WriteLine(task.Attributes); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var task = TaskResource.Create( uniqueName: "uniqueName", pathAssistantSid: "UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(task.Sid); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Taskrouter, "/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { TaskResource.Create("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Preview, "/understand/Assistants/UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks", "" ); request.AddPostParam("UniqueName", Serialize("UniqueName")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { TaskResource.Create("UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "UniqueName", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var attributes = JsonConvert.SerializeObject(new Dictionary <string, Object>() { { "type", "support" } }, Formatting.Indented); var task = TaskResource.Create( attributes: attributes, workflowSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(task.Sid); }
public ActionResult CallTransfer() { TwilioClient.Init(_accountSid, _authToken); string conferenceSid = Request.Params.Get("conference"); string callSid = Request.Params.Get("participant"); ParticipantResource.Update( conferenceSid, callSid, hold: true ); try { string json = @"{ 'selected_product': 'manager', 'conference': '" + Request.Params.Get("conference") + @"', 'customer': '" + Request.Params.Get("participant") + @"', 'customer_taskSid': '" + Request.Params.Get("taskSid") + @"', 'from': '" + Request.Params.Get("from") + @"', }"; var task = TaskResource.Create( _workspaceSid, attributes: JsonConvert.DeserializeObject(json).ToString(), workflowSid: _workflowSid ); } catch (Exception e) { Console.Write(e.ToString()); } return(View()); }
static void Main(string[] args) { const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var jokeActions = new JObject { { "actions", new JObject { { "say", "I was going to look for my missing watch, but I could never find the time." } } } }; var task = TaskResource.Create( pathAssistantSid: "UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", uniqueName: "tell-a-joke", actions: jokeActions ); Console.WriteLine("Tell-a-joke task has been created!"); }