How to Create a Reminder Application in Python Using Wbiztool’s Schedule API

Automating reminders for customers is a great way to improve engagement and keep your audience informed. In this tutorial, we’ll build a simple reminder application in Python that uses Wbiztool’s Schedule API to send automated WhatsApp messages. This guide will take you through each step to set up and schedule messages with Python.

Prerequisites

Before starting, make sure you have:

  • A Wbiztool account with API access.
  • Python is installed on your computer.
  • The requests library installed (pip install requests).

1. Setting Up Your Wbiztool API Key

First, sign in to your Wbiztool account and generate an API key from the dashboard. This key is necessary to authenticate your API requests.

2. Creating the Python Script for Scheduling Reminders

Create a new Python script (reminder_app.py) and import the requests library:

import requests
import json

# Replace these with your Wbiztool credentials
API_KEY = 'YOUR_API_KEY'
CLIENT_ID = 'YOUR_CLIENT_ID'
WHATSAPP_CLIENT = 'YOUR_WHATSAPP_CLIENT_ID'

def schedule_reminder(phone, country_code, message, schedule_time):
    url = "https://wbiztool.com/api/v1/schedule_msg/"
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    }
    payload = {
        "client_id": CLIENT_ID,
        "api_key": API_KEY,
        "whatsapp_client": WHATSAPP_CLIENT,
        "phone": phone,
        "country_code": country_code,
        "msg": message,
        "schedule_time": schedule_time  # Time in 'YYYY-MM-DD HH:MM:SS' format
    }

    response = requests.post(url, headers=headers, data=json.dumps(payload))

    if response.status_code == 200:
        print("Reminder scheduled successfully!")
    else:
        print(f"Failed to schedule reminder. Status Code: {response.status_code}, Response: {response.text}")

# Example usage
schedule_reminder('1234567890', '91', 'This is your reminder message!', '2024-10-01 10:00:00')

3. Explanation of the Script

  • API Key and Credentials: Replace 'YOUR_API_KEY', 'YOUR_CLIENT_ID', and 'YOUR_WHATSAPP_CLIENT_ID' with your actual Wbiztool credentials.
  • Function Definition: The schedule_reminder function takes four parameters: phone, country_code, message, and schedule_time.
  • Payload: Prepares the JSON payload containing the phone number, country code, message, and scheduled time in the required format.
  • Sending Request: Uses the requests library to send a POST request to the Wbiztool Schedule API endpoint.
  • Response Handling: Checks if the reminder was scheduled successfully and prints the appropriate message.

4. Running the Script

Run the script using Python:

python reminder_app.py

If everything is set up correctly, you should see a message confirming the reminder was scheduled successfully.

Tips for Enhancing the Application

  • User Input: Extend the script to dynamically accept user input for scheduling messages.
  • Recurring Reminders: Implement logic to schedule recurring reminders by modifying the schedule_time.
  • Error Handling: Add more robust error handling for different response codes from the API.

Conclusion

With Wbiztool’s Schedule API, automating reminders in Python is straightforward. Setting up this simple script can enhance customer engagement with timely WhatsApp messages, improving your business operations.

For more details, refer to Wbiztool’s Schedule Message API Documentation.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top