Rob Sawyer
Rob Sawyer

Reputation: 2183

Private message Slack user via RTM

Has anyone figured out how to private message a user via Slack RTM? I'm trying to create a game and would like to PM a user in Slack to provide updates and such.

You can see how far I am via the coffee script in src/poker.coffee in https://github.com/robksawyer/hubot-poker.

Feel free to fork and finish. ;)

And please let me know if I'm way off track and if this isn't possible at all.

Upvotes: 2

Views: 6048

Answers (1)

seanrose
seanrose

Reputation: 8685

From the docs

You can send a message to a private group or direct message channel in the same way, but using a Group ID (C024BE91L) or DM channel ID (D024BE91L).

So you just need to specify the recipient @username or id of the DM D1234BLah as the value for channel when sending the message to the RTM API e.g.

{
    "id": 1,
    "type": "message",
    "channel": "@jeff",
    "text": "hello jeff"
}

Full RTM docs here: https://api.slack.com/rtm

Upvotes: 4

Related Questions