When Robots Do Biology for You — Turning Slack into a Personal Lab Assistant

Max Lamb
5 min readMar 25, 2016

--

Messages from the cloud lab

Doing biology in the cloud is so powerful because it frees you from the manual labor and endless pipetting of the lab. But that shouldn’t prevent you from knowing exactly what the robotic lab is doing at a particular time. Now, by building a handy Slack integration with Transcriptic using a bit of Webhooks and AWS, you can do exactly that. And you don’t even have to touch a pipette.

I undertook this integration as a side-project at work the other day after my coworker, Ben Miles, led the way and made his own integration using Node.js. While it takes a few steps, I figured it might be useful for someone else out there looking to incorporate some biology into their Slack messages. And I like Python much better than Node.js.

The first step, of course, was to create an account with Transcriptic and decide which experiment I wanted to do (see our Getting Started docs for some help on this). We have a library of protocols to choose from, or you can programatically access the lab and code your own experiment using Autoprotocol. In my case, I decided to use our `Transform, Spread, Pick` protocol to transform a pGFP plasmid from our reagent catalogue into some E.coli bacteria(1). Who doesn’t like making glowing bacteria?

Overview for the `Transform, Spread, Pick` protocol on Transcriptic’s Protocol Browser.

Now that my run is submitted, it’d be nice to get updates when instructions are completed so that I know how my run is progressing. To do that, I’ll use Slack’s Webhooks integrations with a little help from AWS Lambda and API Gateway.

I tackled the Webhooks integration with Slack first. I decided to turn Slackbot into my personal lab assistant and put the notifications in that channel, and what I really wanted from this step is the Webhook URL that Slack generates. I also made “Dexter’s Lab” the name of my integration (fulfilling childhood dreams) and uploaded the Transcriptic icon as the logo.

Once I had my Webhook URL, I headed over to AWS Lambda, which amazingly lets you run code without provisioning or managing servers. I highly encourage you to check out the AWS Lambda Getting Started docs if you haven’t used Lambda before, as I won’t be covering all the details here (I hadn’t used the service before creating this integration but was able to get it up and running with the documentation fairly quickly). For AWS Lambda, we need to create a function that will run every time a message is sent from a Transcriptic run, either about an instruction completing or a run completing. The function will take this message and transform it into a format suitable for our Slack integration.

Example payload to send to Slack

My language of choice is Python, so I created the following function to produce the Slack message shown in the image at the beginning of this post.

The Webhook URL from Slack is where the request should be posted, specifically in the following line which will ensure that our nicely formatted message is sent to Slack:

post_response = requests.post(url=<webhook_url>, data=json.dumps(payload))

Unfortunately the function can’t be typed straight into the Lambda console since it uses the `requests` package. I had to create a deployment package that includes the function and requests package instead.

Once the deployment package was created and uploaded to Lambda, I turned my attention to the AWS API Gateway. Once again, I’d highly encourage you to check out the API Gateway Getting Started docs if you haven’t used it before. Specifically, I created an API Gateway API for Lambda functions with a `transcripticresource2` resource (2 because the first time didn’t go so well) and a POST method linked to my `transcriptic_update` Lambda function.

AWS API Gateway Resources

Once this API was deployed, I used Postman to test it by sending the following JSON blob in the body of the request:

After all that, it worked! My `Transform, Spread, Pick` run launched a few days later a I received step-by-step updates as it progressed. Even better, the run itself produced some nice looking colonies of bacteria (even if they were a little streaky). Best of all, I was able to do this without ever touching a pipette or stepping foot in the lab.

Plate of transformed bacteria. I didn’t even have to pick up a pipette!

Building this got me thinking, it would be really cool to have Slackbot be an actually useful lab assistant. There could be a Transcriptic integration where you tell Slackbot that you want to run a `Transform, Spread, Pick` or `Genotyping` protocol and it asks you for the relevant parameters, as well as suggests samples to pull from your inventory or helps you search for those samples. It could even report back the results of runs and suggest how you should run your next experiment, in the vein of closed-loop biology that is discussed so much at Transcriptic. Hopefully one day soon. For now, you can use the process described above to receive notifications and see the robotic cloud biology lab working for you as its actually happening.

Notes

  1. I had already provisioned pGFP plasmid into my Inventory using a protocol that I wrote on my own using Autoprotocol. This protocol is also available as a Gist on my Github page, and you can find instructions for running it in Transcriptic’s documentation.

--

--