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

Function sendDirectMessage

server/src/slack/client.ts:365–391  ·  view source on GitHub ↗
(
  userId: string,
  message: SlackBlockMessage
)

Source from the content-addressed store, hash-verified

363 * Send a direct message to a user
364 */
365export async function sendDirectMessage(
366 userId: string,
367 message: SlackBlockMessage
368): Promise<{ ok: boolean; ts?: string; error?: string }> {
369 try {
370 // First, open a DM channel with the user
371 const imResponse = await slackPostRequest<{ channel: { id: string } }>('conversations.open', {
372 users: userId,
373 });
374
375 const channelId = imResponse.channel.id;
376
377 // Send the message
378 const messageResponse = await slackPostRequest<{ ts: string }>('chat.postMessage', {
379 channel: channelId,
380 text: message.text,
381 blocks: message.blocks,
382 });
383
384 logger.info({ userId, ts: messageResponse.ts }, 'Sent Slack DM');
385 return { ok: true, ts: messageResponse.ts };
386 } catch (error) {
387 const errorMessage = error instanceof Error ? error.message : 'Unknown error';
388 logger.error({ error, userId }, 'Failed to send Slack DM');
389 return { ok: false, error: errorMessage };
390 }
391}
392
393/**
394 * Privacy state of a configured Slack channel at send time. Distinguishes

Callers 15

notifyUserFunction · 0.85
sendWelcomeSocialPostsFunction · 0.85
sendMarketingOptInDMFunction · 0.85
createEventsRouterFunction · 0.85
createAddieAdminRouterFunction · 0.85
runMeetingPrepNudgeJobFunction · 0.85
registerAllJobsFunction · 0.85
sendWgWelcomeMessageFunction · 0.85
createAdminToolHandlersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected