Ejemplo n.º 1
0
def get_comp(intent_request, key):
    """
    Performs dialog management and fulfillment for getting phone number.
    Beyond fulfillment, the implementation of this intent demonstrates the use of the elicitSlot dialog action
    in slot validation and re-prompting.
    """

    app_purpose = response.get_slots(intent_request)['rcomplaint']
    app_name = response.get_slots(intent_request)['rname']
    app_email = response.get_slots(intent_request)['remail']
    source = intent_request['invocationSource']

    if source == 'DialogCodeHook':
        slots = response.get_slots(intent_request)

        output_session_attributes = intent_request[
            'sessionAttributes'] if intent_request[
                'sessionAttributes'] is not None else {}
        if app_purpose is not None and app_name is not None and app_email is not None:

            memail = db_handlerapp(key)

            output_session_attributes[
                'app_state'] = "added to bot"  # Elegant pricing model

        return response.delegate(output_session_attributes,
                                 response.get_slots(intent_request))

    # Order the flowers, and rely on the goodbye message of the bot to define the message to the end user.
    # In a real bot, this would likely involve a call to a backend service.
    return response.close(
        intent_request['sessionAttributes'], 'Fulfilled', {
            'contentType': 'PlainText',
            'content': 'Complaint Registered and confirmation Email Sent'
        })
Ejemplo n.º 2
0
def get_number(intent_request):
    """
    Performs dialog management and fulfillment for getting phone number.
    Beyond fulfillment, the implementation of this intent demonstrates the use of the elicitSlot dialog action
    in slot validation and re-prompting.
    """

    login_id = response.get_slots(intent_request)["loginId"]
    source = intent_request['invocationSource']

    if source == 'DialogCodeHook':
        # Perform basic validation on the supplied input slots.
        # Use the elicitSlot dialog action to re-prompt for the first violation detected.
        slots = response.get_slots(intent_request)

        validation_result = validate_idnum(login_id)
        if not validation_result['isValid']:
            slots[validation_result['violatedSlot']] = None
            return response.elicit_slot(
                intent_request['sessionAttributes'],
                intent_request['currentIntent']['name'], slots,
                validation_result['violatedSlot'],
                validation_result['message'])

        # Pass the price of the flowers back through session attributes to be used in various prompts defined
        # on the bot model.
        output_session_attributes = intent_request[
            'sessionAttributes'] if intent_request[
                'sessionAttributes'] is not None else {}
        if login_id is not None:
            global key_id
            val = db_handler(login_id)

            if val > 0:
                key_id = str(login_id)
                stateof = 'logged in'
            else:
                stateof = 'no such account'
                val = 'not logged in'
            output_session_attributes[
                'Number'] = stateof  # Elegant pricing model

        return response.delegate(output_session_attributes,
                                 response.get_slots(intent_request))

    # Order the flowers, and rely on the goodbye message of the bot to define the message to the end user.
    # In a real bot, this would likely involve a call to a backend service.

    return response.close(intent_request['sessionAttributes'], 'Fulfilled', {
        'contentType': 'PlainText',
        'content': 'Welcome to Lex chatbot'
    })
Ejemplo n.º 3
0
def get_time(intent_request, key):
    """
    Performs dialog management and fulfillment for getting phone number.
    Beyond fulfillment, the implementation of this intent demonstrates the use of the elicitSlot dialog action
    in slot validation and re-prompting.
    """

    open_time = response.get_slots(intent_request)['openTime']
    close_time = response.get_slots(intent_request)['closeTime']
    source = intent_request['invocationSource']

    if source == 'DialogCodeHook':
        slots = response.get_slots(intent_request)

        validation_result = validate_time(open_time, close_time)
        if not validation_result['isValid']:
            slots[validation_result['violatedSlot']] = None
            return response.elicit_slot(
                intent_request['sessionAttributes'],
                intent_request['currentIntent']['name'], slots,
                validation_result['violatedSlot'],
                validation_result['message'])

        # Pass the price of the flowers back through session attributes to be used in various prompts defined
        # on the bot model.
        output_session_attributes = intent_request[
            'sessionAttributes'] if intent_request[
                'sessionAttributes'] is not None else {}
        if open_time is not None and close_time is not None:

            #val=str(app_state)
            db_handlertime(open_time, close_time, key)
            output_session_attributes[
                'time'] = "added to bot open"  # Elegant pricing model

        return response.delegate(output_session_attributes,
                                 response.get_slots(intent_request))

    # Order the flowers, and rely on the goodbye message of the bot to define the message to the end user.
    # In a real bot, this would likely involve a call to a backend service.
    return response.close(intent_request['sessionAttributes'], 'Fulfilled', {
        'contentType': 'PlainText',
        'content': 'Contact Time Updated'
    })
Ejemplo n.º 4
0
def get_job(intent_request, key):

    source = intent_request['invocationSource']
    if source == 'DialogCodeHook':

        output_session_attributes = intent_request[
            'sessionAttributes'] if intent_request[
                'sessionAttributes'] is not None else {}

        ad = db_handlerjob(key)
        output_session_attributes['buss_addre'] = ad  # Elegant pricing model

        return response.delegate(output_session_attributes,
                                 response.get_slots(intent_request))

    # Order the flowers, and rely on the goodbye message of the bot to define the message to the end user.
    # In a real bot, this would likely involve a call to a backend service.
    return response.close(intent_request['sessionAttributes'], 'Fulfilled', {
        'contentType': 'PlainText',
        'content': 'Shared Jobs'
    })