# Handle an incoming message Note: Before you can get started, you need to do the following: - - [The latest version of .Net Core with **Long Term Support**](https://dotnet.microsoft.com/download) and a familiarity with how to create a new MVC application. - [ngrok](https://ngrok.com/). You'll use ngrok to open a tunnel to your local server. Using the Conversation API, you can receive and respond to messages from any channel you have configured. This tutorial shows you how to set up a .Net Core MVC application that receives and responds to messages. Note: This tutorial is easier to accomplish if you have already completed the steps for [Sending a message](/docs/conversation/getting-started/csharp/send-message). Steps: 1. [Set up](#set-up-your-net-core-application) your .Net Core application 2. [Configure](#configure-your-webhook) your Conversation API webhook 3. [Test](#test-the-application) the application ## Set up your .Net Core application 1. Create a new folder where you want to keep your app project. Then, open a command prompt to that location. 2. Create a new .Net Core MVC app with the following command: ```shell dotnet new mvc ``` 3. Add the `Newtonsoft.Json` NuGet package. ```shell dotnet add package Newtonsoft.Json ``` ### Modify your application Note: This tutorial uses basic authentication for testing purposes. We recommend OAuth 2.0 authentication in a production environment. Read more about [authentication methods](/docs/conversation/api-reference/#authentication). 1. In the Controllers folder of your project, create a new file named `IncomingController.cs`. Populate that file with the provided "IncomingController.cs" code found on this page. This code starts a server that listens for incoming messages. It then sends a [text message](/docs/conversation/message-types/text-message/) in response. 2. Assign your values to the following parameters: ParameterYour valueAccess_KeyFind your access key on your Sinch [dashboard](https://dashboard.sinch.com/settings/access-keys).Access_Secret Find your access secret on your Sinch [dashboard](https://dashboard.sinch.com/settings/access-keys).Note:Access secrets are only available during initial key creation. 3. Save the file. 4. Compile your application by executing the following command: ```shell dotnet build ``` ### Start your web server and set up a tunnel 1. Start the server by executing the following command: ```shell dotnet run ``` By default, your web server is started on port 5001. 2. Now you need to open a tunnel to the server you just set up. We are using [ngrok](https://ngrok.com/) for this. if you don't have ngrok installed already you can install it with the following command: ```shell npm install ngrok -g ``` 3. Open a terminal or command prompt and enter: ```shell ngrok http https://localhost:5001 ``` 4. Copy the HTTPS address that ends with .ngrok.io and add `/Incoming/ReceiveMessage` to the end of it. ## Configure your webhook For your application to receive messages from Conversation API, you must configure a webhook in your Conversation API app. For detailed instructions on configuring a webhook, click [here](https://community.sinch.com/t5/Conversation-API/How-to-add-a-webhook-to-a-Conversation-API-app/ta-p/8100). 1. Set your webhook URL to the HTTP address you copied in the previous step. 2. Assign the following triggers: - `CONVERSATION_START` - `CONVERSATION_STOP` - `EVENT_DELIVERY` - `EVENT_INBOUND` - `MESSAGE_DELIVERY` - `MESSAGE_INBOUND` - `UNSUPPORTED` ## Test the application Now that your server is running and your webhook is configured, you can test the application. From your messaging platform, send your Conversation API app a message. You will receive a message back in response on the messaging platform. ## Additional resources Read the links below to learn more: - [Learn more about the `/messages` endpoint](/docs/conversation/api-reference/conversation/messages/) - [Learn more about different message types](/docs/conversation/message-types) - [Learn more about channels](/docs/conversation/channel-support) - [API specification](/docs/conversation/api-reference/)