Skip to content

Question & Answer

Use Nova reasoning models to provide comprehensive answers to complex questions using provided context.

System Prompt Template

  You are an expert {domain} analyst who provides accurate, comprehensive answers about {topic}.
  Use the provided context to answer questions thoroughly and cite relevant information from the source material.

User Prompt Template

  ## Context ##
  {relevant context/documents}

  ## Question ##
  {specific question}

  Ask clarifying questions if needed.

Example

Amazon Nova 2 Lite System Prompt

  You are an expert software engineer who analyzes application logs to diagnose issues and provide solutions.
  Use the provided log data to answer questions thoroughly and cite relevant information from the logs.

Amazon Nova 2 Lite User Prompt

  ## Context ##
  **Application Debug Logs - E-commerce Checkout Flow**

  ```
  2024-11-22 10:15:23 [INFO] User session started: user_id=12345, session_id=abc-def-789
  2024-11-22 10:15:24 [INFO] User navigated to product page: product_id=SKU-001, category=electronics
  2024-11-22 10:15:45 [INFO] Product added to cart: product_id=SKU-001, quantity=2, price=299.99
  2024-11-22 10:16:12 [INFO] User navigated to cart page
  2024-11-22 10:16:15 [INFO] Cart validation successful: total_items=2, subtotal=599.98
  2024-11-22 10:16:18 [INFO] User clicked checkout button
  2024-11-22 10:16:19 [INFO] Checkout process initiated: user_id=12345
  2024-11-22 10:16:20 [INFO] Loading shipping addresses for user_id=12345
  2024-11-22 10:16:21 [INFO] Found 2 saved addresses for user
  2024-11-22 10:16:25 [INFO] User selected shipping address: address_id=addr_456
  2024-11-22 10:16:30 [INFO] Calculating shipping costs for zip_code=90210
  2024-11-22 10:16:31 [INFO] Shipping cost calculated: standard=$9.99, express=$19.99
  2024-11-22 10:16:35 [INFO] User selected standard shipping
  2024-11-22 10:16:40 [INFO] Proceeding to payment step
  2024-11-22 10:16:41 [INFO] Loading saved payment methods for user_id=12345
  2024-11-22 10:16:42 [WARN] No saved payment methods found for user
  2024-11-22 10:16:45 [INFO] User entered new credit card details
  2024-11-22 10:16:46 [INFO] Validating credit card number: ****1234
  2024-11-22 10:16:47 [ERROR] Credit card validation failed: invalid_luhn_checksum
  2024-11-22 10:16:47 [INFO] Displaying error message to user: "Please check your card number"
  2024-11-22 10:17:02 [INFO] User re-entered credit card details
  2024-11-22 10:17:03 [INFO] Validating credit card number: ****5678
  2024-11-22 10:17:04 [INFO] Credit card validation successful
  2024-11-22 10:17:05 [INFO] Validating expiration date: 12/2027
  2024-11-22 10:17:06 [INFO] Expiration date validation successful
  2024-11-22 10:17:07 [INFO] Validating CVV code
  2024-11-22 10:17:08 [INFO] CVV validation successful
  2024-11-22 10:17:10 [INFO] Processing payment authorization
  2024-11-22 10:17:12 [INFO] Contacting payment gateway: gateway=stripe
  2024-11-22 10:17:15 [INFO] Payment gateway response: status=success, auth_code=AUTH123456
  2024-11-22 10:17:16 [INFO] Payment authorized successfully: amount=$609.97
  2024-11-22 10:17:17 [INFO] Creating order record in database
  2024-11-22 10:17:18 [INFO] Order created: order_id=ORD-789123, status=confirmed
  2024-11-22 10:17:19 [INFO] Sending confirmation email to: user@example.com
  2024-11-22 10:17:20 [INFO] Email sent successfully
  2024-11-22 10:17:21 [INFO] Clearing user cart
  2024-11-22 10:17:22 [INFO] Cart cleared successfully
  2024-11-22 10:17:23 [INFO] Redirecting user to order confirmation page
  2024-11-22 10:17:24 [INFO] Order confirmation page loaded: order_id=ORD-789123
  ```

  ## Question ##
  The user reported that their checkout process failed and they couldn't complete their purchase. Based on these logs, what actually happened during their checkout experience? Was there really a failure, and if so, what caused it and how was it resolved?

  Ask clarifying questions if needed.

