Coder Social home page Coder Social logo

alexellis / gumroad-custom-workflow Goto Github PK

View Code? Open in Web Editor NEW
27.0 5.0 2.0 713 KB

Get webhooks in Slack every time you sell a product on Gumroad

Home Page: https://gumroad.com/l/serverless-for-everyone-else

License: MIT License

JavaScript 100.00%

gumroad-custom-workflow's Introduction

Email your Gumroad customers and get notifications via Discord

This repo contains two functions which extend Gumroad with a custom workflow

  1. gumroad-pings - forwards messages to Discord to tell you about your sales
  2. gumroad-upgrade - use this to email customers an upgrade to a secret unlisted YouTube video or Gist for additional value

Emails are sent via AWS SES and for low traffic, will stay within the free tier.

Deployment

First of all, set up OpenFaaS using the open-source faasd project.

My new eBook has step-by-step instructions on how to setup and configure faasd and may save you some time with configuration and setting up TLS: Serverless For Everyone Else.

Then create an incoming webhook URL via Discord's docs.

Then clone this repo, and create the two secrets.

faas-cli secret create seller-id --from-literal "GUMROAD_SELLER_ID"
faas-cli secret create discord-url --from-literal "https://hooks.slack.com/services/X/Y/Z"

You can get the discord-url by creating an "incoming webhook" and creating a new channel for the messages, or using an existing one.

Set an end-date for your offer in the promotion_end_date environment variable, if you don't know what date to set, make the date very far into the future.

  gumroad-pings:
...
    environment:
...
      promotion_end_date: '2021-02-13T00:00:00.000Z'

Deploy the function after creating the secrets:

faas-cli deploy --filter gumroad-pings

Now enter your function's URL on the Advanced tab in Gumroad's settings page, in the "Ping" field.

Your URL will be something like: https://faasd.domain.com/function/gumroad-pings

Pings

This is what you'll receive.

Example

Feel free to customise the code in the handler.js file.

Why not?

  • Send new customers an email using SES or Sendgrid
  • Tweet a message to say thanks
  • Customise the message into the Discord channel
  • Send them an automated invite to your Discord community
  • Flash an LED on your Raspberry Pi

See the code for the gumroad-pings function

Conditional emails

The gumroad-upgrade function will "upgrade" customers on the 50USD tier by emailing them a link to a video course.

You'll need to set up AWS Simple Email Service (SES) or use an alternative like Sendgrid if you want this functionality in your own workflow.

Create secrets for your AWS credentials:

export AWS_SES_TOKEN=""
export AWS_SES_SECRET=""

faas-cli secret create \
 ses-access-key-id \
 --from-literal "$AWS_SES_SECRET"

faas-cli secret create \
 ses-access-token \
 --from-literal "$AWS_SES_TOKEN"

Create a secret for the URL that you want your customers to go to:

export SECRET_URL="https://github.com/sponsors/alexellis/"

faas-cli secret create \
 secret-url \
 --from-literal "$SECRET_URL"

Customise the email templates in the gumroad-upgrade/emails/ folder - edit the message.html and message.txt so your users can receive both plaintext and HTML.

Update the environment variables for your emails and the AWS region if you're using SES

    environment:
      subject: "Your bonus upgrade to my video workshop"
      sender: [email protected]
      region: "eu-west-1"

Here's an example of the HTML message, which you can customise:

Sample email to customers

See the code for the gumroad-upgrade function

Emails are de-duplicated to prevent you spamming your customers. You can disable this if you wish.

Sending test emails

curl http://127.0.0.1:8080/function/gumroad-upgrade \
 --data-binary '{"email": "[email protected]", "sellerID": "SECRET"}' \
 -H "Content-type: application/json"

Publish cross-platform images

faas-cli publish --platforms linux/arm/v7

faas-cli publish --platforms linux/amd64,linux/arm64,linux/arm/v7 \
  --filter gumroad-pings

Deploy:

export OPENFAAS_URL=http://192.168.0.15:8080
faas-cli deploy
faas-cli deploy --filter gumroad-pings

Copyright & License

MIT license, copyright OpenFaaS Ltd

gumroad-custom-workflow's People

Contributors

alexellis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

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.