[00:00:00] Speaker 1: Let's use the CLI to deploy an app. Watch this. Hello and welcome back to Slack School. My name is Mike Reynolds, I'm your host. I'm part of the Slack team here at Salesforce. And today, we're gonna use the CLI to deploy an app into Slack. Now, we've talked about using the CLI in a previous episode where I used VS Code. You can use whatever you like, but I'm always gonna use VS Code, it is free. I would go ahead and download that. We've got an entire episode you can watch right there about how to get that all set up. Today, what we're gonna do is go ahead and take an app that I've already written all of the code for, and you can get that app and then install it. Are you gonna let me work? Oh. Probably not. All right, let's get after it. Okay, in order to get started, we're gonna need the app. Now, I've already written all of the app in its code, but you need to go and get it. So, hop into the Slack community, that's slackcommunity.com. Go to the Slack School channel, and then in the Stuff from the Episodes tab up here, you can see this file, slackschoolappofawesomeness.zip. This is just a zipped file, go ahead and download it, and then uncompress it or unzip it, depending on if you're a Mac or a PC, and then put that somewhere where you know where it is on your computer, because we're gonna go open it. Now, I'm going to open my VS Code. VS Code is my IDE, that's Integrated Developer Environment of choice. VS Code is the one that I like to use, and so that's what I'm using. Use whatever you like. The process is gonna be essentially the same. So, what I'm gonna do first is open that folder. So, I've already downloaded it, I mean, I wrote it, I didn't have to download it, but I have it and it's ready for me to open. So, I'm gonna go in my VS Code and do File, Open Folder, not Open, you want Open Folder, and here in my Documents, I have Repos, which is where I put my file, slackschoolappofawesomeness, and I'm just gonna choose to open it. Now, a bunch of things happen here. You might get a pop-up that says, do you trust this? And I've already clicked that. I'm gonna close this, cause it doesn't matter. And you can see my terminal, did this history restore thing. I'm just gonna do that, we'll pretend it was never there. This Welcome tab that showed up, I don't need, I'm gonna go ahead and close it. If you didn't have a terminal window open, if your screen looks like this, at the top, you can go to Terminal and just click New Terminal, and you'll have something like this. And if you just click up here, that goes away. So, the app that was there, that you downloaded, that's what all of these files are. And the same thing will be true if you open this in a browser and you start to look, it's the same things. So, what the app contains is, you can't eat my computer, Nebula. You gotta be cool. We say this all the time, be cool. Be, be cool. Or learn to code. That would be helpful, you could do that too. This folder structure that we have over here, where I have assets and functions, and then a few other files, that is exactly the same that you have over here. I have assets and functions, and I can see the, if I click on any of these, I can see the actual code. We're not gonna talk about the code, and honestly, the code doesn't matter for what we're doing today. But you can see the code, and that's why this is an integrated developer environment, because it's gonna blend together a lot of tools and make life kind of easy for me. So, what we're gonna do is, we are gonna look at the manifest really quickly. I can see that it's importing a couple of things. We don't really need to worry about that. But if you do remember the last time we talked about manifest files, you can see a couple of basic things. It's got a name, Slack School App of Awesomeness, a description, it references this standard icon, and it's got two functions. The two functions inside this app that you can deploy into your own Slack sandbox to test are schedule a message and look up user by email. Both of these are custom workflow steps. So when you build a workflow, you'll be able to choose either of these steps and then use them in your workflows. Look up user by email is pretty straightforward. You enter an email address, and then the function is going to return that user. Schedule a message is really cool. In the user interface, you can always schedule a message, but we don't have that option within the workflow. But because the schedule a message functionality is actually something that lives inside of our API, we can build a custom function that does that. And so that's what this function does. Again, the code doesn't really matter, but I wanna be able to test this in my environment. So what I'm gonna do is first, we're gonna use the command line, which is your terminal. Yours might say something different here. Mine says Slack is cool because Slack is cool. What we're gonna do is we're gonna use this terminal to log into Slack. After we log in, we're gonna take our app that we have and we're gonna run it to see if it works. And if it works the way we like, then we're gonna deploy it into Slack. Those three steps, pretty straightforward. Let's start with logging in. The command, remember, I'm assuming you've already installed everything. If you haven't, check out this episode and I'll show you the whole process of everything you need to do. But from here, since we've installed all of the CLI and everything else that we need, all we have to do is type Slack login. That's gonna open up and give me this prompt. So it gave me this line of gibberish right here. I'm gonna copy that. And then it wants me to enter a challenge code. So I can take this back into the Slack workspace where I want to install things. So I'll go back to Slack here. And I can put this code anywhere because it doesn't actually show up. I'm gonna do it in my direct message with myself. And I'm just gonna paste this in here. Slash auth ticket is a slash command that Slack's gonna recognize. And it's gonna say, hey, someone is trying to connect. We've got a long code from one side and then we wanna get a passcode from the other side and then we'll connect the dots. So I paste this in here and I hit enter. I'm gonna get this pop-up window that is just saying, hey, do you really wanna do this? Here's the access you're granting. In this case, I do really wanna do this. So I'm gonna hit confirm. And now I've got this challenge code. The challenge code is kind of the password that we're gonna use. So I'm gonna close that. And you can see no message was actually sent. I'll go back to my VS code and then right here, I'll paste that challenge code and then hit enter. It says I've successfully authenticated. That's great. So step one, done. Now, if you didn't already have an app, the next step that you would typically do here is you would type Slack create. It's gonna look just like that. Now, I'm not doing that because I already have an app and you do too. Once you've downloaded this and you've opened it up in your VS code, you'll have everything that you need. So there's no need to do that. What Slack create does is it's called scaffolding. It's gonna set up all of the things that you need to have an app. So it's gonna create the folder structures for you. It's gonna do all of that work. So you don't have to do it. In this case, we can skip that. So the next thing that we wanna do is run this to see if it works. Now, if I go back to my Slack and I just try to make a new workflow, I'm gonna say this just starts from a click. It doesn't really matter yet. And I go to add some steps over here on the side. I can look, but there's gonna be no app called Slack School App of Awesomeness, right? It doesn't exist here yet. So I'm gonna go ahead and close this and go back to my VS code. What I wanna do is I wanna run this to see if it really works. So I'm gonna use this command Slack run. Now it's gonna say, where do you wanna run this? And that is my app, or I could create a new app. Now I'm not in that March 26 test. So I'm gonna go down to create a new app. You're gonna wanna do this too because we haven't deployed our app yet. So it's not there. This is a different environment that I was doing some other work in. So you might see something like this. You might not. If you don't, you're gonna get this option to create new app. We'll choose that. And I'm navigating with my arrow keys, just up and down here. And you can tell where I'm at because of the little floating blue cursor. So I'm gonna use create a new app. And then it's gonna say, where do I wanna put it? In this case, I'm putting it in the community org. Yours is gonna say your org's name. And I'm gonna hit enter here. So now our app has been pushed, but in a very special way. I'm not gonna get into the nuts and bolts of this too much. But when you do a Slack run, what we're doing is we're using web sockets. Again, doesn't matter what it is. Just know that I'm doing that. I'm using a web socket. And so this app is actually running on this computer. So Slack doesn't hold the app. Anytime I try to use the app, it's gonna go from Slack to this computer. The computer's gonna do whatever Slack or the app would need to do. And then it's gonna send it back to Slack. So that's what's happening right now. So let's test this out. Earlier, we saw that there was no app there. So I'm gonna do add steps. And when I go down here, if I scroll and scroll and scroll, oh, I need to refresh my page. So if I go to add steps and I scroll on down here, I've got a new app. It's the Slack School app. So I can choose this and both of my functions are sitting here. Let's use this lookup user. Actually, we'll use the scheduled message app. So I'll put this here. And I should have thought about this a little bit more. You have to build the whole thing. So let's build a quick workflow that uses our new app. Let's start out by just collecting some info in a form. And we'll say, what is the email address? And we'll do a question because this is lookup a user by their email address. So we'll do that. We'll leave this as short answer. We'll make it required and we'll say done. So it's just a form that says, what's the email? The next thing we wanna do is use our new function that we made. So within the Slack School app, I've got lookup user by email. Here, I wanna insert a variable. So I'll choose this variable option and it's gonna be the answer to what is the email. So we'll hit save. Then I'll add a step to send a message to a person. We'll say the person who uses the workflow. And then the answer is gonna be what comes back from our app, which is the display name. And we also have the user ID. So we'll put both those in there. And so now both of those functions are in there. We'll save and we'll go ahead and finish it up. And now I'm gonna go back to my direct message with myself and I'm gonna use that slash command. So I'm gonna do a slash and I'm gonna run this and I'm gonna put in my email address. And I'm gonna hit submit.
We’re Ready to Help
Call or Book a Meeting Now