MCPcopy Index your code
hub / github.com/simstudioai/sim / openDMChannel

Function openDMChannel

apps/sim/app/api/tools/slack/utils.ts:206–232  ·  view source on GitHub ↗
(
  accessToken: string,
  userId: string,
  requestId: string,
  logger: Logger
)

Source from the content-addressed store, hash-verified

204 * Opens a DM channel with a user and returns the channel ID
205 */
206export async function openDMChannel(
207 accessToken: string,
208 userId: string,
209 requestId: string,
210 logger: Logger
211): Promise<string> {
212 const response = await fetch('https://slack.com/api/conversations.open', {
213 method: 'POST',
214 headers: {
215 'Content-Type': 'application/json',
216 Authorization: `Bearer ${accessToken}`,
217 },
218 body: JSON.stringify({
219 users: userId,
220 }),
221 })
222
223 const data = await response.json()
224
225 if (!data.ok) {
226 logger.error(`[${requestId}] Failed to open DM channel:`, data.error)
227 throw new Error(data.error || 'Failed to open DM channel with user')
228 }
229
230 logger.info(`[${requestId}] Opened DM channel: ${data.channel.id}`)
231 return data.channel.id
232}
233
234export interface SlackMessageParams {
235 accessToken: string

Callers 2

route.tsFile · 0.90
sendSlackMessageFunction · 0.85

Calls 2

errorMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected