MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / notifyAssessmentCompleted

Function notifyAssessmentCompleted

server/src/notifications/assessment.ts:18–67  ·  view source on GitHub ↗
(data: {
  organizationName: string;
  userName: string;
  userEmail: string;
  persona: string;
})

Source from the content-addressed store, hash-verified

16 * Post assessment completion to the admin channel
17 */
18export async function notifyAssessmentCompleted(data: {
19 organizationName: string;
20 userName: string;
21 userEmail: string;
22 persona: string;
23}): Promise<boolean> {
24 if (!isSlackConfigured()) {
25 logger.debug('Slack not configured, skipping assessment notification');
26 return false;
27 }
28
29 const adminChannel = await getAdminChannel();
30 if (!adminChannel.channel_id) {
31 logger.debug('Admin channel not configured, skipping assessment notification');
32 return false;
33 }
34
35 const personaLabel = PERSONA_LABELS[data.persona] || data.persona;
36 const text = `Assessment completed: ${data.organizationName} → ${personaLabel}`;
37
38 const blocks: SlackBlock[] = [
39 {
40 type: 'header',
41 text: { type: 'plain_text', text: 'Persona assessment completed', emoji: true } as SlackTextObject,
42 },
43 {
44 type: 'section',
45 fields: [
46 { type: 'mrkdwn', text: `*Organization:*\n${data.organizationName}` },
47 { type: 'mrkdwn', text: `*Persona:*\n${personaLabel}` },
48 { type: 'mrkdwn', text: `*Submitted by:*\n${data.userName}` },
49 { type: 'mrkdwn', text: `*Email:*\n${data.userEmail}` },
50 ],
51 },
52 ];
53
54 try {
55 const result = await sendChannelMessage(adminChannel.channel_id, { text, blocks }, { requirePrivate: true });
56 if (result.ok) {
57 logger.info({ channel: adminChannel.channel_name, org: data.organizationName }, 'Assessment notification sent');
58 return true;
59 } else {
60 logger.warn({ error: result.error, channel: adminChannel.channel_id }, 'Failed to send assessment notification');
61 return false;
62 }
63 } catch (error) {
64 logger.error({ error, channel: adminChannel.channel_id }, 'Error sending assessment notification');
65 return false;
66 }
67}

Callers 1

createEngagementRouterFunction · 0.85

Calls 4

isSlackConfiguredFunction · 0.85
getAdminChannelFunction · 0.85
sendChannelMessageFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected