Your sms() function is being called when you create the SMS state, not when the state is executed, so that is definitely going to fail.