File: //home/arjun/projects/unlimited-leads/Unlimited-Leads-Be/services/twilio_service.py
import logging
from twilio.rest import Client
from django.conf import settings
logger = logging.getLogger(__name__)
class TwilioService:
def __init__(self):
self.client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
self.twilio_phone_number = settings.TWILIO_MY_PHONE_NUMBER
def send_sms(self, to, message):
try:
message = self.client.messages.create(
body=message, from_=self.twilio_phone_number, to=to
)
return message.sid
except Exception:
logger.exception("Failed to send SMS using TwilioService")
return None