# Using the HTTP Request Tool with AI Agents

## Метаданные

- **Канал:** n8n
- **YouTube:** https://www.youtube.com/watch?v=9E3XU0WKoXY
- **Дата:** 23.07.2024
- **Длительность:** 20:37
- **Просмотры:** 34,023

## Описание

Join Community member Jim Le as he showcases the power of the new HTTP Request Tool for AI workflows.

This video was part of the n8n Community Hangout of July, 2024.

Links:

- Full Community Hangout: https://www.youtube.com/watch?v=noBdpccJCgs 
- Sign up for future n8n Community Hangouts: https://n8n.io/community/events
- Sign up for the n8n Community Newsletter: https://n8n.io/newsletter/

## Содержание

### [0:00](https://www.youtube.com/watch?v=9E3XU0WKoXY) Segment 1 (00:00 - 05:00)

right um hi everyone my name is Jim uh today I'm going to talk about the HTTP request tool so this is a new tool um that's come out um but it's going to help me slide through um next one so yeah so the HB request tool is a new tool which was released um just shy of a month ago so in uh release 1. 47 um so definitely upgrade if you haven't already and it's sort of exclusively uh used in air agents now this tool like B said it's not the HTP request node that we're all familiar with that we use for kind a lot of things it's more of a younger sibling that's how I would describe it um still very same functionality just maybe it's got a few business pieces that aren't um quite there or identical but we'll come to that later right um so as kind of one of the tools if you're not familiar with agents or tools um a agents are particular in that they are the models but they have these functionalities that you can use to extend them so for example the calculator uh is one way that um an agent or an AI model can do maths right just punch gives it numbers and calculate gives back similar the HTP tool allows the agent to make HTP requests right um but agents which kind of or a models which connected isn't really a new thing right so why in particular did NN kind of come up with to when in my opinion um and that's kind of what I'm going to talk about today so it connects the internet so what right uh I'm glad you all asked basically it means that the HTP request to enables any and I would probably say every API it makes every kind of API into an agent tool um super powerful stuff so that means um yeah it just gives you the freedom to connect your favorite Services uh maybe business critical Services Direct to the agent uh for it to kind of perform a lot stuff and I think it's super smart because um if you imagine if nnn went and said yeah we're going to make a tool for every service out there it would take them literally a million years you know shy you know a couple centuries but um yeah it would just take incredibly long time this tool just gives you the freedom to kind of bring them in into today you know into your kind of AI workflows today makes them super powerful so that's kind of like I feel like one of the big game changing features uh that or functionality that this tool brings the second one um if we go to the next slide uh oh sorry um I sorry about I reordered before you copied them sorry about that I did say I was going to resist but okay anyway um should I go to the next one so uh yeah okay if we go to the next one yeah sorry so the second game gamechanging feature is that this tool um if you like me have built a lot of um agent tools or what tried to extend with HTTP these agents in the past uh you'd notice you had to create this kind of custom workflow tool with a lot of sub nodes uh workflow and it kind of got a little bit big right so with have this um HP request to you know in some cases especially like with this web scrape for example uh that I found in templates Library you can bring it down literally from 10 nodes down to one that is an amazing feature and I'll go through how that works and how you can how that's possible in probably next slide if we jump back a little bit part a previous slide yeah oh not this one yeah this one right so um breakdown very quick uh the tool is um super familiar interface with the HP node um so uh yeah just big brain a big brain move from NN uh to kind of keep it the same so it's kind of very familiar very easy to kind of on board um I love one of my favorite things about and then it's credentials how the credentials are handled so super easy just kind of click click select the ones you want um another kind of super smart thing is this placeholder variables so um this a new sort of concept and where we had tools previously where you know the agent was determining the uh body values the params uh in the body it can now do you know in the path you know variables in the path variables in the headers um incredible stuff that it just kind of knows how to configure and not only kind of pass the variables but I configure the end points as well to kind of meet those requests um super smart move again is the response formatting so um this optimized response option you have at the bottom means that um even though you're kind of making that request getting API results you can um Define sort of a subsection of that response to bring back right so you're optimizing for your token limit so you're not kind of getting you can you know um get only the fields want or which are relevant to the request uh

### [5:00](https://www.youtube.com/watch?v=9E3XU0WKoXY&t=300s) Segment 2 (05:00 - 10:00)

