# Send a Conversation Message with the Sinch Node.js SDK Note: Before you can get started, you need the following already set up: - - [Node.js](https://nodejs.org/en/) and a familiarity with how to create a new app. Learn how to quickly send Conversation 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. [Send](#send-your-first-conversation-message) your first SMS message ## Set up your Node.js application First we'll create a Node project using npm. This creates a package.json and the core dependencies necessary to start coding. To create the project, do the following steps: 1. Create a folder called `send-conversation-app` 2. Navigate into the folder you created and run the following command. ```shell npm init ``` This command adds the package.json file. You will be prompted to provide values for the fields. For this tutorial, you can simply accept the default values and press enter at each stage. You can install the Sinch Node.js SDK using either [NPM](https://www.npmjs.com/) or [Yarn](https://yarnpkg.com/): NPM ```shell npm install @sinch/sdk-core ``` Yarn ```shell yarn add @sinch/sdk-core ``` Note: If you want to use the SDK with a javascript framework such as React or Angular, you can import it with an import statement. ```shell import {SinchClient} from `@sinch/sdk-core` ``` ### Create your file Create a new file named `index.js` in the project and paste the provided code into the file: index.js const { SinchClient } = require('@sinch/sdk-core'); const sinchClient = new SinchClient({ projectId: "YOUR_project_id", keyId: "YOUR_access_key", keySecret: "YOUR_access_secret" }); async function run(){ const response = await sinchClient.conversation.messages.send({ sendMessageRequestBody: { app_id: "YOUR_app_ID", recipient: { identified_by: { channel_identities: [ { channel: "SMS", identity: "RECIPIENT_number" } ] } }, message: { text_message: { text: "This is a test message using the Sinch Node.js SDK" } }, channel_properties: { SMS_SENDER: "YOUR_sms_sender" } } }); console.log(JSON.stringify(response)); } run(); ### Modify your application The code provided includes placeholder parameters. You'll need to update the parameters detailed in the following subsections with your values. Note: This sample code is configured for the US region. If your Conversation API app wasn't created in the US region, update you can set the region when you initialize the Sinch client: ```Javascript const sinchClient = new SinchClient({ projectId: "YOUR_project_id", keyId: "YOUR_access_key", keySecret: "YOUR_access_secret", region: Region.EUROPE }); ``` #### 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. #### 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. ## Send your first Conversation message Now you can execute the code and send your test Conversation message. Run the following command: ```shell node index.js ``` You should receive a text to the phone number you entered and you'll see a response in your terminal or command prompt. You did it! ## Next steps The code you used in the `index.js` file sends a POST request to the Sinch API [`/Messages` endpoint to send the text message](/docs/conversation/api-reference/conversation/messages/). ## Additional resources - Explore the [API specification](/docs/conversation/api-reference/) to test more endpoints.