This is a simple python script to automate airtime disbursal using google-forms, python and AfricasTalking
This is meant to be a proof of concept code not an exhaustive write-up on DIY airtime disbursal.
The First important part of the whole process is to create a Google Form. Visit this link and create a new form. The next step is to authenticate our Python Script and Local Environment with Google and access the Google Form Data from Google Drive by enabling the Google Drive API in Google Cloud Platform. Follow these steps:
1. Go to the Google Form
2. Responses Tab,
3. Click the spreadsheet icon
4. And create a new Destination Spreadsheet for our google form.
This Spreadsheet will be created and stored in Google Drive. We have to integrate Google Drive and Python Environment. First, we have to authenticate with Google.
Now, to work with Google Drive API, we have to set up our account, enable Google Drive API and obtain our client_secrets.json key. Since we are using the gspread library, find more instructions in the docs
- Python and pip (I am currently using 3.9.2) Any version above 3.5 should work.
- An Africas Talking account.
- Api Key and username from your account. Create an app and take note of the api key.
- Additionally, you will need to request them to enable airtime access for your account. Email their airtime team for further clarification. Check more information here
-
Clone the Repo
git clone https://github.com/KenMwaura1/Automated-Airtime-Disbursal
-
Create a virtual environment (venv)
python3 -m venv venv
-
Activate the virtual environment
source ./scripts/activate
If you are using pyenv
2a. Create a virtualenv
pyenv virtualenv airtime-disbursal
2b. Activate the virtualenv
pyenv activate airtime-disbursal
-
Change into the working folder.
cd Automated-Airtime-Disbursal
-
Create a
.env
file and add your credentialstouch .env
OR Copy the included example
cp .env-example .env
-
Add your credentials to the .env file
-
Install the required dependencies
pip install -r requirements
-
Edit the script. Change the
airtime_sheet_name
variable -
Run the script
python airtime_disbursal.py