Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to send private/direct messages to a user rather than a room? #70

Closed
omehegan opened this issue Apr 1, 2016 · 3 comments

Comments

@omehegan
Copy link
Member

omehegan commented Apr 1, 2016

The subject says it all. I'd like to be able to send messages to an individual, rather than a room, because our rooms are getting polluted with notifications that only need to be seen by one person.

@aldaris
Copy link

aldaris commented Oct 6, 2016

I don't believe that this is possible, only users can send private messages to users. OAuth2 tokens issued to groups won't be able to do that. See https://www.hipchat.com/docs/apiv2/method/private_message_user

@aldaris aldaris closed this as completed Oct 6, 2016
@omehegan
Copy link
Member Author

omehegan commented Oct 6, 2016

My now-former coworker actually has a partially-complete pull request for the plugin which supports this. I've handed off the work to someone else, I hope to see it submitted pretty soon. It does require you to create a user and then create an API token for them with appropriate privileges.

@tomasbjerre
Copy link

tomasbjerre commented Jun 19, 2018

You can do it with curl:

curl -H "Authorization: Bearer oasdasdasdasdasdasdasdFm"  -H "Content-Type: application/json" https://hipchat.asdasdasdasd.se/v2/user/[email protected]/message -X POST -d '{"message": "hej", "notify": "true", "message_format": "text"}

Or in a pipeline you might want a method:

def hipchatPrivateMessage(steps, to, message) {
    def data = [
            message       : message,
            notify        : true,
            message_format: 'text'
    ]
    def json = JsonOutput.toJson(data)
    steps.sh """
    curl -H "Authorization: Bearer ofDC10yEHLR6jKdqGqZsJbgQ7RXP6tiyD95wvGFm"  -H "Content-Type: application/json" https://hipchat.dom.se/v2/user/$to/message -X POST -d '$json'
    """
}

Invoked like this:

hipchatPrivateMessage(this,"[email protected]","This is a message")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants