How can an agentic HTTP request tool let AI dynamically set the <ID> in a URL like https://example.com/contacts/<ID>?

How can an agentic HTTP request tool let AI dynamically set the in a URL like https://example.com/contacts/?

Hi @Biraj_Mainali

Replace the literal <ID> in your URL with the $fromAI() function:

{{$json.BASE_URL}}/contacts/{{ $fromAI('contactId', 'The ID of the contact to retrieve') }}

This tells the AI agent to dynamically fill in the contact ID based on conversation context. The key (contactId) is just a hint for the model, not a reference to an existing variable.

You can also use the small AI icon next to the URL field to have n8n generate the $fromAI() expression for you automatically.

More details here: Let AI specify tool parameters

1 Like

Hi @Biraj_Mainali Welcome!
Your approach for this problem is nice, but what i would recommend is that consider using 1 AI agent that would curate you a list of those urls like your base.URL/contacts/ID and so when you have a list of these URLs generated by AI then use the HTTP node to just call each one of them, depending on the situation i would say you should consider doing that else you are putting a lot of responsibilities to a single AI agent which is highly prone to cause inaccurate and irrelevant responses.

1 Like

Thanks a ton! This really helped; I’ve been stuck on this all morning. Cheers!

1 Like

@Biraj_Mainali Glad it worked out! If you could mark the answer as the solution, it helps others with the same question find the fix faster. Thanks!