where you know some API they ver for both and they give all this extra information you can cut that out so super simple I think previously you would have two notes to do this job so one to um handle the post request payload uh but in this tool you've got them all in the same uh node which is fantastic now some of the things that this tool doesn't do um is what I found anyway um binaries so if you're fetching a PDF with this tool it's going to bring back a binary the agent is not going to be able to um pass it or there isn't a step to kind of pass that into text for the agent um so to watch out for that um pagination so if you need to kind of go through a few pages or get like tokens to um to get the offset to get to the next request that's not really handled in this tool as well so it's kind of designed for um yeah make a request get the response uh no Pat and lastly what I found is you can't chain API request so if you needed uh one API request to um kind of call another there's no kind of chaining going on so um so that's kind of not really what's designed for now remember this tool has only been around for 18 days uh maybe no not 18 days just sorry month a month sorry um so there's no telling like what the N team with um sufficient feedback what they could do to improve it so definitely yeah start using it and contributing your feedback to that um so if we go to the next slide but yeah so um after using this to for a month uh so my recommendation Spirit of the bat First Choice for agent tools connected to services and apis um and I would definitely recommend over the old way uh we would um have traditionally done it which is like the custom workflow tool you create like a mini rout router to sort of figure out what you want to do there um this makes it so much simpler just kind of um reduction of nodes is just um a joy to work with and lastly um obviously custom code you kind of want to avoid generally um harder to maintain but if you have to yeah that's also an option um probably just kind of a note to um even though like this tool now exists there's no rush to refactor all your past workflows I would say if it works if your custom workflow tool works just leave it unless you kind of you really hate the way you've done it um yeah feel free to sort of upgrade but yeah I mean it's all these tools all these kind of approaches are valid it really depends on your use case uh next slide yeah right so I'm going to jump into a few quick examples uh this one is a very common use case or use scenario that I've seen uh when people kind of create chatbots and this is an appointment scheduling um chatbot particularly with one API service which is cal. com which is a calendar or appointment booking service um wow look at this what are we seeing here we are seeing uh 1 2 3 4 5 six seven nodes really um to kind of create this really capable booking agent you know it gets availability schedules appointment it can reschedule it can cancel an appointments if you told me to well same time last year that we could build something like this with just this many nodes you know I'd be shocked uh but now we have it today so you can do it right so um super easy to work with um not overwhelming that's what I find with creating a lot of these agent tools is you know once you have to get the sub nodes in it gets a little bit overwhelming with the amount of nodes you have to put in and you know possibly if you decide to choose another service you need to refactor right you need to kind of change it and it's always a drag when you're into the situations with this you just knock the node out and you just replace it with another HTTP tool which is fantastic we're going to run very quickly into a video I'm just going to talk through this um so again this is the whole workflow to enable this kind of agent I'm going to open the chat now and I'm just going to type in sorry for the potato quality by the way uh yeah so chat type in that um you know I'm looking for an appointment um it's going to go through the rounds going to ask my name um and then yeah it's going to ask me for a preferred time and date now when I type in my preferred time and date it's going to make a HTP request to the availability API in my cow. com account which just finish this text and it's making a request call and boom right it's now it's brought us back into the agent now again it's just one node it's made the request it's comeback it's tools uh really simple um very powerful feature that we we've only

### [10:00](https://www.youtube.com/watch?v=9E3XU0WKoXY&t=600s) Segment 3 (10:00 - 15:00)

done one note to kind of enable which is great so now I can confirm my kind of availability and then boom we're done again super powerful stuff um that the N team have enabled with this node um simplified workflows you know they not going to take a lot to maintain um you know you can experiment you know gives you that freedom that creativity to you kind of experiment with different Services uh super powerful stuff right uh next example oh Sor yeah so this is the yeah so again yeah just these fours I mean it's always the rescheduling you know continue the conversation rescheduling you can cancel the appointment again these are just API calls and the agent is smart enough to kind of work out um kind of the rest so uh next example now there is no videos after this is the only video um but um yeah so how we did it was um yeah in the HP request node there's um the endpoint we just put the tool description and the endpoint you want so this one shows the scheduling appointment which is like the bookings API um again credentials I love how the credentials work um you just pull it as you would in the HB request node um placeholder definitions is how you get the agent to fill in the dynamic variables and you can Define them like this so it's very kind of organized and you can Define so here I've got session ID schedule start in the inquiry schedule end and finally in the right hand side is the optimized response so what I'm saying is I've toled it on um I'm expecting the response be Json I want to get out the selected uh fields which is ID start time end time and Status so again that's how I reduce the amount of tokens that come back to the agent so the agent can um yeah not hit that uh limit so r very simple kind of um interface to work with um next example is um so previously we saw an agent hitting all apis of One service um we can eras a more powerful way of um bringing in lots of services multiple Services into the agent so imagine in this one is the holiday planning agent um each tool can be hitting Google flights Google hotels um f c for web scraping maybe trip risor for tools now these are all different services with all different response uh formats coming back right um this tool can handle all so there's no sort of edge case uh nodes you kind of have to put in to kind of you know um handle those responses um it's all kind of Consolidated the same format um really powerful stuff if you don't want to search hotels and Google hotels you just go for you know wherever um people get Hotel data from I guess um but yeah you can see how easy it is to swap them out which in the traditional workflow is again that drag of refactoring and um figuring out what the responses and stuff in all these other nodes and makes it very difficult um yeah so that's another example um the final example is you know it doesn't need to be SAS apis right it's just a HTP request really but it means um yeah anything with an API can be hooked up to your agent directly uh here we're using the super base um you know rest API the PG rest uh API that they have um if you want to search products you know elastic search has HP um API uh endpoint to do that um and yeah and even kind of posting HP requests like uh you know events to post hog so it can be internal it can be external um any yeah any every API is going to come in to power your agent which is super powerful and again um you know you're not having these complex subw workflows to work with it's just sort of yeah super helpful stuff um next slide yeah that's it um I want to give a huge thanks uh for you for listening and U bot and Lis for giving me the opportunity to showcase this amazing uh update uh to the N nna tools um I want to give a special shout out to Nik Nichol who have been on the intern team as well have been reviewing and approving my AI templates so if you didn't know um I have a Crea account the created Hub where I have all my experimental and refund AI templates on there so please check them out um I love talking about Ai and n 10 and would love to know what you guys are using it for so you know contact UM Post in the Forum I've got some long post long form posts in the Forum but if you want to reach out yeah LinkedIn and Twitter uh my Preferred

