#NEWLINE# @ celery . task ( ) #NEWLINE# def send_sms_reminder( appointment_id ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# appointment = db . session . query ( Appointment ) . filter_by ( id = appointment_id ) . one ( ) #NEWLINE# #UNINDENT# except NoResultFound : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# time = arrow . get ( appointment . time ) . to ( body . timezone ) #NEWLINE# body = 'Hello {0}. You have an appointment at {1}!' . format ( appointment . name , time . format ( 'h:mm a' ) ) #NEWLINE# client . messages . create ( body = body , to = appointment . phone_number , from_ = twilio_number )