(domain, contact, phone_number, app, form,
        case_id, keyword, logged_subevent=None)
Returns (session, responses, error, error_code)
Returns (session, responses, error, error_code)
Returns ( session responses error error_code )
def start_session_for_structured_sms(domain, contact, phone_number, app, form,
        case_id, keyword, logged_subevent=None):
    """
    Returns (session, responses, error, error_code)
    """
    try:
        session, responses = start_session(
            SQLXFormsSession.create_session_object(
                domain,
                contact,
                phone_number.phone_number,
                app,
                form,
                expire_after=0,
            ),
            domain,
            contact,
            app,
            form,
            case_id=case_id,
            yield_responses=True
        )
        if logged_subevent:
            logged_subevent.xforms_session_id = session.pk
            logged_subevent.save()
        return (session, responses, False, None)
    except TouchformsError as e:
        human_readable_message = get_formplayer_exception(domain, e)
        logged_subevent.error(MessagingEvent.ERROR_TOUCHFORMS_ERROR,
            additional_error_text=human_readable_message)

        if touchforms_error_is_config_error(domain, e):
            error_code = MSG_FORM_ERROR
        else:
            notify_exception(None, message=('Could not process structured sms for'
                'contact %s, domain %s, keyword %s' % (contact.get_id, domain, keyword)))
            error_code = MSG_TOUCHFORMS_ERROR

        return (None, None, True, error_code)
def start_session_for_structured_sms ( domain , contact , phone_number , app , form , case_id , keyword , logged_subevent = None ) : try : session , responses = start_session ( SQLXFormsSession . create_session_object ( domain , contact , phone_number . phone_number , app , form , expire_after = 0 , ) , domain , contact , app , form , case_id = case_id , yield_responses = True ) if logged_subevent : logged_subevent . xforms_session_id = session . pk logged_subevent . save ( ) return ( session , responses , False , None ) except TouchformsError as e : human_readable_message = get_formplayer_exception ( domain , e ) logged_subevent . error ( MessagingEvent . ERROR_TOUCHFORMS_ERROR , additional_error_text = human_readable_message ) if touchforms_error_is_config_error ( domain , e ) : error_code = MSG_FORM_ERROR else : notify_exception ( None , message = ( 'Could not process structured sms for' 'contact %s, domain %s, keyword %s' % ( contact . get_id , domain , keyword ) ) ) error_code = MSG_TOUCHFORMS_ERROR return ( None , None , True , error_code )