# Receive an incoming SMS Message Note: Before you can get started, you need the following already set up: - - [NPM](https://www.npmjs.com/) and a familiarity with how to install packages. - [Node.js](https://nodejs.org/en/) and a familiarity with how to create a new app. - [ngrok](https://ngrok.com/). You'll use ngrok to open a tunnel to your local server. Learn how to handle incoming SMS messages in a Node.js application with the Sinch Node.js SDK. Steps: 1. [Set up](#set-up-your-nodejs-application) your Node.js application 2. [Start](#start-your-web-server-and-set-up-a-tunnel) your web server and set up a tunnel 3. [Send](#send-your-sms-message) your SMS message ## Set up your Node.js application To quickly get started setting up a simple client application using the Node SDK: 1. If you haven't already, clone the [sinch-sdk-node-quickstart](https://github.com/sinch/sinch-sdk-node-quickstart) repository. 2. Navigate to the `getting-started/sms/respond-to-incoming-message/server` folder. 3. Open a command prompt or terminal and run the following command to install the necessary dependencies: ```shell npm install ``` 4. Open the `.env` [file](https://github.com/sinch/sinch-sdk-node-quickstart/blob/main/getting-started/sms/respond-to-incoming-message/server/.env). Using the [access key credentials](https://dashboard.sinch.com/settings/access-keys) from your Sinch Build Dashboard, add your values: | Field | Description | | --- | --- | | SINCH_PROJECT_ID | The unique ID of your Project. | | SINCH_KEY_ID | The unique ID of your access key. | | SINCH_KEY_SECRET | The secret that goes with your access key. **Note:** For security reasons, this secret is only visible right after access key creation. | | SMS_REGION | The region in which you are send and receiving SMS traffic. Use `us` for US traffic and `eu` for European traffic. | 5. Save the file. ## Start your web server and set up a tunnel 1. Start the server by executing the following command: ```shell npm start ``` 2. 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, install it with the following command: ```shell npm install ngrok -g ``` 3. Open a terminal or command prompt and enter: ```shell ngrok http 3001 ``` 4. You should see a screen in your console that shows the running tunnel. Copy the address ending in `.ngrok.io`. ### Configure your Callback URL 1. To configure a callback URL for your Sinch account, login to your [dashboard](https://dashboard.sinch.com/sms/api/rest). 2. Click on the service plan ID link and edit the Callback URL field with the ngrok.io domain URL from the previous section with `/SmsEvent` added to the end. The complete URL should look something like `https://3b58-75-118-121-186.ngrok-free.app/SmsEvent`. ## Send your SMS message Now send an SMS message to your Sinch number from your mobile phone and you will get an automatic reply. ## Next steps The code you used in the `serverBusinessLogic.js` file listens for a webhook sent from the Sinch servers and then sends a POST request to the Sinch API `/batches` endpoint to send the SMS message. - Explore the [API specification](/docs/sms/api-reference/) to test more endpoints. ## Additional resources - Click [here to learn more about the batches endpoint](/docs/sms/api-reference/sms/batches).