Skip to content

PromptLayer Connection

This workflow demonstrates how to integrate with PromptLayer's API to retrieve prompt templates and log AI interactions. It pulls a prompt template from PromptLayer and then logs a conversation between a user and a support bot back to the platform for tracking and analytics.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

How It Works

  1. Manual Trigger: The workflow starts when manually executed
  2. Retrieve Prompt Template: Makes an API call to PromptLayer to fetch the "pbapldemo" prompt template with the "prod" label
  3. Log Interaction: Sends a structured log entry back to PromptLayer containing the conversation details, including user input, bot response, and metadata

The workflow is designed to demonstrate the basic integration pattern with PromptLayer's prompt management and logging capabilities.

Workflow Diagram

graph TD
    A[When clicking 'Execute workflow'] --> B[Pull Prompt from PromptLayer]
    B --> C[HTTP Request - Log to PromptLayer]

Trigger

  • Type: Manual Trigger
  • Activation: Click "Execute workflow" button in the n8n interface
  • Use Case: Testing and demonstration purposes

Nodes Used

Node Name Type Purpose
When clicking 'Execute workflow' Manual Trigger Initiates the workflow execution
Pull Prompt from PromptLayer HTTP Request Retrieves prompt template from PromptLayer API
HTTP Request HTTP Request Logs conversation data back to PromptLayer

External Services & Credentials Required

PromptLayer API

  • Service: PromptLayer (https://api.promptlayer.com)
  • Authentication: API Key via X-API-KEY header
  • Required Credentials: PromptLayer API key
  • Endpoints Used:
    • /prompt-templates/pbapldemo (GET prompt template)
    • /log-request (POST conversation log)

Note: The workflow currently contains a hardcoded API key which should be replaced with a secure credential reference.

Environment Variables

No environment variables are currently configured. Consider moving the API key to a secure credential store.

Data Flow

Input

  • Manual trigger (no input data required)
  • References to external nodes: Message to bot and Support Bot (not present in current workflow)

Output

  • Prompt template data from PromptLayer
  • Log confirmation from PromptLayer API

Data Structure

The workflow expects and processes: - Prompt Template Response: Contains version number and template content - Log Request: Structured conversation data including user messages, bot responses, and metadata

Error Handling

No explicit error handling is implemented in this workflow. Consider adding: - Error handling for API failures - Validation of required data from referenced nodes - Retry logic for network issues

Known Limitations

  • Hardcoded API key presents security risk
  • References to Message to bot and Support Bot nodes that don't exist in the workflow
  • No error handling or validation
  • Manual trigger limits automation potential

No related workflows specified in the context.

Setup Instructions

  1. Import Workflow

    • Copy the workflow JSON
    • Import into your n8n instance
  2. Configure Credentials

    • Replace the hardcoded API key with a secure credential reference
    • Set up PromptLayer API credentials in n8n's credential manager
  3. Fix Node References

    • Add or connect the missing Message to bot and Support Bot nodes
    • Ensure proper data flow between nodes
  4. Test the Workflow

    • Execute manually to verify PromptLayer connectivity
    • Check that prompt templates are retrieved successfully
    • Verify logging functionality works as expected
  5. Security Hardening

    • Remove hardcoded API keys
    • Use n8n's credential system for API authentication
    • Consider adding input validation and error handling