

Build a Slack App to Create and Apply Stripe Coupons in 4 Steps with Standard Li...
source link: https://www.tuicool.com/articles/IVJRfaR
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Build a Slack App to Create and Apply Stripe Coupons in 4 Steps with Standard Library and Node.js
Subscriptions are everywhere –– think Netflix, Blue Apron, Xbox Live, etc.–– and are a great way to capture value from your customers. These days, it’s easier than ever to set up subscriptions thanks to products like Stripe Billing that drastically simplify the process. Though Stripe offers tons of utility, managing subscriptions requires granting access and navigating to secure dashboards, which can be overkill for more common administrative tasks.
In this article, we’ll walk through how to create your own Slack -based Stripe coupon management app using Build on Standard Library . Your app will be able to:
- Create coupon codes for all occasions (new subscribers, promos, etc.)
- Apply coupons to existing subscribers
- Solve world hunger and the energy crisis (just kidding)
Excited? Let’s get started!
Prerequisites
- 1x Stripe Account
- 1x Slack workspace (we recommend you start with a new “test” workspace –– you can painlessly release your app to an active workspace after testing)
Step 1: Opening the Project Template
We’ll be building this product from an existing template in a GitHub repo. This repo has been configured to automatically create event subscriptions and trigger APIs using Build ! But don’t worry coders, you’ll be able to edit the code, add new handlers to other events, and otherwise customize it to your heart’s content after you deploy.
You can view the code on GitHub here . To get your personal version up and running, click the “ Deploy ” button in the README of the repository. You can also follow this link .

You’ll be greeted by a page like this:
Our app has five endpoints:
-
events/slack/command/apply-coupon.js
, the handler that is triggered by a Slack slash command/apply-coupon
. It opens a dialog with the callback idapply-coupon
that, as you would expect, allows you to apply coupons to existing subscribers. -
events/slack/command/create-coupon.js
, the handler that is triggered by a slash command/create-coupon
. It opens a dialog with the callback idcreate-coupon
that allows you to create new coupons. -
events/slack/dialog_submission/apply-coupon.js
, the handler that gets called when you submit a dialog with callback idapply-coupon
. It calls the Stripe API to update the appropriate subscription. -
events/slack/dialog_submission/create-coupon.js
, the handler that gets called when you submit a dialog with callback idcreate-coupon
. It calls the Stripe API to create a coupon with the parameters from the coupon creation dialog. -
message-menu.js
, the endpoint that retrieves coupon and subscription data from Stripe and populates the menus in the dialog. It acts as a data source for the menus within the dialogs.
Scroll down and you’ll see that we need to link Stripe and Slack accounts:

