mardi 12 avril 2022

How to send the same word to each number using Twilio. I am importing random word from a text file to send to recipients

I am wanting to send the same random word from my text file to each recipient. Right now it sends a different random word to each phone number and I need it to be the same to all. I am using Twilio to send texts to numbers. Here is what I have tried below:

import os
from twilio.rest import Client
import random

# Open the file in read mode
with open("5words.txt", "r") as file:
    allText = file.read()
    word = list(map(str, allText.split()))

account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)
family = {'+123456789', '+123456789','123456789','123456789','123456987','123456789'}
for number in family:
    client.messages.create(
         body=('Your word of the day is ' + random.choice(word)),
         from_='+12345678',
         to=(number)
     )



Aucun commentaire:

Enregistrer un commentaire