code everywhere
technology, web services and applications

messaging slack from phantomJS

posted on March 7, 2015, 8:44 pm in js

With all testing frameworks, its useful to get a message when your tests are completed instead of constantly looking at log files. And many companies are now using Slack for communication.

Here's how to get a message from PhantomJS to Slack without any plugins.

var slackPage = require('webpage').create();

message "Send this message to Slack!";
postData encodeURI('token=YOUR-SLACK-API-TOKEN&channel=#YOUR-CHANNEL&username=YOUR-USERNAME&text=' message);
headers = {
};'''post'postDataheaders, function( status ) {

Replace the token, channel, username and message with your details and what you'd like to send.

recent posts

< back
find something helpful? send us some coin BTC 1A6KbS5AmYQVAh5Zcy9rVSnMAoCEunLUqT

(ad) Need Hosting? Try Linode, VPS Starting from $5