Run a function if I receive a direct message or a mention in Slack?

I'm sure this is doable, but don't know where to start.
So, my idea is to switch on a tp-link light, if I have an unread direct message or a @mention of my username in Slack and then turn it off if I clear my unread count.

Does anyone know of a guide I can follow?

I am not familiar with slack other than it is yet another platform for people to talk.

You will need a node (don't ask me which) that listens to the slack channel (or what ever they are called).

You then need to look at the message/s that come out of it.

Going on what you said about @mention it shouldn't be hard.

Say the message looks something like:

@slack_topic @person_talking <their text here.>

If in the <their text here> part there is your name mentioned, you could use a switch node.

Configured something like:

[{"id":"5874a312.36fb9c","type":"switch","z":"b4f1ccd4.5e8d1","name":"Look for your name","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"<your name here>","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":330,"y":810,"wires":[[]]}]

Then if it gets a message (payload) which contains your name, it sends it to the output.

Then you send that (probably via a change node to set the payload) to your tp-link light.

But that's the basics.

But I hope it helped.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.