style {` .panel-gray{ background-color: #CEE9F9; padding: 10px 10px 5px 10px; color:#000000; text-align: center;max-width: 1100px; border-radius:4px;font-family: DMSans, Helvetica, Arial, sans-serif; } `} div b Some features of this SDK are still in development. Consult with our [online support team](mailto:onlineteam@sinch.com) if you run into issues using this SDK in a production environment. # Send a Conversation Message with the Sinch .NET SDK Note: Before you can get started, you need the following already set up: - - [The latest version of .NET with **Long Term Support**](https://dotnet.microsoft.com/download) and a familiarity with how to create a new console app. Learn how to quickly send Conversation messages in a .NET application with the Sinch .NET SDK. Steps: 1. [Set up](#set-up-your-net-application) your .NET application 2. [Send](#send-your-first-message) your first message ## Set up your .NET application 1. Create a new folder where you want your app project. Then, open a terminal or command prompt to that location. 2. Create a new .NET console app with the following command: ```shell dotnet new console ``` 3. Open the `Program.cs` file in your project folder. Replace everything in the file with the "Send a Conversation message" code. Send a Conversation message using System.Text.Json; using Sinch; using Sinch.Conversation; using Sinch.Conversation.Messages.Send; using Sinch.Conversation.Messages.Message; using Sinch.Conversation.Common; var sinch = new SinchClient("YOUR_project_id", "YOUR_access_key", "YOUR_access_secret", // ensure you set the Conversation region. options => options.ConversationRegion = ConversationRegion.Us); var response = await sinch.Conversation.Messages.Send(new SendMessageRequest { Message = new AppMessage(new TextMessage("Hello! Thank you for using the Sinch .NET SDK to send an SMS.")), AppId = "YOUR_app_id", Recipient = new Identified { IdentifiedBy = new IdentifiedBy { ChannelIdentities = new List { new ChannelIdentity { AppId = "YOUR_app_id", Identity = "RECIPIENT_number", Channel = new ConversationChannel("SMS") } } } }, ChannelProperties = new Dictionary { { "SMS_SENDER", "YOUR_sms_sender" } } }); Console.WriteLine(JsonSerializer.Serialize(response, new JsonSerializerOptions() { WriteIndented = true })); ### Modify your application The code provided includes placeholder parameters. You'll need to update the parameters detailed in the following subsections with your values. #### Initialize the client Before initializing a client using this SDK, you'll need three pieces of information: - Your Project ID - An access key ID - An access key Secret These values can be found on the [Access Keys](https://dashboard.sinch.com/settings/access-keys) page of the Sinch Build Dashboard. You can also [create new access key IDs and Secrets](https://community.sinch.com/t5/Conversation-API/How-to-get-your-access-key-for-Conversation-API/ta-p/8120), if required. Note If you have trouble accessing the above link, ensure that you have gained access to the [Conversation API](https://dashboard.sinch.com/convapi/overview) by accepting the corresponding terms and conditions. To start using the SDK, you need to initialize the main client class with your credentials from your Sinch [dashboard](https://dashboard.sinch.com). Note: For testing purposes on your local environment it's fine to use hardcoded values, but before deploying to production we strongly recommend using environment variables to store the credentials. ```cpp Initialize client using Sinch; var sinch = new SinchClient("YOUR_project_id", "YOUR_access_key", "YOUR_access_secret"); ``` You can also implement the client using ASP.NET dependency injection. `SinchClient` is thread safe, so it's fine to add it as a singleton: ```cpp Initialize client using dependency injection builder.Services.AddSingleton(x => new SinchClient( builder.Configuration["YOUR_project_id"], builder.Configuration["YOUR_access_key"], builder.Configuration["YOUR_access_secret"])); ``` #### Fill in remaining parameters Assign your values to the following parameters: table tr th Placeholder value th Your value tr td code YOUR_app_id td Find your app ID on your Sinch [dashboard](https://dashboard.sinch.com/convapi/apps). tr td code YOUR_channel td The channel you want to use to send the message. This guide presets this code channel property to code SMS , but you may update it to any channel that's already configured on your Conversation API app. You may add the following channels to your app from the [Sinch Build Dashboard](https://dashboard.sinch.com/settings/access-keys): ul li code SMS li code MESSENGER li code MMS li code RCS li code WHATSAPP li code VIBER li code VIBERBM li code INSTAGRAM li code TELEGRAM li code KAKAOTALK li code APPLEBC li code LINE li code WECHAT tr td code RECIPIENT_number td The channel identity of the recipient to which you want to send the message. When using the code SMS channel, this will be a phone number. tr td code YOUR_sms_sender td Your Sinch virtual phone number, available on the [Sinch Build Dashboard](https://dashboard.sinch.com/numbers/your-numbers). This is only required if you are using the code SMS channel. Ensure that you save the file. ### Build your project Before executing your code, you must first compile your application. Execute the following command: ```shell dotnet build ``` ## Send your first message Now you can execute the code and send your test message. Run the following command: ```shell dotnet run ``` You should receive a text to the phone number you entered and you'll see a response in your terminal or command prompt. Press `Enter` to exit the application. You did it! ## Next steps The code you used in the `Program.cs` file sends a POST request to the Sinch API `/Messages` endpoint to send the text message. Click [here to read more about the messages endpoint](/docs/conversation/api-reference/conversation/messages/). ## Additional resources - Explore the [API specification](/docs/conversation/api-reference/) to test more endpoints.