Crafting the perfect prompt is like whispering secret instructions to your AI muse. But there’s no one-size-fits-all approach! Exploring different types of prompts unlocks a spectrum of possibilities in your Generative AI creations. Here’s a sneak peek:
1. The Classic Prompt: ✍️
2. The N-Shot Prompt:
3. The Chain-of-Thought Prompt:
4. The Conditioned Prompt:
5. The Open-Ended Prompt:
6. Interactive Prompts: ️
Prompt: Analyze historical sales data of tech clients and identify key trends in purchasing behaviour.
// Query tech client sales data
List techSales = [
SELECT Id, CloseDate, Amount, Product.Name
FROM Opportunity
WHERE AccountId IN (SELECT Id FROM Account WHERE Industry = 'Technology')
AND IsClosed = true
ORDER BY CloseDate DESC
];
// Calculate quarterly sales trends
Map quarterlySales = new Map();
for (Opportunity opp : techSales) {
Date quarterStart = Date.newInstance(opp.CloseDate.year(), opp.CloseDate.month() - opp.CloseDate.month() % 3, 1);
quarterlySales.put(quarterStart, quarterlySales.get(quarterStart) + opp.Amount);
}
// Identify top products by revenue
Map productRevenue = new Map();
for (Opportunity opp : techSales) {
productRevenue.put(opp.Product.Name, productRevenue.get(opp.Product.Name) + opp.Amount);
}
// Display insights for developers to interpret
System.debug('Quarterly Sales Trends: ' + quarterlySales);
System.debug('Top Products by Revenue: ' + productRevenue);
Prompt: Recommend three relevant products for Customer X based on recent website visits and past purchases.
// Gather customer data
Contact customerX = [SELECT Id, Name, RecentVisitedPages, PastPurchases FROM Contact WHERE Name = 'Customer X'];
// Collect product recommendations from Einstein (replace with your actual Einstein model)
List recommendations = EinsteinRecommendations.getRecommendationsForContact(customerX);
// Display top 3 recommendations
System.debug('Recommended Products for Customer X:');
for (Integer i = 0; i < 3; i++) {
System.debug('- ' + recommendations[i].Product.Name);
}
Prompt: Create a blog post addressing top customer concerns from surveys and support tickets.
// Gather customer feedback data
List supportTickets = [SELECT Id, Subject, Description FROM Case WHERE Status = 'Closed' AND Type = 'Problem'];
List surveyResponses = [SELECT Id, Question, Answer FROM SurveyResponse];
// Extract common topics and concerns
Set topConcerns = new Set();
for (Case ticket : supportTickets) {
topConcerns.addAll(extractKeywords(ticket.Subject, ticket.Description));
}
for (SurveyResponse response : surveyResponses) {
topConcerns.addAll(extractKeywords(response.Question, response.Answer));
}
// Generate blog content
String blogPost = '**Top Customer Concerns and How We're Addressing Them**nn';
for (String concern : topConcerns) {
blogPost += '* **' + concern + ':**n';
blogPost += ' - Explanation of the concernn';
blogPost += ' - Steps we're taking to address itn';
}
// Display blog post for developers to review and publish
System.debug(blogPost);
Prompt 1: Predict the likelihood of a lead converting to an opportunity based on historical data and current lead attributes.
public class LeadConversionPredictor {
public PredictionResult predictLeadConversion(Lead lead) {
// 1. Gather historical data for lead conversion analysis
List historicalLeads = [SELECT Id, ConvertedDate, ... FROM Lead WHERE ...];
// 2. Train a prediction model (e.g., logistic regression, decision tree)
Model model = trainPredictionModel(historicalLeads);
// 3. Extract relevant lead attributes
Map leadFeatures = extractLeadFeatures(lead);
// 4. Generate prediction using the model
Probability prediction = model.predict(leadFeatures);
// 5. Return prediction result
return new PredictionResult(prediction);
}
// Helper methods for model training and feature extraction
private Model trainPredictionModel(List leads) {
// Implement model training logic
}
private Map extractLeadFeatures(Lead lead) {
// Map lead attributes to features for the model
}
}
Prompt 2: Identify customers most likely to churn within the next 6 months, considering past purchase patterns, engagement metrics, and support interactions.
public class ChurnPredictor {
public List predictHighChurnRiskCustomers() {
// 1. Gather relevant customer data from multiple objects
List customers = [SELECT Id, ... FROM Customer];
List orders = [SELECT Id, CustomerId, ... FROM Order];
List cases = [SELECT Id, CustomerId, ... FROM Case];
// 2. Calculate churn risk scores based on defined criteria
Map churnScores = calculateChurnScores(customers, orders, cases);
// 3. Identify customers with scores above a threshold
List highChurnRiskCustomers = new List();
for (Customer customer : customers) {
if (churnScores.get(customer.Id) > churnThreshold) {
highChurnRiskCustomers.add(customer);
}
}
return highChurnRiskCustomers;
}
// Helper method for churn score calculation
private Map calculateChurnScores(List customers, List orders, List cases) {
// Implement churn score logic
}
}
Prompt:
Generate a list of 3 email subject lines that are likely to get high open rates, based on the following examples:
Response
Prompt: Write an Apex trigger that updates the ‘Last_Reviewed_Date’ field on the Account object to today’s date whenever a new Opportunity is created for that account.
trigger UpdateContactLastContactedDate on Contact (after insert) {
for (Contact c : Trigger.new) {
c.Last_Contacted_Date__c = Date.today();
}
}
Prompt: Write an Apex method that calculates the total amount of all open opportunities for a given account, using only a few keywords as guidance: account ID, opportunity amount, and open opportunities.
Keywords:
public static Decimal calculateTotalOpenOpportunityAmount(Id accountId) {
List openOpps = [
SELECT Amount
FROM Opportunity
WHERE AccountId = :accountId AND IsClosed = false
];
Decimal totalAmount = 0;
for (Opportunity opp : openOpps) {
totalAmount += opp.Amount;
}
return totalAmount;
}
Exploring the world of prompt engineering can be exhilarating and empowering. To ignite your journey, here’s a curated list of resources and links to help you learn and master this fascinating skill:
Interactive Platforms:
Comprehensive Guides:
Blogs and Articles:
Online Courses:
Community and Discussion: