Send a message to a specific user
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
**When I** type in a channel `tell @jane.smith they are super cool`,
**I expect** the bot
**to** send a private message to the user `jane.smith`
---
## The problem
The thing is, I don't know yet how to get the `userId` when I have only the `username`.
Solving this issue will enable me to made the following update:
### Currently
```javascript
app.message('tell fulano they are super cool', async ({ message, context }) => {
await app.client.reactions.add({
token: context.botToken,
name: 'top',
channel: message.channel,
timestamp: message.ts,
});
await app.client.chat.postMessage({
token: context.botToken,
channel: 'UN88YAC9G',
text: `<@${message.user}> wants you to know you are super cool`,
});
});
```
### After solving this issue
```javascript
// Would also need to update the regex to retrieve the username
app.message('tell @jane.smith they are super cool', async ({ message, context }) => {
// This is where the magic happens
const userId = getUserIdFromUsername('jane.smith');
await app.client.reactions.add({
token: context.botToken,
name: 'top',
channel: message.channel,
timestamp: message.ts,
});
await app.client.chat.postMessage({
token: context.botToken,
channel: userId, // Sends a pm to this user
text: `<@${message.user}> wants you to know you are super cool`,
});
});
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the existing app.message handler and its app.client.chat.postMessage call shown in the issue. Check the available user-lookup API for resolving a username to a user ID, and determine how the message pattern should capture @jane.smith. Done means the handler can address the selected user privately while preserving the existing reaction behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100