bitterfox / slack-java-api

Provide full api of slack via java
1 stars 0 forks source link

need help in testing this API. #127

Open pradeepyadav15may opened 9 years ago

pradeepyadav15may commented 9 years ago

Hi,

I am new in using slack api. I need to send message to a particular slack group / single user by using slack-java-api. Please let me know how it can be done?

Sorry, but there is very less documentation for this API. Please help.

Thanks, Pradeep

bitterfox commented 9 years ago

Hi Pradeep,

Thank you for your question. And I must apologize for the less documentation.

You can do by using Slack#chat and ChatApi#postMessage. The sample code is here to send a message to the group:

Slack slack = ...; // create Slack object

Group group = ...; // you can get group, using Slack#groups and Groups#list

slack.chat().postMessage(group.id(), "HelloWorld");

It is here to send to the user(im):


Slack slack = ...; // create Slack object
User user = ...;

Im im = slack.im().open(user.id()); // you have to get Im object from user

slack.chat().postMessage(im.id(), "HelloWorld");

Regards, bitter_fox