Amazon Nova 2 Lite Sample Response

Response

Analysis of the Checkout Process Based on Logs

Based on the provided logs, here's a detailed breakdown of what actually happened during the user's checkout experience:


โœ… Was There a Failure?

No, ultimately there was no failure. The user successfully completed their purchase and their order was confirmed. The logs show a complete, successful checkout flow from start to finish.

However, there was a temporary issue during the payment step that could have been perceived as a failure by the user โ€” specifically, the first credit card number entered failed validation due to an invalid Luhn checksum.


๐Ÿ” Step-by-Step Breakdown of the Checkout Flow

1. Session & Navigation

  • 10:15:23 โ€“ User session started (user_id=12345)
  • 10:15:24 โ€“ User navigated to product page (SKU-001, electronics)
  • 10:15:45 โ€“ Product added to cart (2 units of SKU-001 at $299.99 each = $599.98)
  • 10:16:12 โ€“ User navigated to cart page
  • 10:16:15 โ€“ Cart validation passed (2 items, subtotal $599.98)

2. Checkout Initiation

  • 10:16:18 โ€“ User clicked checkout
  • 10:16:19 โ€“ Checkout process initiated
  • 10:16:20โ€“10:16:35 โ€“ Shipping address selected (addr_456) and shipping method chosen (standard shipping $9.99)

3. Payment Step โ€“ First Attempt (Failed)

  • 10:16:40 โ€“ User proceeds to payment step
  • 10:16:41 โ€“ System checks for saved payment methods โ†’ none found (warn level)
  • 10:16:45 โ€“ User enters new credit card details
  • 10:16:46โ€“10:16:47 โ€“ System validates card:
  • 10:16:47 [ERROR] โ€“ Credit card validation failed: invalid_luhn_checksum
  • 10:16:47 [INFO] โ€“ Error message shown to user: "Please check your card number"

๐Ÿ”ด This is the point where the user likely thought the checkout failed.
The card number entered did not pass the Luhn algorithm check, which is a basic mathematical check for valid credit card numbers.

4. Payment Step โ€“ Second Attempt (Successful)

  • 10:17:02 โ€“ User re-entered credit card details
  • 10:17:03โ€“10:17:08 โ€“ Full validation performed:
  • Card number validated successfully (****5678)
  • Expiration date (12/2027) validated successfully
  • CVV validated successfully
  • 10:17:10 โ€“ Payment authorization initiated
  • 10:17:12 โ€“ Contacted payment gateway (Stripe)
  • 10:17:15 โ€“ Gateway response: status=success, auth_code=AUTH123456
  • 10:17:16 โ€“ Payment authorized: $609.97 (including shipping)

5. Order Confirmation

  • 10:17:17 โ€“ Order record created in database
  • 10:17:18 โ€“ Order created: ORD-789123, status=confirmed
  • 10:17:19 โ€“ Confirmation email sent to user@example.com
  • 10:17:20 โ€“ Email sent successfully
  • 10:17:21 โ€“ Cart cleared
  • 10:17:23 โ€“ User redirected to order confirmation page
  • 10:17:24 โ€“ Order confirmation page loaded successfully

๐Ÿงพ Summary of What Happened

Step Event Outcome
Cart โ†’ Checkout User added item and started checkout โœ… Successful
Shipping Selected address and shipping method โœ… Successful
Payment โ€“ First Try Entered invalid card number โŒ Failed (Luhn check)
Payment โ€“ Second Try Re-entered correct card details โœ… Successful
Order Creation Order record created, email sent, cart cleared โœ… Successful
Confirmation User redirected to confirmation page โœ… Successful

๐Ÿ“Œ Root Cause of the Perceived Failure

  • The first credit card number entered failed the Luhn algorithm check, which is a standard validation for credit card numbers.
  • This caused an error message to be shown to the user: "Please check your card number".
  • The user correctly interpreted this as a problem and re-entered the card details, which then passed all validations.

โœ… Resolution

  • The user successfully completed the checkout on the second attempt.
  • The system handled the error gracefully by:
  • Providing a clear error message
  • Allowing the user to correct the input
  • Proceeding normally once valid details were provided

๐Ÿ› ๏ธ Recommendations for Improvement

  1. Improve Error Messaging:
  2. Instead of a generic "Please check your card number", consider specifying that the number failed a Luhn check or was invalid format. This helps users understand what went wrong.

  3. Real-Time Card Validation:

  4. Provide instant feedback as the user types the card number (e.g., via JavaScript Luhn check on the frontend) to prevent submission of invalid numbers.

  5. Saved Payment Methods:

  6. The log shows [WARN] No saved payment methods found. Encouraging users to save payment methods could reduce friction in future checkouts.

  7. Payment Gateway Fallback:

  8. If one card fails, automatically prompt for a new card without requiring a full page reload โ€” improves UX.

๐Ÿงฉ Clarifying Questions (if needed)

If you want to dig deeper, you might ask:

  1. Was the user able to complete the purchase after the second attempt?
    โ†’ Yes, per logs โ€” order confirmed and email sent.

  2. Did the user contact support about this issue?
    โ†’ Not shown in logs โ€” would help assess user impact.

  3. Is the Luhn check performed on the frontend or backend?
    โ†’ Logs show backend validation โ€” could be moved to frontend for better UX.

  4. Are there any patterns of invalid card entries from other users?
    โ†’ Would help determine if this is a common friction point.


โœ… Final Answer:

The user did not experience a real failure in their checkout process. While the first credit card number entered failed validation due to an invalid Luhn checksum, the user successfully completed the purchase on the second attempt. The system correctly identified the issue, displayed an appropriate error message, and allowed the user to correct the input. The entire checkout flow โ€” including payment authorization, order creation, email confirmation, and cart clearing โ€” completed successfully.

API Request

import boto3
import json

# Initialize the Bedrock Runtime client
bedrock_runtime = boto3.client('bedrock-runtime', region_name='us-west-2')

# Define the system prompt
system_prompt = """You are an expert software engineer who analyzes application logs to diagnose issues and provide solutions.
  Use the provided log data to answer questions thoroughly and cite relevant information from the logs."""

