A NodeJS server that manages expenses and budgets via Slack through ProcessMaker.io
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


SpendifiJS Server for Slack

** Keep track of your day to day expenses with SpendifiJS. This package allows you to install SpendifiJS on your server and send and receive spend requests that can be accepted and rejected directly in Slack. **



  • BPMN connection to ProcessMaker.io, to accept and reject spend requests.
  • Image recognition to extract amounts and descriptions from receipts.
  • Stroke Width Transform integration in JavaScript for rapid text detection.
  • NodeJS server to handle HTTP requests.
  • Support for Slack Events API to handle messages and files sent in channels.
  • Support for Add to Slack button.

Sending requests via Text

This video shows how easy it is to send a Spend Request with SpendifiJS in Slack.

Spendifi via Text

Sending requests via Photo

This video shows the process of sending a Spend Request with SpendifiJS via photo.

Spendifi via Photo

Image processing through SWT

The Stroke Width Transform (SWT) is still considered one of the best text detection algorithms out there. It was implemented in JavaScript as an experiment for this project, but it can easily be ported to C++11 and invoked using the JS bindings contained in this project.

We start by detecting edges using a canny filter. Once we find the biggest polygon we crop the image around it and reduce its resolution to imporve performance. After that we apply the SWT filter to the image and look for the components / letters in it. After that we apply a classifier (Depth First Search) to find lines of components (words / sentences) and remove the unwanted components. Finally we pass the resulting image through OCR and look for the amount and description:

Note: There are still a lot of room for improvement like using a morphological erosion instead of looking for connected components using their heights, a dynamic thresholding to remove unwanted components, etc. Please leave an issue if you think of something else.


How to Install

On your server

On ProcessMaker.io

On api.slack.com

  • Create a new App.
  • Enable the Interactive Components for your app using the ProcessMaker.io URL (https://YOURINSTANCEID.api.processmaker.io/api/v1/processes/Slack%20Action%20Receiver/events/Slack%20Response%20Received/webhook).
  • Enable the slash commands
  • Create a slash command called **"/spendifi"**and two variables for the usage hints "[amount $##.##] [descriptionNoSpaces text]"
  • Enable Event Subscriptions using a secure link to your NodeJS server and the following subscriptions:
    • message.channels
    • message.im
    • message.mpim
    • message.groups
  • Create a bot for your app and enable the option "Always Show My Bot as Online "
  • Go to "OAuth & Permissions" and copy your Bot User OAuth Access Token

On Slack

  • Create a new channel called testprocess

On your server

  • Clone this repo in your server
  • Edit the BPMN file provided in the repo "slack.bpmn" to add your Bot User OAuth Access Token: aData.bot_token="xoxb-YOURSLACKBOT-ACCESSTOKEN";
  • Create new environment variables using your Slack App Details (and save them to your bash_profile file) $ export SLACKCLIENTID=yourSlackId $ export SLACKCLIENTSECRET=yourSlackAppSecret $ export SLACKVERIFICATIONTOKEN=yourSlackToken $ export SLACKTEAMID=yourSlackTeamId $ export SLACKTEAMNAME=yourSlackTeamName $ export SLACKOAUTHTOKEN=yourSlackOauthToken $ export SLACKBOTOAUTHTOKEN=yourSlackBotOauthToken $ export SLACKBOTUSERID=yourBotUserID
  • Start the server with node server.js