Automate Recurring Venmo Payments with Github Actions and IFTTT

UPDATED ON APR 27, 2023 : 1123 words, 6 minute read โ€” GUIDES

Like so many tinkerers, I love to automate small parts of my life, while ignoring any actual work I should be doing. After stumbling on Joeโ€™s Venmo automation , I immediately swept all the important things off my plate to have some fun. Now letโ€™s set up automatic payments on Venmo in less than an hour โ€” with email notifications for peace of mind!

Clock + robot snake + Venmo

Why not Nocode (Zapier, IFTTT, etc.) ๐Ÿ”—︎

Youโ€™ll need to know how to code a small amount for this guide. This setup is an alternative to the Zapier Venmo integration and IFTTT Venmo integration, which donโ€™t seem to exist anymore (if they ever did). Venmo shut down their developer APIs and have had them in maintenance mode since 2016 , so unlikely for anything to change on that front. Normally I look to nocode tools first for projects, but unfortunately in this case, youโ€™ll need to know how to run code online.

Ingredients ๐Ÿ”—︎

The 3 pieces you will need to set this up (in <1 hour):

  • A scheduled trigger (GitHub actions, AWS Cloudwatch, etc.)
  • A place to run a Python script + itโ€™s dependency (GitHub actions, PythonAnywhere, Node.js with Autocode is in exploration)
  • A free or cheap notification service (IFTTT, AWS SNS, etc.)

I use GitHub Actions + Python script + IFTTT for sending emails, but feel free to step off the beaten path if you have other ideas.

How to set up automatic payments on Venmo ๐Ÿ”—︎