# Define the user prompt
user_prompt = """## Context ##
  **Application Debug Logs - E-commerce Checkout Flow**

  ```
  2024-11-22 10:15:23 [INFO] User session started: user_id=12345, session_id=abc-def-789
  2024-11-22 10:15:24 [INFO] User navigated to product page: product_id=SKU-001, category=electronics
  2024-11-22 10:15:45 [INFO] Product added to cart: product_id=SKU-001, quantity=2, price=299.99
  2024-11-22 10:16:12 [INFO] User navigated to cart page
  2024-11-22 10:16:15 [INFO] Cart validation successful: total_items=2, subtotal=599.98
  2024-11-22 10:16:18 [INFO] User clicked checkout button
  2024-11-22 10:16:19 [INFO] Checkout process initiated: user_id=12345
  2024-11-22 10:16:20 [INFO] Loading shipping addresses for user_id=12345
  2024-11-22 10:16:21 [INFO] Found 2 saved addresses for user
  2024-11-22 10:16:25 [INFO] User selected shipping address: address_id=addr_456
  2024-11-22 10:16:30 [INFO] Calculating shipping costs for zip_code=90210
  2024-11-22 10:16:31 [INFO] Shipping cost calculated: standard=$9.99, express=$19.99
  2024-11-22 10:16:35 [INFO] User selected standard shipping
  2024-11-22 10:16:40 [INFO] Proceeding to payment step
  2024-11-22 10:16:41 [INFO] Loading saved payment methods for user_id=12345
  2024-11-22 10:16:42 [WARN] No saved payment methods found for user
  2024-11-22 10:16:45 [INFO] User entered new credit card details
  2024-11-22 10:16:46 [INFO] Validating credit card number: ****1234
  2024-11-22 10:16:47 [ERROR] Credit card validation failed: invalid_luhn_checksum
  2024-11-22 10:16:47 [INFO] Displaying error message to user: "Please check your card number"
  2024-11-22 10:17:02 [INFO] User re-entered credit card details
  2024-11-22 10:17:03 [INFO] Validating credit card number: ****5678
  2024-11-22 10:17:04 [INFO] Credit card validation successful
  2024-11-22 10:17:05 [INFO] Validating expiration date: 12/2027
  2024-11-22 10:17:06 [INFO] Expiration date validation successful
  2024-11-22 10:17:07 [INFO] Validating CVV code
  2024-11-22 10:17:08 [INFO] CVV validation successful
  2024-11-22 10:17:10 [INFO] Processing payment authorization
  2024-11-22 10:17:12 [INFO] Contacting payment gateway: gateway=stripe
  2024-11-22 10:17:15 [INFO] Payment gateway response: status=success, auth_code=AUTH123456
  2024-11-22 10:17:16 [INFO] Payment authorized successfully: amount=$609.97
  2024-11-22 10:17:17 [INFO] Creating order record in database
  2024-11-22 10:17:18 [INFO] Order created: order_id=ORD-789123, status=confirmed
  2024-11-22 10:17:19 [INFO] Sending confirmation email to: user@example.com
  2024-11-22 10:17:20 [INFO] Email sent successfully
  2024-11-22 10:17:21 [INFO] Clearing user cart
  2024-11-22 10:17:22 [INFO] Cart cleared successfully
  2024-11-22 10:17:23 [INFO] Redirecting user to order confirmation page
  2024-11-22 10:17:24 [INFO] Order confirmation page loaded: order_id=ORD-789123
  ```

  ## Question ##
  The user reported that their checkout process failed and they couldn't complete their purchase. Based on these logs, what actually happened during their checkout experience? Was there really a failure, and if so, what caused it and how was it resolved?

  Ask clarifying questions if needed."""

# Prepare the request
request_body = {
    "system": [
        {
            "text": system_prompt
        }
    ],
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "text": user_prompt
                }
            ]
        }
    ],
    "toolConfig": {
        "tools": [
            {
                "systemTool": {
                    "name": "nova_grounding"
                }
            },
            {
                "systemTool": {
                    "name": "nova_code_interpreter"
                }
            }
        ]
    },
    "additionalModelRequestFields": {
        "reasoningConfig": {
            "type": "enabled",
            "maxReasoningEffort": "low"
        }
    },
    "inferenceConfig": {
        "temperature": 0.3,
        "topP": 0.9,
        "maxTokens": 10000
    }
}

# Make the API call
response = bedrock_runtime.converse(
    modelId="amazon.nova-2-lite-v1:0",
    **request_body
)

# Print the response
print(json.dumps(response, indent=2, default=str))
#!/bin/bash

