As usual, we start by importing the packages we’ll need. There’s a bit going on here so let’s walk through it. Delete all of the existing code out of the file and replace it with this: // notification.ts import type There will be a file in this folder called hello.ts. With those values in place, let’s make some updates to the boilerplate code in the pages > api folder of the project. ![]() We’re going to take advantage of Next’s built-in API functionality. SLACK_TOKEN=xoxb-your-tokenĬLOUDINARY_UPLOAD_PRESET=your-upload-preset The file should look something like this. ![]() env file at the root of the project to hold the credentials we need to use Slack and Cloudinary. With all of this in place, we can move in the Next app and start writing some code. You’ll need the channels:read, chat:write, and incoming-webhook scopes on the Bot Token Scopes. ![]() This is where we set the scopes for the access token we’ll use to post messages to our channel. Now you need to go to the OAuth & Permissions page in the left sidebar. You should test out that the app is working as you expect by using the example cURL method generated on the page. After you choose the channel in your workspace, you’ll be redirected back to the Incoming Webhooks page. I have mine set to post to my direct messages to test with. Pay extra attention to the workspace permission screen so that you know you’re posting in the right channel. You’ll be taken to another page where you’ll need to add a new webhook to your workspace. This is how we’ll be able to post messages from the Next API. Let’s start by enabling Incoming Webhooks. You’ll get redirected to a page with all of the app settings we need to set up to interact with this throughout Next API. ![]() Make sure you choose the right workspace and name the app Image Upload. Log in to Slack in the browser and create a new app. Setup the Slack app in your Slack workspaceįirst, you’ll need to create a Slack app so that you can generate a token for the Next app.
0 Comments
Leave a Reply. |