MR-Tajeddin / PYTHON

1 stars 0 forks source link

Telegram Message #2

Open MR-Tajeddin opened 1 year ago

MR-Tajeddin commented 1 year ago

Send a message to a phone number excel list

import pandas as pd from twilio.rest import Client

Load phone numbers from Excel file

df = pd.read_excel('phone_numbers.xlsx')

Twilio account SID and auth token

account_sid = 'YOUR_ACCOUNT_SID' auth_token = 'YOUR_AUTH_TOKEN'

Twilio phone number to send the message from

from_number = 'YOUR_TWILIO_PHONE_NUMBER'

Loop through each phone number and send a message

for index, row in df.iterrows(): to_number = str(row['Phone']) message_body = 'Hello, this is a test message!'

client = Client(account_sid, auth_token)

message = client.messages.create(
    body=message_body,
    from_=from_number,
    to=to_number
)

print(f"Message sent to {to_number} with message ID {message.sid}")