aws bedrock-runtime converse \
    --model-id amazon.nova-2-lite-v1:0 \
    --region us-west-2 \
    --messages file://messages.json \
    --system '[{"text": "You are an expert software engineer who analyzes application logs to diagnose issues and provide solutions. Use the provided log data to answer questions thoroughly and cite relevant information from the logs."}]' \
    --additional-model-request-fields '{"reasoningConfig": {"type": "enabled", "maxReasoningEffort": "medium"}}'
{
 "system": "You are an expert software engineer who analyzes application logs to diagnose issues and provide solutions.\n  Use the provided log data to answer questions thoroughly and cite relevant information from the logs.",
 "messages": [
  {
   "role": "user",
   "content": [
    {
     "text": "## Context ##\n  **Application Debug Logs - E-commerce Checkout Flow**\n  \n  ```\n  2024-11-22 10:15:23 [INFO] User session started: user_id=12345, session_id=abc-def-789\n  2024-11-22 10:15:24 [INFO] User navigated to product page: product_id=SKU-001, category=electronics\n  2024-11-22 10:15:45 [INFO] Product added to cart: product_id=SKU-001, quantity=2, price=299.99\n  2024-11-22 10:16:12 [INFO] User navigated to cart page\n  2024-11-22 10:16:15 [INFO] Cart validation successful: total_items=2, subtotal=599.98\n  2024-11-22 10:16:18 [INFO] User clicked checkout button\n  2024-11-22 10:16:19 [INFO] Checkout process initiated: user_id=12345\n  2024-11-22 10:16:20 [INFO] Loading shipping addresses for user_id=12345\n  2024-11-22 10:16:21 [INFO] Found 2 saved addresses for user\n  2024-11-22 10:16:25 [INFO] User selected shipping address: address_id=addr_456\n  2024-11-22 10:16:30 [INFO] Calculating shipping costs for zip_code=90210\n  2024-11-22 10:16:31 [INFO] Shipping cost calculated: standard=$9.99, express=$19.99\n  2024-11-22 10:16:35 [INFO] User selected standard shipping\n  2024-11-22 10:16:40 [INFO] Proceeding to payment step\n  2024-11-22 10:16:41 [INFO] Loading saved payment methods for user_id=12345\n  2024-11-22 10:16:42 [WARN] No saved payment methods found for user\n  2024-11-22 10:16:45 [INFO] User entered new credit card details\n  2024-11-22 10:16:46 [INFO] Validating credit card number: ****1234\n  2024-11-22 10:16:47 [ERROR] Credit card validation failed: invalid_luhn_checksum\n  2024-11-22 10:16:47 [INFO] Displaying error message to user: \"Please check your card number\"\n  2024-11-22 10:17:02 [INFO] User re-entered credit card details\n  2024-11-22 10:17:03 [INFO] Validating credit card number: ****5678\n  2024-11-22 10:17:04 [INFO] Credit card validation successful\n  2024-11-22 10:17:05 [INFO] Validating expiration date: 12/2027\n  2024-11-22 10:17:06 [INFO] Expiration date validation successful\n  2024-11-22 10:17:07 [INFO] Validating CVV code\n  2024-11-22 10:17:08 [INFO] CVV validation successful\n  2024-11-22 10:17:10 [INFO] Processing payment authorization\n  2024-11-22 10:17:12 [INFO] Contacting payment gateway: gateway=stripe\n  2024-11-22 10:17:15 [INFO] Payment gateway response: status=success, auth_code=AUTH123456\n  2024-11-22 10:17:16 [INFO] Payment authorized successfully: amount=$609.97\n  2024-11-22 10:17:17 [INFO] Creating order record in database\n  2024-11-22 10:17:18 [INFO] Order created: order_id=ORD-789123, status=confirmed\n  2024-11-22 10:17:19 [INFO] Sending confirmation email to: user@example.com\n  2024-11-22 10:17:20 [INFO] Email sent successfully\n  2024-11-22 10:17:21 [INFO] Clearing user cart\n  2024-11-22 10:17:22 [INFO] Cart cleared successfully\n  2024-11-22 10:17:23 [INFO] Redirecting user to order confirmation page\n  2024-11-22 10:17:24 [INFO] Order confirmation page loaded: order_id=ORD-789123\n  ```\n  \n  ## Question ##\n  The user reported that their checkout process failed and they couldn't complete their purchase. Based on these logs, what actually happened during their checkout experience? Was there really a failure, and if so, what caused it and how was it resolved?\n  \n  Ask clarifying questions if needed."
    }
   ]
  }
 ],
 "additionalModelRequestFields": {
  "reasoningConfig": {
   "type": "enabled",
   "maxReasoningEffort": "high"
  }
 }
}