I have this Cloud Function that posts to Slack, some text is fully hyperlinked but the majority is only partial and I don’t know why. The full bug title should be hyperlinked. Can anyone help me debug it? For example, these are fully hyperlinked:
Fix portfolio Dockerfile path
Profiler for A: The user can still change chains
Yet many aren’t like this:
Overview > Historical Token Portfolio [and other widgets]: Changing
time period filters completely resets the token selection>
Code:
async function generateSummary(groupedBugs) {
try {
const openai = new OpenAI({
apiKey: OPENAI_API_KEY
});
const currentDate = new Date();
const oneWeekAgo = new Date(currentDate.getTime() - 7 * 24 * 60 * 60 * 1000);
let formattedBugs = `*Weekly Bug Recap: ${oneWeekAgo.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })} - ${currentDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })}*n_______________________________nn`;
// Separate known features and unknown features
const knownFeatures = {};
let unknownFeatures = [];
for (const [feature, bugs] of Object.entries(groupedBugs)) {
if (feature === 'Unknown Feature') {
unknownFeatures = bugs;
} else {
const mainFeature = feature.split(':')[0].trim();
if (!knownFeatures[mainFeature]) {
knownFeatures[mainFeature] = [];
}
knownFeatures[mainFeature].push(...bugs);
}
}
// Format known features
for (const [feature, bugs] of Object.entries(knownFeatures)) {
formattedBugs += `*${feature}*n`;
bugs.forEach((bug, index) => {
const fullTitle = bug.title.replace(/^BUGs*::s*/i, '').trim();
formattedBugs += `${index + 1}. <${bug.url}|${fullTitle}>n`;
});
formattedBugs += 'n';
}
// Format unknown features at the bottom
if (unknownFeatures.length > 0) {
formattedBugs += `*Unknown Feature*n`;
unknownFeatures.forEach((bug, index) => {
const title = bug.title.replace(/^BUGs*::s*/i, '').trim();
formattedBugs += `${index + 1}. <${bug.url}|${title}>n`;
});
}
const prompt = `Format the following bugs by feature using Slack's markdown syntax:
- Preserve the existing bold text, underlines, and hyperlinks
- Do not use code blocks, quote blocks, or any other additional formatting
- Do not add any additional information
- Ensure the output matches the input format exactly but make sure hyperlink covers full text, not partial!
- The output should be plain text with Slack markdown, not wrapped in any blocks
Here's the bug summary to format:
${formattedBugs}`;
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ "role": "user", "content": prompt }],
});