First, we'll set up the project directory:
Navigate to the directory in which you'd like to store your project.
Create a folder called
sinch-user-consentand navigate into it.Create a file called
app.py.
Now, we'll install the prerequisites for your application.
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
python -m venv venvIn Linux you can create a virtual environment with the command
virtualenv --python python venvNow you need to activate the virtual environment.
In Windows, run the command:
venv\Scripts\activateIn Linux, the command is:
source venv/bin/activateNow that your virtual environment is activated, you can install the dependencies your application needs to function.
This is a Flask application so you need to install Flask. You can do this with pip.
pip install flaskTo effectively leverage Sinch SMS capability with Python, you need to install the SDK. You can do this with pip.
pip install sinchIf you successfully completed the Receive an SMS Message guide, you'll have used ngrok to set up a tunnel to your local server. Install ngrok with the command:
npm install ngrok -gIf you haven't already, set up a free account with ngrok. Now we've installed everything we need, we can start creating the application.
On the next page, you'll need to intialize the SDK.
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 <b>Access Keys</b> page of the Sinch Build Dashboard. You can also create new access key IDs and Secrets, if required.
If you have trouble accessing the above link, ensure that you have gained access to the Conversation API by accepting the corresponding terms and conditions.