### [15:00](https://www.youtube.com/watch?v=9E3XU0WKoXY&t=900s) Segment 4 (15:00 - 20:00)

channel so thank you cheers brilliant thanks Jim this was really amazing and inspiring to see how much you can achieve with so little so few nodes that's really cool uh let me take a real quick look at the questions that we have so we have a couple uh Simon is curious how things work under the hood what does the HTTP tool take as its input can you answer that or is that a question for the N team that's probably for n team I would my answer would be magic it works for yeah magic yeah I'm not sure if there're still around uh yeah maybe I can chip in so it's not using uh the definition of the API like the Swagger Json or the API schema but rather you just provide it with the placeholders uh that and so you're hitting a specific endpoint in those tools and you provide it with the placeholders which the AI fails uh which will be sent to that endpoint and this gives you sort of more control over what uh what AI can do but also gives you uh a nice way to manage your credentials for example in a secure way uh but it wouldn't just be randomly firing request you need to set up like which request is it allowed to fire it and you describe in the placeholder what each parameter means hope that answer the question great thanks Al um rako is interested to know if this could replace tools like crew AI a couple of months ago we had Derek Chung giving a demo of that as well so if you're interested browse back on our YouTube channel um Jim is this something you can take do you have experience with crew AI um I don't actually have much experience with crew AI I mean multiple agents kind of working together still was sort of a new uh thing for me so yeah probably not the best but I mean if it has the HTP um API definitely could um could ping those Services yes right also not exactly the HTTP tool but the sub workflow tool would allow you to do like sub agents and then you can compose uh them uh several levels deep and I guess that also answers the next question if tools can reference other tools right yeah okay cool all right thanks and then finally uh Thomas asks if we have any ideas on how to combine keyword searches with some IC searches for accessing different kinds of databases um I mean through the agent I mean definitely through the agent you could um but I mean definitely depends on your use case right what do you want to kind of do is it you want to search for the product first and then search for related products um you can definitely get the agent to carry out that workflow for sure but um if you kind of want it in one API maybe you need like a third party service or an external service which does that um is that doesn't answer the question I don't know Thomas does it um hi there thank you for the answer um I was thinking of an e-commerce context where you look for trousers in red and it also finds you jeans in Bordeaux for example there would be semantic search in other times you look for um an article number and so sometimes the semantic search has the better results sometimes the keyword and I read somewhere there are ways to combine these so you have search results from your database vector store and then a reranking takes place and it and the best results are then shown as a combination of these both data sources so I was curious if anyone has experience with that or how you would build that into the chatbot you know what I mean yeah definitely I think maybe that's a that's uh that a longer answer would imagine may maybe I can also jump in here a little bit so some of the vector databases like for example we8 I don't think that we have an n8n connector for that uh but they offer hybrid search right so they offer both keyword and uh semantic search based on embeddings and they do that basically by having a ranking trick that that uh retrieves both uh keyword based on keyword search and based on semantic search and then ranks them based on the on their ranking in both of these lists but uh that yeah so that that's one way to do it the other way you would like add two tools uh to an agent that allows you to instruct maybe the agent a little bit better like hey if somebody asks something that requires a keyword search use this tool and otherwise use like a semantic so

### [20:00](https://www.youtube.com/watch?v=9E3XU0WKoXY&t=1200s) Segment 5 (20:00 - 20:00)

that's two ways to do that I think okay actually I have a workflow that of the second option that JB just mentioned so maybe if we have a few minutes after I can show it which does exactly that y let's do that in the chat that sounds good yeah and Everyone by the way JP here just joined N1 team a couple of weeks ago so it's really great to see him make his appearance here so give him a warm welcome thanks JP um okay Jim thanks so much for your uh great example

---
*Источник: https://ekstraktznaniy.ru/video/15631*