Slack nodes for KNIME

I’ll merge it into the release branch today.

@raghum I have now deployed these changes on KNIME 4.1.

Please let me know if you get any success with after talking to the slack team or let me know if there’s anything they suggest doing that you need my help with.

Sorry we couldn’t get this working.

Hi Sam,

We are getting following error when I try to send message to channel after few tweaks. However, I am able to send the message through using https://api.slack.com/methods/chat.postMessage/test

ERROR Message Slack channel 0:6545 Execute failed: No value present

Can you share the full stack trace so I know where in the code that error happened and I’ll take a look in the morning?

Cheers

Sam

Here, it is

2020-04-23 13:06:48,485 : ERROR : KNIME-Worker-514-Message Slack channel 0:6545 : : Node : Message Slack channel : 0:6545 : Execute failed: No value present
java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:135)
at com.sjwebb.knime.slack.api.SlackBotApi.sendMessageToChannel(SlackBotApi.java:218)
at com.sjwebb.knime.slack.nodes.messages.send.SendMessageNodeModel.execute(SendMessageNodeModel.java:52)
at org.knime.core.node.NodeModel.execute(NodeModel.java:737)
at org.knime.core.node.NodeModel.executeModel(NodeModel.java:571)
at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1236)
at org.knime.core.node.Node.execute(Node.java:1016)
at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:557)
at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:95)
at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:218)
at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:124)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:334)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:210)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)

Sam, currently, the message nodes doesn’t support to have Title. Do you have any idea to introduce this change?

I don’t believe slack ‘messages’ as I’ve been referring to them have a title.

Slack can however create posts and snippets which do seem to have a title, is that what you are referring to?

I’d be happy to look into making a node that can do that if that’s what you mean?

For example in the below image, the top is a message as the node would send the second is a post and the third is a snippet. The nodes currently don’t do posts of snippets.

W.r.t to the issue you posted the exception for the node has come across a state it wasn’t expecting. The check for whether the channel exists/can be found passed but the node was not able to find a conversation with that channel. Do you have a lot of channels in your workspace? It looks like there’s a bug that will trigger if you’ve got more than 100 channels and the channel you want to talk to is 101 or greater in this list.

The good news here is that once I’ve fixed this I think it will finally work for you. I’ll let you know when I’ve pushed through the fix for this (probably tomorrow morning UK time).

Cheers

Sam

I pushed a quick fix, the tests passed and nightly and 4.1 sites have built.

Worth giving that a go to check if it worked.

Yes, this works for me. Thanks again.

Coming to title. Its not exactly title. I would like to change the App/Workspace name while sending message. My use case is, Lets say I am sending Sales/HR alters then it should be

Important alert from Sales
Message goes here…

Important alert from HR
Message goes here…

As of now, It always appears as

App/workspace name
Message goes here…

Makesense?

1 Like

Great I’m glad it’s working, sorry it took so long to get there.

Oh I see. I don’t believe this is something I can change as the bit in bold is the display name or the user/bot.

What you could do is set up a bot for Sales and a bot for HR etc and then use appropriate token in knime depending on which bot you want the message to come from?

1 Like

Yes, I do not want to create multiple apps for each type of activity. HOOKS service is having this option. Let me check with Slack APIs.

Maybe it’s the username param

Set your bot’s user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.

If so I can look at exposing that as an optional parameter in the nodes.

Yes, exactly. This is what I was referring to.

Could you incorporate this functionality?

Sure I will try add this over the next few days.

Can you point me to where you’ve been able to get this working? Is HOOKS the webhooks functionality?

I tried setting the username when running the api request but it would appear it’s being ignored. I did some searching and it looks like this isn’t guaranteed to actually work:

https://api.slack.com/changelog/2017-09-the-one-about-usernames

  • Slack apps and their bot users should not use the username field when authoring a message. The username is part of your app’s configuration and will not always be settable at runtime.

It also seems to ignore the username if using it in slacks API test: chat.postMessage method | Slack

Could you please provide me some details on how you’ve seen this working and I’ll investigate further.

EDIT:

**image **

It seems my new functionality does work but only on an old slack bot type not the new bot type.

Edit 2:

Posting in public channels and customizing message authorship

New Slack apps do not begin life with the ability to post to any public channel without joining, as classic bots did. Nor do they start with the ability to adjust username or icon when posting messages.

Good news: with two special scopes, you can gain those abilities by asking for them explicitly. Request the chat:write.public scope and chat:write.customize scope, respectively, to gain the ability post in all public channels and adjust your app’s message authorship.

Check out the chat.postMessage documentation for more details.

Seems you can get the functionality in new/modern slack apps by adding chat:write:customize scope. This now seems to work:

image

image

I’ll do some testing, tidying up and then deploy he new functionality.

Cheers

Sam

@raghum the change is available in version 2.2.0

This new update adds the ability to optionally set a username in the message channel nodes. The new feature requires the chat:write:customize scope otherwise the username will not be changed (message will still send).

Cheers

Sam

1 Like

Thanks Sam, It is working as expected.

Could you also have this feature for User node?

Is this version part of the release now?

Is this version part of the release now?

Version 2.2.0 is on the 4.1 release branch.

Could you also have this feature for User node?

image

Yes but it still pops up under the ‘knime’ app (my app name is knime). I’ve added this behavior and it will appear in the trunk and 4.1 release branch as version 2.3.0 within the hour hopefully.

Cheers

Sam

Sorry, one more feature to have flexible ICON. Could you also include this feature?

The parameter where you pass in a url to an image?

I think I’ll just look at adding all the optional parameters from the chat.postMessage API method then release 2.4.0.

I assume you want this for channel messages and user messages?