If this, then: code.

Trigger code on events in your favorite web services.

Why wait? Sign up now and start trying Hoist for free today.

Build powerful integrations with code

We'll connect you to your favorite data sources to let you know when something important has happened. You build the output.

1

1. Connect

Seamlessly connect to your favorite data sources and we'll watch them in the background.

2

2. Choose a Trigger

When something happens in your data sources, we'll run an event. You choose which events you want watch by selecting them from the 'trigger' menu.

3

3. Publish your Code

Using our built in library and NodeJS, you can get and post data from any of your data sources, or even pull in NPM packages to do completely new tasks.

1 2 3 4 5 6 7 8  
module.exports = function(event) { return Hoist.connector('slack') .get('/chat.postMessage', { channel_name: "watercooler", text: event.payload.message, username: 'Jarvis', }); }; Sample: Posting a message to a Slack channel.

Sample Modules

Here are some examples of what you can do with Hoist.

Copied
module.exports = function(event, done) {

  var email = extractEmails(event.payload.text);

  if(!email) {
    done();
    return;
  } else {
    email = email[0];
  }

  return Hoist.bucket.set('default')
    .then(function() {

      /* Get user from Intercom */
      return Hoist.connector('intercom').get('users', { 
        email: email
      }).catch(function(err) {
        return null;
      });

    })
  .then(function(user) {

    if(user) {
        
    Hoist.log(user);

      /* If a user was found, build the message block */
      return Hoist.connector('slack')
        .get('/chat.postMessage', formatMessage({
          channel_id: event.payload.channel_id,
          user: user, 
          email: email
        }));

    } else {

      /* If no user found, build an error block */
      return Hoist.connector('slack')
        .get('/chat.postMessage', formatMessage({
          channel_id: event.payload.channel_id
        }));

    }

  }).catch(function(err) {

    return Hoist.log(err.message);

  });

};

function extractEmails (text)
{
  return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
}
function formatMessage(options) {

  /* This is the object that will be sent to Slack to create a message */
  /* Swap out the fields that you want to show */

  var fields = [];

  if(options.user) {
    if(options.user.session_count) {
      fields.push({
        title: 'Session Count',
        value: options.user.session_count,
        short: true
      });    
    }
    if(options.user.custom_attributes && options.user.custom_attributes.applications) {
      fields.push({
        title: 'Applications',
        value: options.user.custom_attributes.applications,
        short: true
      });    
    }
    if(options.user.location_data) {
      var loc = options.user.location_data.city_name ? options.user.location_data.city_name + ", " : "";
      loc += options.user.location_data.country_name ? options.user.location_data.country_name : "";
      fields.push({
        title: 'Location',
        value: loc,
        short: false
      });
    }
  }
  var message = {
    channel: options.channel_id,
    username: 'Hoist',
    icon_url: 'https://pbs.twimg.com/profile_images/514192322993471488/4cgcRw14_bigger.jpeg'
  };
  if(fields.length > 0) {
    message.attachments = JSON.stringify([
      {
        fallback: "User info for " + options.email,
        title: "User info for " + options.email,
        title_link: "https://app.intercom.io/apps/" + options.user.app_id + "/users/" + options.user.id,
        text: "Here's everything you need to know about " + options.user.name,
        fields: fields,
        color: "#13BCA4"
      }
    ])
  } else {
    message.text = "Sorry, user not found.";
  }
  return message;
}
Slack-Intercom Lookup
Ask Slack for information about a user, by asking "Slack, tell me about email@email.com".
AuthorHoist
Copied
module.exports = function(event, done) {

  return Hoist.bucket.set('default').then(function() {
  
    var slack = Hoist.connector('slack');

    var message = {
      channel: "#tweets",
      username: 'twitter',
      icon_url: 'https://slack.global.ssl.fastly.net/66f9/img/services/twitter_48.png',
      message: "https://twitter.com/" + event.payload.user.screen_name + "/status/" + event.payload.id_str,
      attachments: []
    };
    message.attachments.push(twitterAttachment(event.payload));
    message.attachments.push(tweeterAttachment(event.payload.user));

    /* slack api requires attachments to be stringified */
    message.attachments = JSON.stringify(message.attachments);
    
    Hoist.log(message);

    return slack.get('/chat.postMessage', message);
    

  })
  .catch(function(err) {

    return Hoist.log(err.message);

  });

};

var twitterAttachment = function(tweet) {

  var attachment = {
    author_name: tweet.user.name,
    author_subname: "@" + tweet.user.screen_name,
    author_link: "https://twitter.com/" + tweet.user.screen_name,
    author_icon: tweet.user.profile_image_url_https,
    text: tweet.text,
    color: "#0096EE",
    fallback: "New tweet from @" + tweet.user.name
  };
  return attachment;

};

var tweeterAttachment = function(tweeter) {

  var attachment = {
    color: "#e3e4e6",
    text: "User info for " + tweeter.name,
    fields: [
      {
        title: "Description",
        value: tweeter.description,
        short: false
      },
      {
        title: 'Followers',
        value: tweeter.followers_count,
        short: true
      },
      {
        title: 'Following You',
        value: tweeter.following ? "Yes" : "No",
        short: true
      }
    ]
  };
  return attachment;

};
Twitter mentions to Slack
Substitue the default Twitter/Slack integration for one that gives you more info about the tweeter.
AuthorHoist
Copied
var request = require('request-promise');

module.exports = function(event) {
  
  return request({
      uri: 'https://yourwebapp.com/webhook/incoming-invoice',
      data: event.payload,
      json: true
    })
    .catch(function(err) {
      return Hoist.log(err.message);  
    });
   
};
Simple Webhook
Create a webhook by posting a payload's data to a URL.
AuthorHoist

Why wait? Sign up now and start trying Hoist for free today.