Search code examples
pythonsmsresponsetwiliostatus

Can't get status of sms from Twilio


I had some issue when works with Twilio API. I tried to get sms status as is delivered, queue, failed or another, but I couldn't find this method at Rest API.

I use Python and Django.

def send_sms(self, msg):
    ACCOUNT_SID = self.profile.twilio_sid
    AUTH_TOKEN = self.profile.twilio_auth_token
    client_phone_number = self.profile.phone_number
    twilio_phone_number = "+1"+str(self.profile.twilio_number)
    client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
    message = client.messages.create(
        body=msg,
        to=client_phone_number,
        from_=twilio_phone_number,
    )
    sid = message.sid

So how can I get sms status with sid what i have? Without response processing if it is possible

I found answer. All what I need is added to my code

body  = client.messages.get(sid)
status =body.status  

Solution

  • I found answer. All what I need is added to my code

    body  = client.messages.get(sid)
    status = body.status