Step 2: Setting Up Stripe
Let’s start with Stripe! Linking your Stripe account is very simple. Just click the Link Resource button in the Stripe row, select Link New Resource in the resulting dialog, and select your Stripe account in the following OAuth popup. Since you’re in testmode, just click Skip this account form to avoid unnecessary setup.
Step 3: Setting Up Slack
Setting up Slack requires a few more steps. For this app, we’ll need to:
- Create a Slack app
- Create a Bot User for that app
- Paste our Authentication Redirect URL
- Paste our Interactive Components URL
- Retrieve the credentials for your app and link it to your project’s Identity
- Register the
/create-coupon
Slash Command - Register the
/apply-coupon
Slash Command - Paste our Message Menu URL to populate the dropdowns in our dialogs
Fortunately, each step only takes a minute! To get started, click the Link Resource button in the Slack row. This will bring up a built-in guide that will walk you through the first five steps:
Carefully read through and follow each section of the guide before clicking Next Step , pasting the URLs it supplies into the appropriate places in your Slack app dashboard . After you’ve done this, you’ll need to set up three additional URLs: two slash commands ( /create-coupon
and /apply-coupon
) as well as the data source for the dropdowns in the dialogs.
Navigate to your Slack app dashboard , and select the app you just created. Next, select Slash Commands from the left sidebar and press Create New Command .
Name the command create-coupon
. Use https://<your Standard Library username>.events.stdlib.com
for the Request URL . Click Save in the bottom right once you’re done, and repeat this process to create a second slash command named apply-coupon
.
Almost done! Select Interactive Components in the left sidebar, scroll down, and populate Message Menus with this URL: https://<your Standard Library username>.api.stdlib.com/coupon-bot@dev/message-menu/
.
Note:The trailing slash is important –– don’t forget it!
Step 4: Ship It!
We’re ready to go! Now we can click the “ Deploy Project ” button at the button of the page on Build . Once it’s finished, open up the Slack workspace you installed the app in. Try running /create-coupon
and creating a coupon from the resulting dialog!
If you have existing infrastructure to handle coupon codes, you can give them directly to your customers. Otherwise, you can use /apply-coupon
to apply coupons you create with /create-coupon
directly to a subscriber. If you don’t have any existing testmode subscribers, you can create one from your Stripe dashboard by creating a test customer, payment source, product, and finally, subscription.
Making More Modifications: It’s Just Code!
Although we didn’t write any code during this tutorial, we imported directly from a GitHub template –– which means we have complete control over all the code that powers our workflow(s) and app. To edit and iterate on the code, select the dev environment from the list in project management screen, scroll down, and click the Edit Code button in front of any of the endpoints.
Click “Edit Code” to open your code in code.stdlib.comThis will open your app’s code in code.stdlib.com , our online code editor. You can also use our command line tools to download and redeploy your app if you’d prefer to work locally.
When You’re Ready: Shipping to Production
Once you’ve deployed and iterated on your app and tested it with your test workspace and testmode Stripe account, switching to use production data is simple. From the project management screen in Build, simply click the Ship Release button. You’ll be prompted to link the live version of your Stripe account and a new Slack workspace, which should be the workspace you actually intend to use the app in. You’ll have to repeat the process of setting up the slash commands and message menu data source as well.

That’s it! Thank you!
We hope you and your customers enjoy using your new coupon management app! If you have any ideas or improvements, feel free to open up a pull request in the template’s repository .
For additional help see our documentation , or join our Slack workspace by visiting https://docs.stdlib.com/ and clicking Request Slack Community Invitation on the right.
Thanks again! Please follow Standard Library on Twitter, @StdLibHQ , or me personally ( @hacubu ) for product updates! We’ve got a lot more exciting things coming.
Recommend
-
103
Udemy Coupon Grabber & Course Enroller: Grab FREE Coupons! Do you want to LEARN NEW STUFF for FREE? Don't worry, with the power of web-scraping and automation, this script will find the necessary Udemy Coupons & enroll you to...
-
14
Images of new International Airmail Reply Coupons Sunday, December 31, 2006 I picked up some International Airmail Reply coupons the other day to include with QSL requests. Since these are the new versions, I figured I...
-
4
We may earn a commission for purchases using our links. Learn more. Saving more money Mint Mobile Deals, Coupons and Promo Codes Looking to save even...
-
6
Weekend PC Game Deals: Daily freebies and unending coupons to claimWeekend PC Game Deals is where the hottest gaming deals from all over the internet are gathered into one place, every week, for your consumption. So kick...
-
9
Online Voucher Codes And Discount Coupons ...
-
11
The Engineering Behind Coded Coupons, eBay’s New Seller ToolSkip to main content This tool...
-
11
Klarna launches browser extension with payments and coupons Fintech startup Klarna is launching a desktop browser extension that provides many of the features th...
-
6
How to design better coupons?Use an offer, discount to attract users to buy things.Coupons are an excellent marketing technique for attracting new sales and customers while promoting special i...
-
12
1 week ago Last updated April 28th, 2022 652 Reads Why Coupons are the Perfect Marketing Tool Image Credit: ...
-
7
Weekend PC Game Deals: Mega sales, coupons, and a free trip to Borderlands...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK