PromptLayer Connection copy¶
This workflow demonstrates integration with PromptLayer's API for managing and logging AI prompt interactions. It pulls prompt templates from PromptLayer and logs conversation data back to the platform for tracking and analytics purposes.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow appears to be a demonstration or testing setup for PromptLayer integration, showing how to retrieve prompt templates and log AI interactions for monitoring and optimization purposes.
How It Works¶
- Manual Trigger: The workflow starts when manually executed
- Prompt Retrieval: Makes an API call to PromptLayer to fetch a prompt template labeled "prod" for the "pbapldemo" prompt
- Interaction Logging: Logs a conversation interaction back to PromptLayer, including user input, bot response, timing data, and prompt version information
The workflow is designed to work with chat-based AI interactions, capturing both the user's message and the bot's response for analysis and prompt optimization.
Mermaid 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: Workflow executes when the "Execute workflow" button is clicked
- Use Case: Testing and demonstration purposes
Nodes Used¶
| Node | Type | Purpose |
|---|---|---|
| When clicking 'Execute workflow' | Manual Trigger | Starts 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 templates)/log-request(POST conversation logs)
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').item.json.message.textand$('Support Bot').item.json.output
Processing¶
- Retrieves prompt template with "prod" label from PromptLayer
- Extracts version number from the prompt response
- Constructs conversation log with user message and bot response
Output¶
- Prompt template data from PromptLayer
- Log confirmation from PromptLayer API
Error Handling¶
No explicit error handling is implemented in this workflow. Consider adding: - Error handling for API failures - Validation of required data before logging - Retry logic for network issues
Known Limitations¶
- Hardcoded API key poses security risk
- References nodes (
Message to bot,Support Bot) that don't exist in this workflow - No error handling for API failures
- Limited to the "pbapldemo" prompt template
- Workflow status is inactive
Related Workflows¶
No related workflows identified from the current context.
Setup Instructions¶
-
Import Workflow
- Copy the workflow JSON
- Import into your n8n instance
-
Configure Credentials
- Replace the hardcoded API key with a secure credential
- Set up PromptLayer API credentials in n8n
-
Update Node References
- Modify the HTTP Request node to reference actual nodes for message input and bot output
- Or provide test data for demonstration purposes
-
Configure Prompt Template
- Update the prompt template name if using a different template
- Adjust the label if not using "prod"
-
Test the Workflow
- Activate the workflow
- Execute manually to test the connection
- Verify data appears in your PromptLayer dashboard
-
Security Hardening
- Move API key to n8n credentials
- Add error handling nodes
- Implement input validation