Python
This tutorial provides you with a step-by-step walkthrough of how to build a ‘Doctor’s Appointment App’ to send appointment reminders via SMS using Live Link 365.
This is not a production-ready application. Please take your time to enhance it for production so that it meets your specific business requirements.
The main panel on the right highlights the right piece of code for each step.Steps
Create the Python class for Doctor
using the doctorID
, doctorName
and specialization
:
- doctorID: Integer
- doctorName: String
- specialization: String
Create the Python class for Patient
using the patientID
and patientName
:
- patientID: Integer
- patientName: String
Create the Python class for Specialization
using the specializationID
and specializationName
:
- specializationID: Integer
- specializationName: String
Create the Python class for Appointment using the Doctor
, Patient
, Specialization
and Date
class objects
The config.ini file acts as a temporary storage for records and holds key information such as: patient’s name, doctor’s name, specialization, date, time, and so on.
The configuration file can be replaced by the database, which holds the employee information
This is the driver Python script which contains the main()
method. It reads the properties defined in the config.ini file.
Run this file using a Python interpreter
Before you can use the API for sending SMS, you have to fetch an authentication token, by providing:
- App key
- App secret
Please see this site's Authentication section for more info on app keys and secrets
ThegetAccessToken()
method will take the App Key and App Secret and combine them into a Base64 string, which will then be sent to the /api/oauth/token
endpoint for generating the authentication token
For sending the SMS we will make a method that will take 3 attributes:
- number: The number the SMS will be sent to
- message: The message that the destination phone number should receive
- token: The authentication token that will be generated with the method explained in the previous step
/api/v2/sms
endpoint, and we will call it for each new message we need to send
Now we finally call the main function, connecting the booking classes to the sending API. Replace in the configuration:
- appKey: An app key created for your application
- appSecret: An app secret created for your application
- destinationNumber: The phone number you want to send the message to
sendSMS()
method
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|