def order_flowers(intent_request):
    """
    Performs dialog management and fulfillment for ordering flowers.
    Beyond fulfillment, the implementation of this intent demonstrates the use of the elicitSlot dialog action
    in slot validation and re-prompting.
    """

    flower_type = get_slots(intent_request)["FlowerType"]
    date = get_slots(intent_request)["PickupDate"]
    time = get_slots(intent_request)["PickupTime"]
    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 = get_slots(intent_request)

        validation_result = validate_order_flowers(flower_type, date, time)
        if not validation_result['isValid']:
            slots[validation_result['violatedSlot']] = None
            return 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 flower_type is not None:
            output_session_attributes['Price'] = len(flower_type) * 5  # Elegant pricing model

        return delegate(output_session_attributes, 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 close(intent_request['sessionAttributes'],
                 'Fulfilled',
                 {'contentType': 'PlainText',
                  'content': 'Thanks, your order for {} has been placed and will be ready for pickup by {} on {}'.format(flower_type, time, date)})
def order_flowers ( intent_request ) : flower_type = get_slots ( intent_request ) [ "FlowerType" ] date = get_slots ( intent_request ) [ "PickupDate" ] time = get_slots ( intent_request ) [ "PickupTime" ] source = intent_request [ 'invocationSource' ] if source == 'DialogCodeHook' : slots = get_slots ( intent_request ) validation_result = validate_order_flowers ( flower_type , date , time ) if not validation_result [ 'isValid' ] : slots [ validation_result [ 'violatedSlot' ] ] = None return elicit_slot ( intent_request [ 'sessionAttributes' ] , intent_request [ 'currentIntent' ] [ 'name' ] , slots , validation_result [ 'violatedSlot' ] , validation_result [ 'message' ] ) output_session_attributes = intent_request [ 'sessionAttributes' ] if flower_type is not None : output_session_attributes [ 'Price' ] = len ( flower_type ) * 5 return delegate ( output_session_attributes , get_slots ( intent_request ) ) return close ( intent_request [ 'sessionAttributes' ] , 'Fulfilled' , { 'contentType' : 'PlainText' , 'content' : 'Thanks, your order for {} has been placed and will be ready for pickup by {} on {}' . format ( flower_type , time , date ) } )
Performs dialog management and fulfillment for ordering flowers.
    Beyond fulfillment, the implementation of this intent demonstrates the use of the elicitSlot dialog action
    in slot validation and re-prompting.