Member-only story
Happy New Year on WhatsApp using Python
2 min readJan 1, 2025
Importing Required Libraries
import pywhatkit as kit
import datetime
pywhatkit
: A Python library that automates tasks like sending WhatsApp messages, searching on Google, and more.datetime
: A built-in Python module used to work with date and time.
2. Getting the Current Time
now = datetime.datetime.now()
datetime.datetime.now()
retrieves the current date and time.- The
now
variable stores this value, which is used to schedule the message.
Defining the Recipient’s Phone Number
phone_number = "+919767292502"
- The phone number of the recipient is stored in the
phone_number
variable. - Note: The phone number must include the country code (e.g.,
+91
for India).
Writing the Message
message = (
"🎉🎊 Happy New Year! 🎉🎊\n"
"Wishing you a year full of joy, "
"health, and success! 🥳"
)
- The
message
variable stores the text to be sent. - A multi-line string is used for better readability.
- The newline character
\n
creates a line…