Uncategorized

Basic app setup

YOU ARE READING: Basic app setup AT Vccidata_En

This guide is for developers who have never followed a Slack app recipe but want to cook with the latest ingredients from the Slack platform. We’ll teach you how to create a new Slack app from scratch.

If you’re a seasoned chef and already familiar with past seasons of Slack apps, check out this quickstart guide that covers exactly explains what new ingredients have arrived in apps.

Reading: How to create an app in slack

Otherwise read on!

  • Overview
  • Create an app
  • Request spaces
  • Install the app in a workspace
  • Call API methods
  • Monitor events
  • Post to public channels
  • Customize message authorship
  • Use slash commands and incoming webhooks
  • Handle unfolding of links
  • Further steps

Overview

This guide will walk you through creating a new Slack app using the Slack app management UI.

At the end of this guide, your app will be ready to send messages post and reply to mentions , and use even classic recipes like slash commands and incoming webhooks.

New Slack apps are safer for users to install and less prone to unexpected uninstalls and even new features not available to classic apps. So let’s start cooking, starting with the first ingredient: creating an app.

Creating an app

If you haven’t already, create a new Slack app with our easy-to-use interface:

Create a new Slack app

Enter your app name and select the development workspace you’re playing around in and build your app. Don’t worry too much about either field – whichever workspace you choose, you can still distribute your app to other workspaces if you wish.

Request Spaces

Preheat the oven and get your app ready to go by requesting sections. Scopes give your app permission to do things (e.g. post messages) in your development workspace.

You can select the scopes you want to add to your app by going to OAuth & Permissions sidebar.

Scroll down to the Scopes section and click Add OAuth scope.

For example, try adding the scope chat:write to your bot token. It will allow your app to post messages! While you’re at it, add the Channels:Read section so your app can gain insights about public Slack channels.

If you’re not sure what the difference is between adding a bot token scope or a user token scope, don’t worry:

See also  Theater Resume Template (Guide & Example)

Add scopes to your bot token, not your user token.

A notable exception to this rule is when you need to act as a specific user (e.g. posting messages on behalf of a user or setting a user’s status). In this situation you need a user token.

Otherwise it’s bot tokens at the bottom.

Installing the app in a workspace

Sure, you can request any area you want – but the user who installs your app always has the final say. Like a picky eater, a user can refuse any install that appears to be requesting permissions beyond what an app really needs.

Try it! Install your own app by clicking the Install App button in the sidebar.

After you click another green button Install App in Workspace clicked, you will be sent through Slack’s OAuth UI.

See also: 10 Tips for Creating a Profitable App

New OAuth UI for users

Here’s a potentially confusing part: when you follow this flow with Slack, you play the role of the installing user, the picky eater – not the app! If you were to add your app to a different workspace besides your development workspace, a user from that workspace would complete this flow, not you.

As a user, you choose to trust the app . Is it trustworthy? Well, you just created it – hopefully it’s not too bad.

After installation, you’ll find an access token on your app management page. Look for it in the OAuth & Permissions sidebar.

Access tokens are packed with power. They represent the permissions that the installing user has delegated to your app. Remember to keep your access token secret and secure so as not to violate the trust of the installing user.

At the very least, avoid checking your access token into public version control. Access it through an environment variable. We also have many other best practices for app security.

Calling API methods

Your access token allows you to call the methods described by the scopes that you requested during installation.

p>

For example, your chat:write section now allows your app to post messages. Your app is probably not a member of any channel yet, so select a channel you’d like to add some test messages to and /invite your app.

You can find the appropriate ID for the channel in it Your app just joined by reviewing the results of the conversations.List Method:

curl https://slack.com/api/conversations.list -H “Authorization: Bearer xoxb-1234…”

You will get a list of conversation items.

See also  Anonymous Email Accounts - 7 to Use and 4 to Stay Away From

Now post a message in the same channel your app just joined using the chat.postMessage method:

