Integrate Equipment to Slack

Does anyone have some use cases of integrating their equipment to slack instead of the ancient “eMaIL nOtIfICATtHuNs” most líquid handlers and plate readers come with?

Curious how and if people achieve this?

Slack has webhooks so if your automation platform has the ability to send an HTTP request (or a modern scripting language) its pretty straight forward

I believe Microsoft Teams also has webhooks, but they also allow you to send an email directly to a channel, so that could be an easy no-code option.

1 Like

I think the only liquid handlers with modern scripting language capabilities is a Lynx and an Opentron so where does that leave Biomek, Hamilton, and TECAN users :frowning_face:

Hamilton has an HTTP library that could potentially work with Pete’s solution, haven’t played around with it a ton. As for the modern scripting language capabilities for Venus, my favorite quick and dirty way is using shell scripts to call bash or python commands. Write a script, build the string for the command + arguments in Venus, and fire away.

@smohler have you tried using HSL in Venus methods? Have been tempted to dive deeper into that space to solve a variety of data transfer/communication hurdles but haven’t had the chance to explore in depth.

@LukeWitt beat me to it…I was just poking around Fluent Control looking at the UI; it allows you to run an application as a task, so if you wrote a python script, node script, etc. that makes an http request, you can run it and pass in command line parameters. Looks like they also have VB script support.
I don’t have a lot of expe

1 Like

Oh and you left out the most Awesome Liquid Handler - The Bravo. You can make an HTTP request through the ancient JavaScript engine at any task. :slight_smile:

2 Likes

@LukeWitt so that’s great to hear! We do a lot of hitting that run shell command on our liquid handlers.

I’ve tried using the JSON package Hamilton has but it really didn’t seem to be much better than just using the shell script methodology.

@Pete man TECAN really be bustin down tech innovation walls with that one :laughing:

I guess I posted this topic to see what others are doing. I’d be interested to loop someone in that actually uses the HTTP or JSON library for web integration stuff.

Kudos to Tecan, they’re doing some of the most interesting stuff at the moment. They even offer an integrated line of communication with IFTTT through their Tecan Connect software.

When I build things for scientists or technicians (who are often running around juggling many things and meetings), I’ll setup a slack channel with alerts for them and do it “natively” through Fluent Control. This lets them know where they are in the process and if their attention is required.

You can even send custom messages through Slack like below,

Edit: Here’s a link to the kind of integrations that are supported out of the box.

2 Likes

@luisvillaautomata holy fuck balls. This is crazy I had no idea. Do you have control over the json message package you send to Slack or is it discrete message cases.

1 Like

What’s the use case that you have in mind?

The goal with IFTTT is to simplify the programming burden to increase IoT adoption. Tecan probably just saw this and was like, here’s an ecosystem for integration we can play with and give to customers to figure out. You can in theory (I think) create an applet that triggers more than a simple custom send message to Slack. You can send that message (whatever it is) and have some other entity parse it and run some sort of program on the backend… I don’t see why that might not be possible, I just haven’t had that level of use case for it.

1 Like

+1 to Pete’s webhooks reference.

Building the opentrons integrations was absolutely trivial.

image

For the Hamilton, using the Venus software, we had to pull another trick: find out how to run any miscellaneous bash command and then write a simple python script with the message as the input.

A bit limited yes, compared to everything else you could do with a slack app, but very effective to include notifications in between liquid handling steps

image

3 Likes

They do!? Could you provide a link to it, please?

I don’t have a link, I’m afraid.

I believe it was called a Shell command, you can find it on the Venus software help docs.

Quick and dirty for an instrument that generates files like a plate reader:

Replace the URL and Directory to watch in the code with your slack webhook url and the directory to watch with your directory. Test it by dropping files into your directory.

import time
import requests

from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler


url = 'Enter Webohook URL Here'

class Watcher:

    # -- Change this to a directory to monitor

    DIRECTORY_TO_WATCH = "watching"

    def __init__(self):
        self.observer = Observer()

    def run(self):
        event_handler = Handler()
        self.observer.schedule(event_handler, self.DIRECTORY_TO_WATCH, recursive=True)
        self.observer.start()
        try:
            while True:
                time.sleep(5)
        except:
            self.observer.stop()
            print ("Error")

        self.observer.join()


class Handler(FileSystemEventHandler):

    @staticmethod
    def on_any_event(event):
        if event.is_directory:
            return None

        elif event.event_type == 'created':

            # Take any action here when a file is first created.
            print ("Received created event - %s." % event.src_path)
            myobj = {"text":"Hey Just recieved some reader data: %s" % event.src_path }

            x = requests.post(url, json = myobj)

            print (x)

        elif event.event_type == 'modified':
            # Taken any action here when a file is modified.
            print ("Received modified event - %s." % event.src_path)


if __name__ == '__main__':
    w = Watcher()
    w.run()

Credit to this guy for the watcher code: Using Python's Watchdog to monitor changes to a directory

2 Likes

Ah sorry, I was replying to Luke, we use the shell commands already - very helpful!

Hamilton Instinct V - you can run executables compiled from scripts and even pass arguments via stdin, read stdout and stderr.

3 Likes

While I am late to the party, here is what we did @smohler.

We created a Slack Bot in slack and then made a small Python script. That script is run on a Hamilton using two avenues: 1) VENUS Shell command to send Milestone or user alerts and 2) From ExecuteOnError Config commands for STAR errors to post that there has been an error.

Further, at startup we ask for the Operators name. We use that name to find their Slack handle and send milestones or intervention alerts ONLY to that Operator. WE don’t want to blast a pool of Operators a bunch of irrelevant information because after a while of being blasted with junk alerts Operators tend to become numb to the alerts and alerts are important. Error alerts are sent to the Operator as well as to the Automation Team for visibility and troubleshooting.

Overall the Slack integration this way is functioning really well. We libraryized the slack calls for easy use and so that we can deploy it as part of our custom in house library across all of our Hamilton devices. The Python script itself is vendor agnostic, so as long as the vendor software can call an executable then it will work when/if we diversify our instrument stack.

4 Likes

Anybody interested in sharing their actual code? I feel this thread could get us the closest to a stack exchange vibe to a random list googler out there.

With lab automation you’d need to post like these snippets, the Python, the executable or batch file, and the liquid handling programming IDE steps?

2 Likes

For those who don’t know you can share syntax highlighted code snippets with triple backticks ie

```language
code
```

We’ve been using koa/node.js docker as middle man to interfacing Hamilton and other sequencing devices. e.g. MiSeq/iSeq has control software REST API available in http://localhost:8888/swagger/, but many actions required multiple steps REST API calls and orchestration. We just made simple REST API available to Hamilton Venus, and use HTTP/JSON Lib to initiate API calls, Then let the node.js server does the thing.
For the slack integration, we just exposed alert REST API to Hamilton run control. and then the node.js server can send message to slack through web hook interface.

1 Like