def respond(
    intent_request, # NOSONAR this function needs to have 8 parameters
    message,
    fulfillment_state,
    dialog_action_type,
    confirmation_state=None,
    slots=None,
    slot_to_elicit=None,
    active_context=None,
):
    """
    Constructs a response object and sends response back to Amazon Lex.

    :param intent_request: Event object that was sent by Amazon Lex
    :param message: A string containing the custom message that you want Amazon Lex to show to the user
    :param fulfillment_state: A string indicating the intent's state in Amazon Lex. Acceptable values: Failed | Fulfilled | InProgress | ReadyForFulfillment
    :param dialog_action_type: A string indicating state of the dialog between user and Amazon Lex. Acceptable values: Close | ConfirmIntent | Delegate | ElicitIntent | ElicitSlot
    :param confirmation_state: (optional) A string indicating the intent's confirmation state in Amazon Lex. Acceptable values: Confirmed | Denied | None
    :param slots: (optional) slots object to include in the intent that is being sent to Amazon Lex.
    :param slot_to_elicit: (optional - required only when dialog_action_type=ElicitSlot) A string indicating the name of a slot that you want Amazon Lex to inquire from the user
    :param active_context: an object representing an active_context that you want Amazon Lex to remember during the dialog
    :returns: Constructed response object with compatible format to send to Amazon Lex.
    """
    intent = intent_request["sessionState"]["intent"]
    intent["state"] = fulfillment_state
    if confirmation_state != None:
        intent["confirmationState"] = confirmation_state
    if slots != None:
        intent["slots"] = slots
    response = {
        "sessionState": {
            "activeContexts": [active_context],
            "dialogAction": {
                "slotToElicit": slot_to_elicit,
                "type": dialog_action_type,
            },
            "intent": intent,
        },
        "messages": [
            {
                "contentType": "PlainText",
                "content": message,
            }
        ],
        "sessionId": intent_request["sessionId"],
        "requestAttributes": intent_request["requestAttributes"]
        if "requestAttributes" in intent_request
        else None,
    }
    if active_context == None:
        del response["sessionState"]["activeContexts"]
    return response