curl -X POST -F channel=C1234 -F text=”Reminder: We have a softball game tonight !” https://slack.com/api/chat.postMessage -H “Authorization: Bearer xoxb-1234…”

Voila! We’re well on our way to bringing a full-fledged Slack app to the table.

Slack Softball Team App Message

Want more tips on creating the perfect API call? Check out the Web API guide for some technical tricks.

If you just want to see all the different methods you can call, check out the method list. When you select a method, you can see exactly what parameters the method takes, as well as additional information. Think of the method list as the Slack API cookbook.

Posting in public channels

New Slack apps do not begin with the ability to post in to post any channel to public channel without joining.

Good news: Apps can get this ability by explicitly asking for it using scopes.

Require the chat scope: write.public to get the ability to post in all public channels without becoming a member. Otherwise, you’ll need to use conversations.join or have someone invite your app to a channel before you can post.

Customize message authorship

Even new Slack apps Start not with the ability to customize the username or icon when posting messages – that is, the authorship of the message.

You can customize your app’s authorship using the chat:write .panel adjust. Once you’ve requested scope, you can use the username, icon_url, and icon_emoji parameters in chat.postMessage.

Wait for events

See also: How to Make a Good Logo in Photoshop: 10 Basic Tips

A basic pattern of Slack apps is Listen and respond.

We’ve already touched on one way an app can respond: by calling chat.postMessage to post a message.

But ours app is not a very good listener yet. An app that speaks without prompting can be distracting at best and downright annoying at worst.

Apps are always responding to something. It can be a mention in the channel, a button press to trigger an action, or even a user entering a DM using the app. But apps never act without a reason.

Apps listen with the Events API. Events are exactly what you expect: notifications about events in Slack sent to your app. Each event type informs your app of a specific event type.

Let’s subscribe to the app_mention event. Select the Event Subscriptions sidebar and turn on “Enable Events”. Under Subscribe to bot events, click Add bot user event, then search for app_mention.

See also  How to Start a Finance Blog in 5 Steps

As with scopes, you always subscribe to events with a bot -User, unless just a user token is sufficient.

Set the Request URL to a URL where your app’s server listens for incoming HTTP requests. Slack will send an HTTP request there when your app is mentioned so your app can figure out how to respond.

If setting up a server makes you nervous, there’s plenty of help in our tools and SDKs for programming languages ​​that implement a server that automatically listens for events.

You’ll notice that the app_mention event requires the app_mention:read scope. Events are like API methods: they allow your app to access information in Slack, so you need permission for that. Reinstall your app with the new section.

Now you’ll be notified when your app is mentioned and you can respond to it however you like:

Slack Softball Team app call and response

Using slash commands and incoming webhooks

New Slack apps can still use popular recipes passed down through the family: slash commands and incoming webhooks.

Request the command pane to add a slash -Command to create. Request the incoming webhook scope to use incoming webhooks. Both features behave the same as classic Slack apps, with one big exception:

Slash commands and incoming webhooks are now tied to your bot user and bot token , not to a user. This means you’re safe from unexpected installs when the user creating a command or webhook leaves the workspace!

New Slack apps don’t support slash commands or incoming webhooks on a user token. They can only be retrieved by the bot user of the app.

Link unfolding handling

You can request the links:read and links:write scopes to allow your app to handle unfoldings .

p>

A link shared in a channel is only unfolded if the token with links:write has access to the message containing the link.For example, if you have a new Slack app and an installing user shares a link to a private channel, but the new Slack app isn’t in that private channel, that link won’t appear.

Learn more next

Cooking is a lifetime activity, and Slack apps are just as complex. From here you can proceed to create delicious interactive workflows; Spice up your sentences with Block Kit; even track the build for larger Enterprise Grid orgs that contain multiple workspaces.

You can now even submit new Slack apps to the App Directory and share your creations!

See also: 15 Effective Tips To Come Up With A Logo That Fits Your Brand

.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button