File size: 500 Bytes
b407a42
9e0fc4a
b407a42
 
 
9e0fc4a
 
b407a42
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from twilio.rest import Client
from twilio.http.http_client import TwilioHttpClient
from app.core.config import settings

def send_sms_otp(phone: str, otp: str) -> str:
    http_client = TwilioHttpClient(timeout=10)  # 10 seconds timeout
    client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN, http_client=http_client)

    message = client.messages.create(
        from_=settings.TWILIO_SMS_FROM,
        body=f"Your OTP is {otp}",
        to=phone
    )

    return message.sid