[00:00:00] Speaker 1: Did you know that Slack workflows can call your Salesforce flows? It's easier than you'd think. Check this out. 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 I'm excited to talk to you today about how workflows can go with the flow. That's the best I could come up with. In today's episode, we're going to set up a flow in Salesforce and then we're going to use it from a workflow. It's going to be super cool and you can follow along. Remember, jump into your sandbox. Oh my gosh, come on. Jump into a sandbox and build along with me. I'm assuming that most of us have built flows before, so I'm not going to spend a lot of time on the flow, but it's probably worth it to take a look at it anyway. Autolaunched flows can be invoked or used by external systems or other processes that you have. And this is exactly the model we're going to use. We're going to create a campaign member from a campaign in Slack using just the contact's email address. And that's kind of complicated, so we're going to let flow do the heavy lifting. Before we dive into the flow, let's talk about variables for a second. In order for Slack to send data into your flow, you have to have variables that are available for input. Let's take a look at that. If I open my toolbox, I can see that I've got a couple of variables here, var email, var campaign ID, and var channel ID. These are data points that we're going to pass from Slack into Salesforce. If I take a look at the first one, var email, I can see that it's available for input. That's really important, because that's going to allow Slack to actually put a value inside this variable. If I didn't check this box, Slack would not see the field and would not be able to populate any data into it. The same is going to be true for campaign ID. We're going to be creating campaign members. I'm definitely going to need that campaign ID. The other variable that I have here is var channel ID. You'll notice this is available for input and available for output. We're going to use this in our fault and send an error message back to the channel if something doesn't go right. We need this to be available for output. Same rules apply here. If available for output is not checked, Flow will not be able to hand this data point back to Slack. What are the parts of our Flow? It's pretty straightforward. We're going to start out by taking that email address and looking up the related contact. If you have multiple contacts with the same email address, you're going to need to do something more complex here. For my simple example, that's going to do just fine. After that, I'm going to set the values of the campaign member. For my scenario, that's just going to require three fields. I'm going to populate the campaign ID using var campaign ID from Slack. I'm going to look up the contact ID. We did that in this get records just up above. And then I can take the ID from that get records and populate it as the contact ID. And then we need to have a status. And my status here is always going to be sent. Maybe that doesn't work for you because you're an actual business. That's fine. It works for this demo. After that, we try to create a campaign member using the record variable that I populated in this assignment. Now, I've added a fault path here using this action send Slack message. What I like about this is it's going to allow me to pass back an error message, if there is one, directly into my channel where I use the Flow, or whatever channel ID I put in my workflow. And we'll see that when I build it in just a moment. And that's the Flow. It's really pretty straightforward. We've got a start element. We need to look up the contact because I only have the email address. That's a nice, easy thing for a user to be able to find in Slack, or that they might be able to know. It's not like a record ID, which is a little bit harder for users to work with. We populate a record variable, and then we insert that record variable. And then if something goes wrong, we've got a path to handle that. So let's jump into Slack. Here I have a Salesforce channel for a campaign record. I can click over and see the campaign details. But unfortunately, I don't have a nice, easy button here to create a campaign member. So we'll make our own. We've got a Flow that'll do the heavy lifting for us. We just need a workflow that uses that Flow. So let's build that now. Of course, I can go over to More and do Tools. But I'm going to go do a new tab, and then choose Workflow, and then Create Workflow. This is just as good as any other method. The starting event today, we're going to use from a link in Slack. It's pretty simple, and it works in a lot of different applications, and we'll be doing that. Now, right out of the gate, we need to get the ID that is associated with our Salesforce channel. Because Flow doesn't really care about the channel ID, it wants the record ID. So let's give it that. I've got a good way to do that. I can go to Add Steps, and then find a channel's Salesforce record. I could also use Find or Create, but for now, this Find is just fine. Now it wants me to know what channel, and I'm going to say the channel where the workflow is used. Doesn't matter what Salesforce channel I'm in, I want you to go and find the related Salesforce record ID, and then we'll make that available for the rest of our workflow. So I'll choose that and save. That part was pretty easy. Now let's send a message telling the end user that they need to get that email address, and then bring it in. So we'll add a step, and we'll do Send Message to Channel. That defaults to the channel where the workflow is used. That's great. That's what we want. And then we'll need a message here. How about, get the email address, and click Next. And then we'll add a button. We said click Next, so we'll name it Next, and we'll say Done. So now, we know what the ID of the Salesforce record is for the campaign, because that's the kind of channel that we're in, and we've asked the user to go get that email address and then click a button. So that should be all we need. I know the channel ID, because Slack knows the channel ID. I've looked up the Salesforce record ID, and our user is going to go and get the email address, so we're ready to call that flow. We'll do that by clicking Add Step, and then up here, we can just type Flow, and there's a Run a Flow option. Now when you run a flow, you've got a choice of do you want Slack to build a form for you, or do you want to build the form from scratch? There are going to be fields that we're going to be populating, and Slack can figure all of that out and build the form for you. Let's go with that option. So we'll leave this option, add the step with the form selected, and then click Setup. It's going to verify the connection, and it'll use the running user, and then we just need to find our flow. I happen to have named this Slack campaign member. So I'll click Next. We'll give this a title of Run a Flow, that's fine. And then here, it's showing my variables that were available for input, but it's showing them in this kind of format, which is not really user-friendly, and it's showing variables that I have the answers to, not the users. So we can actually just delete these, campaign ID and channel ID, I'll be able to get on my own. This one, VAR email, I would like them to fill out, but VAR email's kind of terrible. How about we make that contacts email, and we'll make this required. If you don't have an email address, there's no reason to run this flow. And then I can click Next. I still have these two fields, and I definitely want to populate them with values, and we know that we can get to variables by clicking on these curly brackets. This one is VAR campaign ID, and the campaign ID, we figured out it was the record ID from this first step that we added, find a channel's Salesforce record. So we'll choose record ID there. Now the channel ID is slightly more complex. We're going to click here, and up here, I've got the channel where the workflow is used. This is going to get me the channel ID, but I have one extra step, and we don't want to forget this. There's a little down arrow, and when we click that, we can choose how I want to return the results. In this instance, I want the specific channel ID, and not the name or a link. So we'll use this bottom option, and then click Save. Believe it or not, that's all we have to do to use this flow. So we'll click Finish Up. We'll give this a title. How about Campaign Member Creator, and a good description. We'll say everyone can use it, and then we'll publish the workflow. If I go back into my channel, and I go look for my workflow, this Campaign Member Creator, and we add this, we can now run our workflow from the channel. Well, so far, so good. I can see there's an unread message, so we'll go back to the Messages tab, and I show here the Campaign Member Creator, said get the email address and click Next. Well, I actually don't have an email address, so I need to go back to Salesforce to get one. And I have a test record here with an email address, so I'll just copy this email address and jump back into Slack. I can click the Next button, and we know what should happen. It wants to know what the contact's email is. So I'll paste that here and click Submit. Now, on my new product launch record for the campaign in Salesforce, I should see that there's a campaign member. So when I refresh this page, that campaign member should be there. And there we have it. All good. Everything worked well. Well, what about that fault path, though? This thing for us, I can't add the same person to the same campaign two times. So I can just rerun this, and hopefully I get an error message back. So I'll put the exact same email address in and submit it. Well, that was quick, wasn't it? You know those flow errors, they come at you fast, right? And so there you go. This error occurred when the flow tried to create records, but I got a duplicate value error, already a campaign member. Look at how I did that. If I go back to my flow, within this action to send a message to Slack, the one that I'm calling here, the send error, if I go down into the message, the Slack message here, we use a text template as the tool to get to this. And if we look at this in the toolbar, I have one text template called message body. I have a variable that is available to me called the fault message, and the fault message, when there's a problem, we can use that to post back to Slack so that we can help with our troubleshooting of things. That's a really handy, handy, handy tool. Well there you have it. Creating workflows in Slack that are calling flows in Salesforce is easier than keeping cats off your desk. Really, it is. Let me know how it went for you. Tell me in the comments or jump into the Slack community and let me know how it went. We'll see you next time. Oh, hey, I see you. You did a great job. Oh, I forgot to like and subscribe. I know how to do my job. Sometimes.
We’re Ready to Help
Call or Book a Meeting Now