# Creating an appointment reminder app with Python SDK ## Creating the project structure We're going to create the project folder and add a simple directory structure. 1. Navigate to the directory in which you'd like to store your project. 2. Create a folder called `sinch-appointment-reminder` and navigate into it. 3. Create the following directory structure: ```shell sinch-appointment-reminder │ .env │ appointment_server.py │ ├───static │ style.css │ └───templates patient_details.html success.html ``` As you complete the tutorial, you'll learn what each of the files and folders does. ## Environment Setup We'll now install the prerequisites for the application. ### Creating a Python virtual environment Open a terminal or command prompt and navigate into the project folder you created. Here, you will create a virtual environment called `venv`. You don't need to do this, but it is recommended. Python virtual environments function as sandboxes, allowing you to install application specific packages without installing them globally. In Windows and Mac you can create a virtual environment with the command ```shell python -m venv venv ``` In Linux you can create a virtual environment with the command ```shell virtualenv --python python venv ``` Now you need to activate the virtual environment. In Windows, run the command: ```shell venv\Scripts\activate ``` In Linux, the command is: ```shell source venv/bin/activate ``` Now that your virtual environment is activated, you can install the dependencies your application needs to function. ### Installing Flask This is a Flask application so you need to install Flask. You can do this with pip. ```shell pip install flask ``` ### Installing Python-dotenv We'll be loading environment variables, so you need to install Python-dotenv. You can do this with pip. ```plaintext pip install python-dotenv ``` ### Installing the SDK To effectively leverage Sinch SMS capability with Python, you need to install the SDK. You can do this with pip. ```shell pip install sinch ``` ### Client information 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). ### Adding the environment variables Your app stores information, such as your Sinch credentials, as environment variables in the `.env` file. This is much more flexible and secure than simply hardcoding them. 1. Open the `.env` file. 2. Paste the following text into the `.env` file: ```.plaintext KEY_ID='YOUR_key_id' KEY_SECRET='YOUR_key_secret' PROJECT_ID='YOUR_project_id' DEBUG=True COUNTRY_CODE_EU='YOUR_EU_country_code' COUNTRY_CODE_US='+1' FROM_NUMBER='YOUR_sinch_number' SMS_REGION='YOUR_sms_region(us/eu)' ``` 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. | | `DEBUG` | Set to `True` to enable debugging. | | `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`. | br br