Creating Custom Integrations for Zapier - With AI!

Ray Deck builds a custom Zapier integration for AI21's APIs to automate customer support. When the AI can't find an answer in the document, the workflow automatically routes the question to a human via text instead of making something up. The no-code builder lets you set up authentication, configure actions, and add fallback logic without writing code.
Chapters
I'm a big fan of Zapier. Zapier is the way that, for example, StateChange is able to do a lot of its automations for our community. So whenever, for example, I add Office, add a particular item to my Google Calendar, it will, you know, basically figure out if it's meant for StateChange. It will create an event in Circle, which is the platform we use to actually run the community. And it will schedule up the event that will then match to the event that's sitting over in my Google Calendar. It will send me a little SMS telling me the job is done. Like I say, updated my— it will re-update my calendar, tell me what the ID of the post is that goes with that. And that way it just makes it really easy for me to be scheduling this stuff. But the— but there's a lot more that we can do. I mean, that's fairly deterministic and simple, but something that happens every day. But you can also use it to integrate, you know, higher-level tools. And particularly tools that don't currently exist in Zapier are actually now much easier to put in than they ever were before. I actually just participated in this hackathon run by LabLab where we had AI21, which has, which is an AI company that has what they call task-specific APIs that just seemed to be a wonderful candidate for getting into Zapier. And so we made that for our hackathon entry over in the, in the LabLab hackathon.. And the way we did that was by creating a new integration within Zapier, which is now so much easier to do than it was before. I remember back in the day, you'd have to go download a CLI package, a particular type of JavaScript, and you would need to make sure you're using their libraries, et cetera. But they actually have a no-code way now of building out your own integration, which is pretty cool. So for our entry, we made one for AI21 and basically wrapped the AI21 APIs so they could be directly called as if they were just inside Zapier themselves. Now, one key thing about this, because we don't work for AI21, we had to make this a private integration because they'll only make them public if they're done by the first party. So anyone at AI21 who's watching this, we'd be glad to give you the integration so that you can make it more publicly available to your various users because we think this is really cool, something that could, you know, increase the use of your tech. The key considerations when we're building out one of these integrations is we need to figure out how we're going to authenticate and how you manage the tokens. So they have some interesting ways of doing that and playing on easy. Whether you're going to integrate with a trigger, like if there's an event, a webhook or something that they're going to link up with, in our case there wasn't because we're, we're, we're telling AI21 to do stuff, we're not receiving events from it. And then they have a whole validation process to make sure that you're really legit and that you're doing this on behalf of the primary company. We didn't do that validation part because like I said, it was a private integration. So the two key things I think are sort of non-obvious are first the issue of authentication. And you can tell it you're going to authenticate using, you know, in my case, just sort of setting up using an API key. And then, then it just kind of works, you know? So the, so we set up the API key that will then get stored as API key, which will then be used for future authentication of requests. And then the, if I just sort of go back here, you have to call one of their API, one of the APIs from your service to confirm that the key works. And they often look for like sort of an auth me type thing, a generic, something that's not going to trigger billing event, but will fail if you're not authenticated and succeed if you are authenticated. And so we just use one of the APIs from AI21. API.AI21. You know, AI21. There it is, studio documentation. And, and they had some that are just for like, you know, listing out your datasets that they just show under their API reference. And we just use that because that doesn't require you to actually run anything. It doesn't drive anything on the build, but it will fail if you are not authenticated. So this is, yeah, back to the platform. Excellent. So, so, so we just set that up to run and then all it does is then create standard view that you've probably seen a bunch of other times in Zapier. Let me, let me show you what that looks like. So we can have like a contextual answers API, which I think is one of the most fun things we can do in this, in this context. I'll show you how the demo works in just a second. The, where we have the, where it uses the action for contextual answers in AI21 unofficial, which is the thing that we created. Now here, if we were just to, oh, we're going to edit the draft. Yeah, replace. Fine. You know, we can say, well, which account we're supposed to use and we can change the account. Or in my case, what I'll do is I'll just say reconnect it. And that creates a little popup like you see over here. In this popup, you know, then can you, it will ask you for your private key for AI21. And if I were to click this, click this here, it will show me my AI21 current key, which is not gonna be my current key once I actually publish this video. So don't worry about it. This will say copy here. And then I can, let's see, and get this guy again and paste. And then It just resets my key. So if you have an API that you're looking to integrate with that just uses API keys, it's very, very straightforward, right? You just, you get to inherit all of the UI from our friends over at Zapier. You don't need to do anything yourself. The second big piece of this is, in addition to having the API key, go back a second, you have the actions. And what we did is we set up the actions to go with each of these systems. So we created the Zap. And then we're able to test each of them, blah, blah, blah. So to use that same one we were just looking at, the contextual answers API, we can manage those actions and we can click contextual answers. This is where we create it. You give it a name, whatever's the noun that's supposed to come out with, a description, et cetera. Nothing here that is too totally exciting. So the really important part is going to be what are the inputs that you need to provide to it. In this case, the context and the question. And we took both of by just studying what the, what the key is, what the contextual answers API, actual API looks like, right? Context and the question. So by feeding those two pieces of information in, it knows that those two things need to go, go into your request. Therefore, they can come in and be, be built out of the rest of the Zap, right? So like the question might be the email you just received. You get treated as a question. The context could be the content of your current webpage., and like, if you can answer the question based on what's on the webpage, provide a useful answer, reply to the user. And if not, it actually is a very cool thing. This is actually designed not to lie. So it will say, I don't know, in the event that it doesn't have the answer. So, and then, you know, after setting up the, what, what you want the inputs to look like, you get the API configuration where you tell it, okay, what kind of request is it going to be? And this, this code mode is actually really key too, but we'll get to that in a second. You can set up what the request body is going to contain. You can set up what the headers are going to be in terms of how you handle authentication. So all the things you already know how to do, maybe from looking at through Postman or having run the web request yourself, very easy to get into here. And in the event that you need to go make some changes, you can, you know, switch into code mode and edit it as if it were JavaScript, which is actually the old school way of doing it through the system. So the fact that you get to use no-code first, but can always dive into JavaScript gives you an escape hatch that allows you to do most things a simple way. And then wait, this is complicated. Let's have a little bit more control. And I find that just to be pretty fantastic here. So what we did for the hackathon was we did this process times each of the APIs that are surfaced by AI21, the passphrase, grammatical, et cetera, et cetera, et cetera. And so the, and so when we go back over to the platform UI, you know, what we did here was we just, Well, we'll go through each of those, you know, types of ways that one can interact with, you know, with AI21 and make them each into actions so that we can go back over to Zapier. And like we did in this example, we say, okay, well, we receive an email. And if the email is, you know, asking us a question, right? If it contains AI21 Hackathon, well, then its job was to go fetch you know, the information about the AI21 hackathon. It was then going to format it, basically stripping out all of those, you know, the HTML tags, right? So it just looks like normal text, make it easier to answer questions. And then we were just able to, you know, click on plus here and say AI21. Now, in order to get this view, you need to be invited, but I'll include the invitation link on the YouTube so you'll be able to get there even if AI21 hasn't done this themselves. And you can, you know, click on this. And then once you do, you'll be able to choose the event you want to work with, right? It'll ask you to log in just like we saw before. And then it'll give you these various options where you can paraphrase your text, you can summarize your text. I mean, these are actually really cool APIs. And what we did for our case is we told it just to do it by what's called a contextual answer, which is sort of your classic ChatGPT with data type approach of you're going to load in the data that came from a particular webpage. You're gonna feed the question, you're gonna put them both in a prompt, and, and what it takes care of for you is going and getting that answer. And then we set up paths, and the paths are really where, like, working with AI, we found, like, makes it much more valuable. So in the event that it did not find an answer, right? So if it exactly matches answer not in document, if it does, if you try to ask a question to the AI21 bot, AI21 Hackathon bot, and say, hey, why is the sky blue? It's going to tell you, I don't know why the sky is blue. The answer is not in the document. And then, great. So in the event that it's not in the document, we will just say we're going to reply with a message that says, you know, something humble, right? Like, I don't know what the answer is, so I forwarded it to a person. And then we go and forward it to a person and send that person a text to make sure they know it's time for them to get on it right quick. In this way, we're able to make use of this technology, not only to improve automation and reduce our costs, but really to improve the quality of service. Somebody asks a question, they get an instant answer if it can be answered quickly. And if not, we light a fire under somebody to go get the answer. And by doing this in a way that keeps the AI from lying to us, we, we're just trying to get the best of both worlds and serve the customer better as all this technology really should be doing.. And we were able to do that because of the remarkable sort of already preexisting compositional quality, right? Using pathing, using if filters, using the, the Zaps that already exist and the, you know, remarkably improved development platform available through Zapier at developer.zapier.com. This is the kind of thing we do over at StateChange, which is, you know, work on the hardest 5% of of projects, both no-code, AI, and what have you. And often those challenges are at the edges. And I hope that this video here today has helped you, helps you see what, what is possible by extending Zapier using this platform. And then in fact, it does not have to be scary. And I hope you'll let me know how you use it, and I look forward to—