Diving into the meat & potatoes you came for, how to actually get this dang thing running.

  1. (Optional) ๐Ÿ’Œ Set up IFTTT notifications

    โ„น๏ธ If you donโ€™t care about being notified, skip this step and remove the notify() code in script.

    Example of the IFTTT notification email

    IFTTT allows a variety of target services , I originally used SMS, then converted to email since itโ€™s not an urgent alert.

    • Sign up for IFTTT account (might require downloading of the app).

    • Configure the Webhooks service in IFTTT.

    • Then set up your chosen notification service. My example script sends metadata about the Venmo request sent in the value1 field IFTTT provides. If you use the same, you’ll have to make sure that is mapped correctly to your chosen notification service.

      IFTT applet set-up screen

    • โœ… Use cURL or your favorite web request tool to test your webhook and ensure notifications are sending correctly.

    • Save your webhook URL as a Secret so the workflow can access it. In the browser, go to GitHub Repo -> Settings -> Secrets -> New Repository Secret.

  2. ๐Ÿ” Get Venmo access token

    โš ๏ธ๐Ÿšจ *This token has the same power with your Venmo account as you do, so be very careful with it! It will never expire unless you logout manually, as explained in the docs .

    I plan to update this guide to use Payment Links (a deeplink into the Venmo app that doesnโ€™t require account access) in the near future, but for now, you are forewarned.* โš ๏ธ๐Ÿšจ

    Youโ€™ll have to be comfortable working with Python dependencies to run these scripts locally.

    from venmo_api import Client
    # https://github.com/mmohades/Venmo
    
    print("Login using account to get an access token for the API.")
    email = input('Venmo Email:')
    if '@' not in email:
        print('! yo what the heck you sure thats an email')
        raise SystemExit
    password = input('Venmo Password:')
    
    Client.get_access_token(username=email, password=password)
    
    • Save the token as the Secret VENMO_ACCESS_TOKEN by going to GitHub Repo -> Settings -> Secrets -> New Repository Secret.
  3. (Optional) ๐Ÿ—บ Map Venmo usernames to IDs

    Then Venmo API requires payment requests to be tied to an ID, rather than the @username we humans use in the app. I did the mapping of usernames during setup and added them as environment secrets , but you can just as easily add 1 extra LOC to convert during regular runs.

    user = venmo_client.user.get_user_by_username(username)
    # Key is the 'user.id' part
    venmo_client.payment.request_money(amount, note, target_user_id=user.id, privacy_setting=PaymentPrivacy.PRIVATE)
    
  4. ๐Ÿ Modify the Python script

    The script I use has a simple entry point, then defines a separate function for each Venmo request I want it to make, YMMV. Youโ€™ll need to make some small adjustments based on how many requests you need it to make & how you fetch Venmo user IDs. The most important bits can be boiled down to this main.py:

    # main.py
    
    import os
    from venmo_api import Client, PaymentPrivacy
    # requests is pulled in by venmo_api
    import requests
    
    TOKEN_KEY = 'VENMO_ACCESS_TOKEN'
    IFTTT_WEBHOOK_KEY = 'IFTTT_WEBHOOK'
    
    def main():
        # load the access token from environ
        access_token = os.environ.get(TOKEN_KEY)
        if access_token is None:
            raise ValueError('[!] EVERYTHING IS BROKEN WE CANT GET ACCESSS AHHHHHH')
    
        venmo_client = Client(access_token=access_token)
    
    ....
    		# <venmo user id from mapping step>
    		c_user_id = os.environ.get('C_USER_ID') 
    		amount = 20.0
    		note = f'Monthly Internet'
    		try:
    	    venmo_client.payment.request_money(amount, note, target_user_id=c_user_id, privacy_setting=PaymentPrivacy.PRIVATE)
    			print('Successfully requested for internet $$')
    		  msg = f'Requested ${amount} Internet from C.'
    		except Exception as e:
    			print(e)
    			msg = '[!] Failed to request $$ for internet from C.'
    		notify(msg)
    
    ....
    
    def notify(msg):
        # notify with IFTTT webhook
        ifttt_webhook_url = os.environ.get(IFTTT_WEBHOOK_KEY)
        if ifttt_webhook_url is None:
            raise ValueError('[!] Dang, no webhook so cant notify myself :(')
    
        json_data = {
            'value1': msg
        }
        resp = requests.post(ifttt_webhook_url, json=json_data)
        print(resp.status_code)
        if resp.status_code >= 300:
            raise ValueError(f'Webhook resp was {resp.status_code}; not a success. Body: {resp.text}')
    
    main()
    
  5. ๐Ÿ‘จโ€๐Ÿ’ป Configure GitHub Secrets & Actions

    โ„น๏ธ Cron actions get disabled after 60 days of no activity on the repository - so either plan to push a commit every 50 days, or follow my approach and just wait until GitHub emails you.

    โœ‹ At this point you should have your VENMO_ACCESS_TOKEN saved in Secrets, along with the optional IFTTT_WEBHOOK or USER_IDs values. if you didnโ€™t, go back and do it.

    Now create your workflow definition at .github/workflows/<workflow-name>.yml . This is where you will define your schedule in cron. My example shows monthly Venmo requests.

    # <workflow-name>.yml
    
    name: Run Recurring Venmo
    
    on:
      schedule:
        # 5/6pm EDT on the 10th of the month.
        - cron: "0 10 10 * *"
      workflow_dispatch:
    
    jobs:
      run:
        runs-on: ubuntu-latest
    
        steps:
          - uses: actions/checkout@v2
          - name: Set up Python 3.7
            uses: actions/setup-python@v2
            with:
              python-version: 3.7
          - name: Install dependencies
            run: |
              pip install pipenv
              pipenv install
          - name: Run script 
            # https://pipenv.pypa.io/en/latest/advanced/#automatic-loading-of-env; this is somewhat silly but I wanted to finish quick
            run: |
              echo VENMO_ACCESS_TOKEN=$VENMO_ACCESS_TOKEN >> .env
              echo GF_VENMO_USER_ID=$GF_VENMO_USER_ID >> .env
              echo C_USER_ID=$C_USER_ID >> .env
              echo IFTTT_WEBHOOK=$IFTTT_WEBHOOK >> .env
              pipenv run python main.py
            env:
              VENMO_ACCESS_TOKEN: ${{ secrets.VENMO_ACCESS_TOKEN }}
              GF_VENMO_USER_ID: ${{ secrets.GF_VENMO_USER_ID }}
              C_USER_ID: ${{ secrets.C_USER_ID }}
              IFTTT_WEBHOOK: ${{ secrets.IFTTT_WEBHOOK }}
    
  6. ๐Ÿ–๏ธ Sit back and relax - with your automation in place, youโ€™re now saving MINUTES each month! ๐Ÿคฃ

    But hey, we learned something neat and learned some new automation tricks. Time well spent.

    XKCD was it worth the time matrix

๐Ÿงช Experiments & potential improvements ๐Ÿ”—︎

  • Writing Node.js function on Autocode after switching to Payment Links.

See Also