Giter Site home page Giter Site logo

slack-venmo-integration's Introduction

Building a Venmo Integration for Slack

Overview

http://bit.ly/slackmo

This is a Venmo Slack integration leveraging Slack’s slash command. Within Slack you can easily pay your co-workers using a simple command. Currently, it supports the ability to pay using their Slack username.

Slash Commands

Slash Commands are a great way to get started with Slack integrations. Anytime a user initiates a slash command (/slackmo), Slack merely POSTs the necessary data to your provided endpoint. A sample request can be seen here:

token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
response_url=https://hooks.slack.com/commands/1234/5678

You endpoint must parse through this data and provide a JSON response to Slack, so that it can respond back to the user. In this app, we use user_name, user_id & command to make payments on the user’s behalf.

Please Note: This app requires additional consideration around security. Ideally, the user should authenticate with the app every time they attempt to make a payment. A user could spoof one another by making a POST request to my endpoint with another user’s username and pay himself. I think it defeats the purpose of a slash command if a user must authenticate each time, so I’d be curious to see if I’m missing something here.

Usage

Supports 3 commands:

  • /slackmo [@username] [$amount] [note] . For example, /slackmo @mauerbac $10 lunch!
  • /slackmo help
  • /slackmo [@username] add [phone #] - Used for adding a new co-worker

**You can request money by using a negative dollar amount. i.e $-10

Building the app

A first time user will be immediately prompted to Oauth with Venmo. A user must authenticate with Venmo so the app can make payments on their behalf. This token is saved in the app’s database for later use. A Slack username doesn’t necessarily map to a Venmo username, so I needed to create a mapping of Slack username to a Venmo identifying. In this app, I used the Slack username and Venmo phone number. If the receiver hasn’t used the app, you must supply their phone number using the /slackmo @will add [number] command.

The app has two endpoints: /main & /venmoauth, which can be seen in api/views.py. Slack POSTs all slash command data to the main endpoint and Venmo uses the venmoauth endpoint in the OAuth process.

Housekeeping

  1. Register a custom slack command.
  2. Register an App with Venmo here. Make note of Client ID & Client Secret.
  3. Supply Venmo Client ID, Client Secret and Slack Token in api/views.py.
  4. Deploy the application and provide Slack with your endpoint.
  5. Give it a try!

Next steps

  • Add support to refresh Venmo Auth tokens when expired.
  • Add better authentication to avoid co-worker spoofing.
  • Add additional commands.
  • Become an offical Slack Integration via the Slack Button.

Reach out to @mauerbac with questions/feedback. Thanks!

slack-venmo-integration's People

Contributors

ivey avatar mauerbac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.