rampatra / jbot Goto Github PK
View Code? Open in Web Editor NEWMake Slack and Facebook Bots in Java.
License: GNU General Public License v3.0
Make Slack and Facebook Bots in Java.
License: GNU General Public License v3.0
Hi,
I am currently running Jbot as part of a spring boot project, what I noticed is that after certain amount of time (could be inactivity, though I am not sure) bot shows offline in SLACK even though the application is running fine.
I had to restart my application to bring the bot online again.
Also, one thing I noticed in howdy botkit (running on ec2), that after sometime RTM has multiple instances running because of app trying to reconnect. howdyai/botkit#750
Could these be related.
Also, any idea how to solve this issue of bot going offline.
Hi,
Thanks for the awesome framework. I'm using your framework to create a Slack Bot. I have an issue when the bot tries to reply back with large text (around 10k characters). The bot simply goes offline without any error. I tried debugging the issue, but couldn't get into a solution.
I suspect, the web socket session is getting closed for larger text. I tried setting the text limit for the session, even that didn't work.
Can you help me fix the issue?
TIA!
HI,
When I add bot in a group and than tag it with a message(DIRECT_MENTION), doing event.getText() gives me message along with some <--id--> and simply text.
Same thing in howdy botkit gives me only message and no tagging information if I don message .text there.
Any help?
Do you have an example for sending files (like pdf) over slack.
Hi,
I tried to use the events.getUser api, which returns null. I have added required user:read and user:email.read permissions to the slack app. I want to know the details of the user bot is chatting to currently.
Could you let me know how that can be done?
Hi, Like howdy botkit, I wanted to send messages from jbot using reply with typing feature.
I have set message type as "typing" but still the bot directly replies without a typing info before.
Implementing the conversation as a queue can lead to stack overflows when conversation needs to be restarted from a point already mentioned in a method before. An acyclic directed graph can be used to handle such a situation.
It would be nice if there was a jar-file (published to central) that could be used as a gradle dependency, instead of cloning your repository!
The JSON should be short not short_enough
I am trying to follow the instructions on offer and run the slackbot for the first time, I have navigated to jbot-example as stated and have run mvn spring-boot:run but when ever i do this i am presented with this error message:
[WARNING] The POM for me.ramswaroop.jbot:jbot:jar:3.0.3-SNAPSHOT is missing, no
dependency information available
[ERROR] Failed to execute goal on project jbot-example: Could not resolve depend
encies for project org.springframework.boot:jbot-example:jar:1.0.0-SNAPSHOT: Cou
ld not find artifact me.ramswaroop.jbot:jbot:jar:3.0.3-SNAPSHOT -> [Help 1]
I am quite new to mvn so I am not sure if i am doing something wrong or if there is an issue with the source i have downloaded, would greatly appreciate some assistance
This isn't an issue per se, but I'm having some issues running the sample application in Eclipse. Are instructions documented someplace?
Hi,
I have encountered a big issue. Say you entered a slack domain and it has several users. When a new user that haven't yet talked to the JBot, the JBot fails to take inputs. But when a restart of the spring-boot service is done, those users who tried interacting with the bots and failed are now are able to interact.
Can you please, tell me where can the problem be as soon as possible. :)
I found out while playing with reaction_added event that there is one field that is missing from the Item which is called ts. It is the time stamp of the original message which received the reaction. Whitout this field it is not possible to determine which message received the reaction. I added it to Item in local and it works like a charm, maybe itt would be great to fix this issue here as well.
Why not completely separate this from Spring and allow it to be used in any form of Java application (desktop, android, enterprise, etc)?
I was going to take a crack at implementing the Facebook bot until I realized the base of this library is developed on Spring which I am not fully familiar with.
In the current solution it's not possible to skip a step in a conversation.
Maybe there could be a new method nextConversation(event, "confirmBooking")
, which could create a conversationQueue "on-the-fly". This would make it possible to change the flow of a conversation depending on the input from the user.
That could perhaps remove the need for startConversation(event)
and stopConversation(event)
and also the next
-attribute in the annotation?
Hi,
I think I spotted a bug.
If we take you meeting scheduler example, even if you stop the conversation by answering "no" to the askWhetherToRepeat step, then, forever, all the steps are called. So the conversation is not really closed.
I hope that's clear...
This about sums it up. I love your library but I can't end conversations properly and i dont know why.
@Controller(pattern = "(setup poll)", next = "comfirm")
public void onPollRequest(WebSocketSession session, Event event)
{
startConversation(event, "confirm");
reply(session, event, new Message("'Yes' to confirm setup poll."));
}
@Controller(next = "runPoll")
public void confirm(WebSocketSession session, Event event)
{
if(event.getText().contains("yes")) {
reply(session, event, new Message("Awesome! Which system? -BA -UCD -Machines -Jenkins -Sametime"));
nextConversation(event);
} else {
stopConversation(event);
}
}
/**
* This method is chained with {@link SlackBot#onPollRequest(WebSocketSession, Event)}.
*
* @param session
* @param event
*/
@Controller
public void runPoll(WebSocketSession session, Event event)
{
if (event.getText().contains("Jenkins")) {
reply(session, event, new Message("Easy, running..."));
ResourcePollingMachine.runRPM("Jenkins", true, true);
} else if (event.getText().contains("BA")) {
reply(session, event, new Message("Easy, running..."));
ResourcePollingMachine.runRPM("BA", true, true);
}
stopConversation(event);
}
In slack if you want to announce with a bot message you need to use <!channel>. When you include this in the message but call getEncodedMessage it does not work. However if you don't use the encoded message it does work.
see https://get.slack.help/hc/en-us/articles/202009646-Make-an-announcement. Scroll down to section labeled bot messages.
Can you give a little example of how to use SlackWebhooks ?
When I tried it seems slackIncomingWebhookUrl is not initialized by Spring... I forgot something but I don't know what..
Thanks !
After deploying to Heroku and attempting to run the app I am seeing this error message in the logs:
Error: Unable to access jarfile jbot-example/target/jbot-example-1.0.0-SNAPSHOT.jar
I have checked this is the correct name for the jar file and this is the jar file that is auto-created when running mvn spring-boot:run.
My procfile looks like this: web: java -Dserver.port=8080 -jar jbot-example/target/jbot-example-1.0.0-SNAPSHOT.jar
And the path from the jbot directory to the jar file is jbot-example\target\jbot-example-1.0.0-SNAPSHOT.jar
Any help with this would be greatly appreciated
This is the first time I've used Heroku so not sure if I am missing anything.
Hi
Is there a way to use RichMessage with the bot's reply method? The example does not seem to deal with this. Basically I want to show a RichMessage as a response to a Text Message from the user.
Thanks
Hey,
I have a scheduler, which checks every hour if a new event (for example we sold something) occurred.
If something occurred, I want to send a new message to a channel (in which the bot already is).
Is this possible? I can't find any methods for this in the documentation.
I've been trying to run jbot-example–I cloned the repository, ran mvn install
in the jbot folder, went into jbot-example and ran mvn spring-boot:run
, but it throws this error:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) on project jbot-example: An exception occurred while running.
null: InvocationTargetException: Error creating bean with name 'slackBot': Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager: org.apache.tomcat.util.res.StringManager -> [Help 1]
Please is the Facebook version available now
Hello Ram,
Thanks for the wonderful library. Can you also add hipchat support to it.
Thanks in advance,
Regards,
Abhishek
Hi,
How can we import and launch your project (JBotApplication.java) directly in Eclipse ?
Actually, Eclipse can't detect that it's a Maven and Java project (so, your main classe cannot be launch, but as you said, if we launch the 'mvn spring-boot:run' command, it works).
Thanks for your help.
Julien M
Good afternoon,
First of all, thanks for your work and making it available on Git. I am currently trying to use Jbot, it works pretty fine. However, when restarting the server, not only are the pending request all replied at once but some messages for which a reply have already been made are sent again. Would there be a way to handle this?
Advanced thanks,
Hey,
Is there any plans to integrate the new Slack API interactive messages feature?
I have a new issue now. When I call startConversation()
in my java method init()
, it throws an InvokeTargetException
even though the string parameter I am using is a method that actually exists. Here is a snippet of my bot code (feel free to correct any other ways in which I'm using your framework wrong, if that's the case):
@Controller(events=EventType.USER_TYPING, next="promptQuestion")
public void init(WebSocketSession session, Event event) {
if(rightTime() == true){ // Bot does nothing if it's not the right time/circumstances to ask questions
initializeReaderAndWriter();
startConversation(event, "promptQuestion");
}
}
@Controller(next="promptQuestion")
public void promptQuestion(WebSocketSession session, Event event) {
String question = ""; // initialize question
try{
question = questionReader.readLine(); // read the current question from the text file "questions.txt"
}
catch(IOException e){
e.printStackTrace();
}
reply(session, event, new Message(question)); // print out the most recently read question
answerWriter.println(event.getText()); // take in the user's answer to that question
if( (++answerCount) < 3) nextConversation(event); // Repeat the method if this is only the first or second question
else{ // If it's the third (last) question, end the conversation
try{
questionReader.close(); // The feature (reader) that reads the question file must close after asking all three questions
answerWriter.close(); // The feature that saves the answers to a text file must also close after the user is finished giving out his/her
// three answers
}
catch(IOException e){
e.printStackTrace();
}
stopConversation(event); // No more calling of promptQuestion() until the next day
}
}
Here is the exception/error output:
2017-07-17 11:19:51.555 ERROR 10932 --- [ient-SecureIO-1] me.ramswaroop.jbot.core.slack.Bot : Error invoking controller:
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at me.ramswaroop.jbot.core.slack.Bot.invokeMethods(Bot.java:304) [jbot-3.0.2.jar:3.0.2]
at me.ramswaroop.jbot.core.slack.Bot.handleTextMessage(Bot.java:177) [jbot-3.0.2.jar:3.0.2]
at me.ramswaroop.jbot.core.slack.BotWebSocketHandler.handleTextMessage(BotWebSocketHandler.java:32) [jbot-3.0.2.jar:3.0.2]
at org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43) [spring-web
socket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75) [spring-w
ebsocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleMessage(LoggingWebSocketHandlerDecorator.java
:56) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerA
dapter.java:110) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$000(StandardWebSocketHandlerAdapter.
java:42) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter
.java:81) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter
.java:78) [spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:399) [tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:500) [tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:295) [tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:131) [tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:73) [tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsFrameClient.access$300(WsFrameClient.java:31) [tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:131) [tomcat-embed-we
bsocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:114) [tomcat-embed-we
bsocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WrapperFuture.complete(AsyncChannelWrapperSecure.java:463) [tomcat-em
bed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$ReadTask.run(AsyncChannelWrapperSecure.java:332) [tomcat-embed-websoc
ket-8.5.4.jar:8.5.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Caused by: java.lang.StackOverflowError: null
at me.ramswaroop.jbot.core.slack.Bot.formConversationQueue(Bot.java:270) [jbot-3.0.2.jar:3.0.2]
at me.ramswaroop.jbot.core.slack.Bot.formConversationQueue(Bot.java:275) [jbot-3.0.2.jar:3.0.2]
at me.ramswaroop.jbot.core.slack.Bot.formConversationQueue(Bot.java:275) [jbot-3.0.2.jar:3.0.2]
at me.ramswaroop.jbot.core.slack.Bot.formConversationQueue(Bot.java:275) [jbot-3.0.2.jar:3.0.2]
at me.ramswaroop.jbot.core.slack.Bot.formConversationQueue(Bot.java:275) [jbot-3.0.2.jar:3.0.2]`
How do I get the bot to join a channel when I only know the channel name, i.e. #general?
What's the recommended approach / library for blending Web API calls to supplement the RTM response data (e.g. retrieve user info for a message poster)?
Using 3.0.3-SNAPSHOT as I want the reply feature of messages, but get the following error when the bot responds:
2017-02-06 14:43:56.192 ERROR 8104 --- [ient-SecureIO-1] me.ramswaroop.jbot.core.slack.Bot : Error handling response from Slack: {"type":"message","message":{"type":"message","user":"U3QCGKKNU","text":"game Plague Inc","thread_ts":"1486392240.000396","reply_count":1,"replies":[{"user":"U41LKC0NA","ts":"1486392241.000397"}],"ts":"1486392240.000396"},"subtype":"message_replied","hidden":true,"channel":"G3RU2Q5MG","event_ts":"1486392241.263880","ts":"1486392241.000398"}.
Exception:
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of me.ramswaroop.jbot.core.slack.models.Message: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: {"type":"message","message":{"type":"message","user":"U3QCGKKNU","text":"game Plague Inc","thread_ts":"1486392240.000396","reply_count":1,"replies":[{"user":"U41LKC0NA","ts":"1486392241.000397"}],"ts":"1486392240.000396"},"subtype":"message_replied","hidden":true,"channel":"G3RU2Q5MG","event_ts":"1486392241.263880","ts":"1486392241.000398"}; line: 1, column: 30] (through reference chain: me.ramswaroop.jbot.core.slack.models.Event["message"])
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1456) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1012) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1205) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:314) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:148) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:499) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:101) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798) ~[jackson-databind-2.8.5.jar:2.8.5]
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842) ~[jackson-databind-2.8.5.jar:2.8.5]
at me.ramswaroop.jbot.core.slack.Bot.handleTextMessage(Bot.java:159) ~[jbot-3.0.3-SNAPSHOT.jar:3.0.3-SNAPSHOT]
at me.ramswaroop.jbot.core.slack.BotWebSocketHandler.handleTextMessage(BotWebSocketHandler.java:32) [jbot-3.0.3-SNAPSHOT.jar:3.0.3-SNAPSHOT]
at org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43) [spring-websocket-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75) [spring-websocket-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleMessage(LoggingWebSocketHandlerDecorator.java:56) [spring-websocket-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:110) [spring-websocket-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$000(StandardWebSocketHandlerAdapter.java:42) [spring-websocket-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:81) [spring-websocket-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:78) [spring-websocket-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:399) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:500) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:295) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:131) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:73) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.WsFrameClient.access$300(WsFrameClient.java:31) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:131) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:114) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WrapperFuture.complete(AsyncChannelWrapperSecure.java:463) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$ReadTask.run(AsyncChannelWrapperSecure.java:332) [tomcat-embed-websocket-8.5.6.jar:8.5.6]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
I'm probably just missing this, but how can I get my bot to join a channel and listen to messages from that channel?
Hi I'm running into some kind of problem while connecting to the websocket after previously having been able to fix my problem with spring package scanning. Any ideas what could be causing it?
The execution log is here:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.0.RELEASE)
2017-04-19 08:07:17.417 INFO 3941 --- [ main] example.jbot.JBotApplication : Starting JBotApplication on 17263-debian with PID 3941 (/home/msl09/IdeaProjects/jbot/jbot-example/target/classes started by msl09 in /home/msl09/IdeaProjects/jbot/jbot-example)
2017-04-19 08:07:17.421 INFO 3941 --- [ main] example.jbot.JBotApplication : No active profile set, falling back to default profiles: default
2017-04-19 08:07:17.474 INFO 3941 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@50b472aa: startup date [Wed Apr 19 08:07:17 BRT 2017]; root of context hierarchy
2017-04-19 08:07:18.707 INFO 3941 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-04-19 08:07:18.718 INFO 3941 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-04-19 08:07:18.719 INFO 3941 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.4
2017-04-19 08:07:18.785 INFO 3941 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-04-19 08:07:18.785 INFO 3941 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1313 ms
2017-04-19 08:07:18.880 INFO 3941 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-04-19 08:07:18.882 INFO 3941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-04-19 08:07:18.883 INFO 3941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-04-19 08:07:18.883 INFO 3941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-04-19 08:07:18.883 INFO 3941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-04-19 08:07:20.546 INFO 3941 --- [ main] o.s.w.s.c.WebSocketConnectionManager : Starting WebSocketConnectionManager
2017-04-19 08:07:20.547 INFO 3941 --- [ main] o.s.w.s.c.WebSocketConnectionManager : Connecting to WebSocket at wss://mpmulti-8rlf.slack-msgs.com/websocket/enDEorpAThym9rnzQrHq3iCzLqA0CPqoFnQsqOp5WLob8C7_DObTHQrsXNsWf2w83dOOzkr2VmLIg5Bty0nAEUfhELZ9V0rKjWSDYk4AwNL-oTXjOG6Sc8KpHhN-So5Kyj5tMUST8zu9qWN2zoTcSiZhpHk_BvG6T37MfnBVgk0=
2017-04-19 08:07:20.733 ERROR 3941 --- [cTaskExecutor-1] o.s.w.s.c.WebSocketConnectionManager : Failed to connect
javax.websocket.DeploymentException: The HTTP request to initiate the WebSocket connection failed
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:314) ~[tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:150) ~[spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:147) ~[spring-websocket-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
Caused by: java.io.EOFException: null
at org.apache.tomcat.websocket.WsWebSocketContainer.processResponse(WsWebSocketContainer.java:676) ~[tomcat-embed-websocket-8.5.4.jar:8.5.4]
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:303) ~[tomcat-embed-websocket-8.5.4.jar:8.5.4]
... 4 common frames omitted
2017-04-19 08:07:21.743 INFO 3941 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@50b472aa: startup date [Wed Apr 19 08:07:17 BRT 2017]; root of context hierarchy
2017-04-19 08:07:21.784 INFO 3941 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/slash-command],methods=[POST],consumes=[application/x-www-form-urlencoded]}" onto public me.ramswaroop.jbot.core.slack.models.RichMessage example.jbot.slack.SlackSlashCommand.onReceiveSlashCommand(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
2017-04-19 08:07:21.787 INFO 3941 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-04-19 08:07:21.787 INFO 3941 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-04-19 08:07:21.808 INFO 3941 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-19 08:07:21.808 INFO 3941 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-19 08:07:21.831 INFO 3941 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-19 08:07:21.926 INFO 3941 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-04-19 08:07:21.958 INFO 3941 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-04-19 08:07:21.962 INFO 3941 --- [ main] example.jbot.JBotApplication : Started JBotApplication in 4.855 seconds (JVM running for 5.124)
And here are all the changes I made to the original jbot-example project:
~/IdeaProjects/jbot$ git diff
diff --git a/jbot-example/src/main/resources/application.properties b/jbot-example/src/main/resources/application.properties
index 940f526..beb1318 100644
--- a/jbot-example/src/main/resources/application.properties
+++ b/jbot-example/src/main/resources/application.properties
@@ -3,6 +3,6 @@ spring.jackson.property-naming-strategy=SNAKE_CASE
# slack integrations
rtmUrl=https://slack.com/api/rtm.start?token={token}&simple_latest&no_unreads
-slackBotToken=xoxb-50014402slackbottokenx29U9X1bQ
+slackBotToken=<MYTOKEN>
slashCommandToken=X73Fv3Tokenx242CdpEq
slackIncomingWebhookUrl=https://hooks.slack.com/services/T025DUwebhookurloOYvPiHL7y6
\ No newline at end of file
I am trying to send attachments as part of the reply to slack.
I made a new method called replyJSON to handle the json
public void replyJSON(WebSocketSession session, Event event, Message reply) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode replyJSON = mapper.readTree(encode(reply.getText()));
((ObjectNode) replyJSON).put("type", EventType.MESSAGE.name().toLowerCase());
if (reply.getChannel() == null && event.getChannelId() != null) {
((ObjectNode) replyJSON).put("channel", event.getChannelId());
}
session.sendMessage(new TextMessage(replyJSON.toString()));
if (logger.isDebugEnabled()) { // For debugging purpose only
logger.debug("Reply (Message): {}", replyJSON.toString());
}
} catch (IOException e) {
logger.error("Error sending event: {}. Exception: {}", event.getText(), e.getMessage());
}
}
This takes json I already have created and adds the fields to it that the standard reply function sets.
Here is an example of the json I am getting from the call to reply.getText()
{
"text": "Good Check",
"attachments": [{
"color": "good",
"text": "Thing is good",
"title": "Thing1"
}, {
"color": "good",
"text": "Thing 2 is good",
"title": "Thing 2"
}
],
"type": "message",
"channel": "CHANNEL_ID"
}
The issue I have is that only the contents of the "text" field are being displayed.
Are there issues with sending attachments from the bot that I am unaware of?
This happens when I run the server locally or even on amzn. After a while when there are no interactive slack clients talking to the bot. The connection becomes stale, and no message is received by the jbot server. Maybe the connection is reseted by slack server, but I am not sure how to handle this.
I was thinking about reinitializing Bot every so often, as I couldn't figure out the time it takes to make the connection stale.
I'm trying to include BotKit in a Maven project but when I run mvn install
or verify
, it appears to hang while downloading
It appears I was just being impatient. I'll note that the download took 17:51 for me on a 20Mb/s wireless connection. Not sure why it took so long.
rtmUrl=https://slack.com/api/rtm.start?token={token}&simple_latest&no_unreads
slackBotToken=xoxb-50014402slackbottokenx29U9X1bQ
slashCommandToken=X73Fv3Tokenx242CdpEq
slackIncomingWebhookUrl=https://hooks.slack.com/services/T025DUwebhookurloOYvPiHL7y6
why in rtmUrl there is {token}
. Do i have to replace it with one my application tokens from slack or what?
similar question for slashCommandToken
. I couldn't find it on slack website that i have to generate tokens for these.
Currently there is no real conversation object, so I did not find how to attach data to a conversation to keep tracks of what was said between steps.
Did I miss something ?
The generic model for attachment should also have attribute for markdown.
For eg:
{
"attachments": [
{
"title": "Help Documentation",
"title_link": "https://docs.google.com/xxxx/usp=sharing",
"text": "Here is a quick guide of what I can do",
"color": "#7CD197",
"mrkdwn_in": [
"text",
"pretext"
]
}
]
}
Markdown is an array of string and allows users to format the within attachment as well.
Is it possible to get the info of a user like email?
getUser().getProfile().getEmail() returns null
I'm able to build and execute the bit trough intellij but the bot doesn't connect to slack. When I tried checking with wireshark it doesn't produce any tcp messages(that I was able to capture).
Here's the bootup and shutdown log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.0.RELEASE)
2017-04-07 10:52:19.364 INFO 13200 --- [ main] br.jus.tjse.hal.JBotApplication : Starting JBotApplication on 17263-debian with PID 13200 (/home/msl09/IdeaProjects/jbot/jbot-example/target/classes started by msl09 in /home/msl09/IdeaProjects/jbot/jbot-example)
2017-04-07 10:52:19.367 INFO 13200 --- [ main] br.jus.tjse.hal.JBotApplication : No active profile set, falling back to default profiles: default
2017-04-07 10:52:19.429 INFO 13200 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@50b472aa: startup date [Fri Apr 07 10:52:19 BRT 2017]; root of context hierarchy
2017-04-07 10:52:20.736 INFO 13200 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 5555 (http)
2017-04-07 10:52:20.746 INFO 13200 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-04-07 10:52:20.747 INFO 13200 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.4
2017-04-07 10:52:20.806 INFO 13200 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-04-07 10:52:20.806 INFO 13200 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1380 ms
2017-04-07 10:52:20.906 INFO 13200 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-04-07 10:52:20.909 INFO 13200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-04-07 10:52:20.909 INFO 13200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-04-07 10:52:20.909 INFO 13200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-04-07 10:52:20.909 INFO 13200 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-04-07 10:52:21.226 INFO 13200 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@50b472aa: startup date [Fri Apr 07 10:52:19 BRT 2017]; root of context hierarchy
2017-04-07 10:52:21.289 INFO 13200 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-04-07 10:52:21.290 INFO 13200 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-04-07 10:52:21.320 INFO 13200 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-07 10:52:21.320 INFO 13200 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-07 10:52:21.352 INFO 13200 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-07 10:52:21.507 INFO 13200 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-04-07 10:52:21.557 INFO 13200 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 5555 (http)
2017-04-07 10:52:21.562 INFO 13200 --- [ main] br.jus.tjse.hal.JBotApplication : Started JBotApplication in 2.527 seconds (JVM running for 2.822)
2017-04-07 10:55:18.738 INFO 13200 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@50b472aa: startup date [Fri Apr 07 10:52:19 BRT 2017]; root of context hierarchy
2017-04-07 10:55:18.740 INFO 13200 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
On the application.properties I have only set slackBotToken with our own token.
Besides that I have configured the JVM to pickup our proxy configurations. I tested that they work by using a small "main" that simply opens a stream to the rtmURL.
Any ideas on what could be happening?
Hi Ram,
Is there a way I can implement a conversation flow similar to javascript botkit framework. Can you provide me any hint of how to implement this.
Krishna
My integration works perfectly if the user input just "@slackbotName message" with the code getting the input text and outputting the desired result based on this
However if the user inputs something before this such as "Hi '@slackbotName message'" the code reads all the text the user has typed not just the part following the "@" this causes the output to not display properly, is there anyway to get it so it only reads the message from the "@" onwards?
getUser()
in event returns null
. In other words, user
in event
isn't set.
Hi Jbot dev,
I wanted to post a welcome message when a new user joins the team. The team_join event is getting fired properly but the channelId is coming null and hence no welcome message is posted.
Could you point me in the right direction here?
Thanks
Hi, awesome bot, great job.
I cannot figure out what slackBotToken
should I use if I want to distribute my Slack bot in Slack App directory? When I go to the Bot user
menu in Slack app page, I can just enable the bot, but there's no token out there I can use.
Besides, the RTM url that JBot uses https://slack.com/api/rtm.start
is per team only (based on the documentation), so it won't work if I want to listen to multiple teams who install my app.
Could you please clarify how should I use it?
Are there any plans to include this feature in the bot?
Sounds really cool
message-threading
What EventType(s) do I need to use to make my JBot automatically post a message on Slack at a certain time every day? (eg. 6pm everyday)
If I'm not supposed to utilize an EventType to accomplish such a task, are there any other ways of doing so?
Ive noticed that my bot keeps going offline on slack and so when a user tries to message it, it does not give any output back, when checking Bluemix, which is where I have deployed the bot, the app is still reported as online and there are no logs reporting any issues, the only way I have found to resolve this is to restart the bot on Bluemix, this then makes it active on Slack again and allows a user to message it, but then after a while the same thing will happen again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.