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 message with the Sinch Python SDK Note: Before you can get started, you need to do the following: - - [Python](https://www.python.org/) and a familiarity with how to create a new app. - [PIP (package installer for Python)](https://pypi.org/project/pip/) and a familiarity with how to install Python modules. Using the Conversation API, you can send messages to any channel you have configured. This tutorial shows you how to set up and send a message in a Python application. Steps: 1. [Install](#installing-the-sdk) the Sinch Python SDK. 2. [Set up](#set-up-your-python-application) your Python application 3. [Send](#send-your-first-message) your first message ## Installing the SDK The easiest way to install the SDK is using [`pip`](https://pypi.org/project/pip/): 1. Open a command prompt or terminal to the local repository folder. 2. Execute the following command: ```shell pip install sinch ``` ## Set up your Python application Now you can start setting up 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). ### Create your file Create a new file named `send-message.py` and paste the provided "send-message.py" code found on this page into the file. This code sends a [text message](/docs/conversation/message-types/text-message/). send-message.py from sinch import SinchClient sinch_client = SinchClient( key_id="YOUR_key_id", key_secret="YOUR_key_secret", project_id="YOUR_project_id" ) # conversation_region must be set to either us or eu sinch_client.configuration.conversation_region="us" send_conversation_api_message_response = sinch_client.conversation.message.send( app_id="YOUR_app_id", recipient={ "identified_by" : { "channel_identities" : [ {"identity":"RECIPIENT_number","channel" : "SMS"} ] } }, message={ "text_message" : { "text" : "Text message from Sinch Conversation API." } }, channel_properties={ "SMS_SENDER" : "YOUR_sms_sender" } ) print(send_conversation_api_message_response) Note: This sample code is configured for the US region. If your Conversation API app wasn't created in the US region, update `sinch_client.configuration.conversation_region` to `eu`. ### 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. #### 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 message Now you can execute the code and send your test message. Open a command prompt or terminal to the location where your Python file is saved and run the following command: ```shell python send-message.py ``` You should receive a message in your configured messaging platform. ## Additional resources Read the links below to learn more: - [Learn more about different message types](/docs/conversation/message-types) - [Learn more about channels](/docs/conversation/channel-support) - [API specification](/docs/conversation/api-reference/)