# Creating an appointment reminder app with .NET SDK ## Set up your .NET application 1. Navigate to the directory in which you'd like to store your app project. 2. Create a new folder called `sinch_appointment_reminder`. 3. Open a terminal or command prompt to that location. 4. Create a new .NET MVC app with the following command: ```shell dotnet new mvc ``` ### Installing the SDK The easiest way to install the SDK is using the [`dotnet` CLI](https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net70): 1. Open a command prompt or terminal to the local repository folder. 2. Execute the following command: ```shell dotnet add package Sinch ``` ### Client information When using the SDK, you must 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. You'll add these values to the file described in the next section (along with others). #### Setting the environment variables Your app stores information such as your Sinch credentials as key-value pairs in the `appsettings.Development.json` file. This is much more flexible and secure than simply hardcoding them. br To set up your `appsettings.Development.json` file: 1. Open the `appsettings.Development.json` file. 2. Paste the following JSON body into your `appsettings.Development.json` file. ```json "Sinch":{ "key_id":"", "key_secret":"", "project_id":"", "country_code_eu": "", "country_code_us": "", "from_number": "", "sms_region":"" }, ``` 3. Populate the fields in the file with your own values. Refer to the table below for guidance: | Field | Description | | --- | --- | | `key_id` | Your access key ID, used for authentication. Refer to the [Client information](#client-information) section for more information. | | `key_secret` | Your access key secret, used for authentication. Refer to the [Client information](#client-information) section for more information. | | `project_id` | Your project ID. Refer to the [Client information](#client-information) section for more information. | | `country_code_eu` | If you live in the EU or UK, this is the country code of your home country. For example the UK country code is `+44`. | | `country_code_us` | If you live in the US, this is the country code of your home country. For the US, it's `+1`. | | `from_number` | Any number you've assigned to your Sinch account. Find the number on your Customer [Dashboard](https://dashboard.sinch.com/sms/api/rest) by clicking the service plan ID link and scrolling to the bottom of the page. | | `sms_region` | The region in which you would like to send SMS messages. Either `us` or `eu`. | ### Modifying the `Program.cs` file In .NET, `Program.cs` has the job of setting your application up and running it. The dependencies your application needs are created as *services*. These services will be fed into a Controller using *Dependency Injection*. The SDK client is initialized and added to Services as a *singleton*, meaning there can only be one instance of it. br Open `Program.cs` and replace the contents with the following code: ```csharp using Sinch; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); builder.Services .AddMvc(); builder.Services.AddSingleton(_ => new SinchClient( builder.Configuration["Sinch:project_id"], builder.Configuration["Sinch:key_id"], builder.Configuration["Sinch:key_secret"], // ensure you set the SMS region. options => { options.SmsRegion = Sinch.SMS.SmsRegion.Us; options.LoggerFactory = LoggerFactory.Create(config => { config.AddConsole(); }); options.HttpClient = new HttpClient(); })); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run(); ```