HTTP Channels for Managed Deep Agents
Read the Portuguese translation →
Author: LangChain · Watch on YouTube
Video authored by the channel shown, not by IANIA; all rights belong to the creator. Transcript and summary generated automatically; the original-language content is preserved.
Original language: English
Original video: HTTP Channels for Managed Deep Agents · Channel: LangChain · 07:58 · Watch on YouTube
Topics: AI agents, Task and workflow automation, AI developer tools
Summary
Section titled “Summary”The video explains how to build a custom HTTP channel for a managed deep agent, using a receipt-triage agent connected to Photon for iMessage. The setup requires custom functions to verify inbound requests, parse their contents, manage thread IDs, and send replies through a post hook. The example agent extracts information from receipt images and stores expenses in durable memory, which can later be queried. HTTP channels are intended for events from external services, and production deployments with multiple users need appropriate authorization.
Key points
Section titled “Key points”- Custom HTTP channels are useful for inbound requests from external services or providers without built-in channels.
- The example builds an expense-reporting agent called Reflex and connects it to Photon for iMessage.
- A verifier checks that inbound requests are valid, while a parser extracts relevant text or image content from the event.
- Thread IDs determine whether messages belong to the same conversation; the example hashes a user’s phone number into a UUID.
- A post hook sends the agent’s response back through the channel provider.
- The agent inspects receipt images and stores extracted expense information in durable memory.
- LangSmith traces the agent’s runs, and Context Hub stores the expenses in a Markdown file.
- For production use with multiple users, authorization is needed to keep users’ receipts separate.
- HTTP channels can be combined with pre-built channels, while custom UIs are better suited to the LangGraph SDK.
Chapters
Section titled “Chapters”| Start | Chapter | Summary |
|---|---|---|
| 00:00 | What HTTP channels are for | Nathan introduces custom HTTP channels and outlines a receipt-triage agent that will receive messages through an external service. |
| 01:04 | Scaffolding the agent and adding memory | The example agent is configured with expense-reporting instructions and durable memory for its ledger. |
| 02:07 | Connecting Photon and handling inbound messages | The walkthrough sets up Photon and implements functions to verify incoming requests and parse message content. |
| 04:12 | Managing threads and sending replies | The example derives thread IDs from users’ phone numbers and adds a post hook to send responses through Photon. |
| 05:52 | Deploying the agent and reviewing the results | The deployed agent processes receipt images, writes expenses to durable memory, and demonstrates how HTTP channels handle external events. |
Quotes
Section titled “Quotes”You’re going to want to use a custom HTTP channel anytime you want inbound requests to your agent that you don’t control — 00:00
The parser takes in an event and parses the JSON that comes from this event. — 03:42
the thread ID is pretty crucial, and this is gonna be important for the user experience of your agent. — 04:12
With post, we can send the response back to the channel provider — 05:20
You need to handle the shape of the event, you need to handle parsing it out, and you need to handle verifying the event — 07:58
Concepts and entities
Section titled “Concepts and entities”HTTP channels, Managed Deep Agents, Photon, LangChain, LangSmith, Context Hub, LangGraph SDK, durable memory, Reflex, Nathan
Full transcript (original language)
Section titled “Full transcript (original language)”00:00 Hey, I’m Nathan. I’m a product manager here at LangChain, and today we’re talking about custom channels for managed deep agents over HTTP. You’re going to want to use a custom HTTP channel anytime you want inbound requests to your agent that you don’t control, or for services where we don’t yet have built-in channels. Today, this includes Slack. Think, for example, requests from an external service like HubSpot or Salesforce, or custom services to manage connections through RCS, WhatsApp, or iMessage, like Photon or Twilio. Today we’re gonna build an example of an agent that can handle receipt triage, where when I send in expenses, the agent can store them
00:31 securely using durable memory. Essentially our project structure is gonna look as it usually does, where we define our agent, and we’re gonna add a custom channel in there. You declare the channel with a basic setup, and you need to provide your own functions to verify and parse any of the inbound messages. So when the external service sends a message, this will create a run for your agent, but your agent needs to handle the verification to ensure that the message is sent securely, and the parsing to pull out the relevant data that the agent needs to actually process in order to create a reasonable response.
01:04 So let’s scaffold our agent out. I’ve created an agent, in this case, using TypeScript, but if you’re following along on Python, it’s overall the same basic concepts. the first thing we wanna do is add our own instruction set. So this agent is gonna be called Reflex. It’s an expense reporting agent. We have some policy that’s encoded in our instructions.md. And then we’re saying also our ledger is gonna be stored in memory. Today we’re gonna use durable memory to store the ledger, but in a production use case, you might use an external service in order to store the ledger across
01:36 many users that are interacting with it. let’s try out our agent with just these instructions and see how it works. We can chat with it in the terminal interface here. Let’s ask what it can do All right, sweet. So the instructions took effect. And the agent can answer basic questions about the policy. To distribute this, we want this to be a text message agent, we don’t want people interacting with this from the terminal. But just to get started, this gives us a sense of how we’re managing the personality and basic levers inside of this agent. Now that we have our instructions file set up, let’s add in our memory
02:07 All right, so I’ve created the memory file, and we’re gonna add in our memory definition. In this case, it’s a very simple durable memory setup where the agent has access to the memory layer, and it’s gonna be able to store files in Context Hub using this Okay, so let’s start adding our channel. We’ll start by adding our verifier and our parser. And today, we’re gonna be using Photon as the channel. Photon is a simple system to allow us to connect using SMS or iMessage or WhatsApp or other systems. So in my Photon dashboard, I’ve set up a project here called Reflex for
02:39 the agent that I’ll be building. This is gonna be distributed in iMessage. In this case, it’s private to only me, and we’re going to send requests back to Photon using webhooks. So when the agent responds, we’ll invoke a webhook, and this will allow the user to receive a text from our agent So here we’re setting up, just like we saw in the docs, our verify and our parsing function, which we’re going to build. And this is what the managed deep agent is gonna use to communicate or receive events from this channel
03:10 So the first thing that we need in the case of this implementation is a client. So we’re gonna add in our Photon client, which is going to allow us to interact with Photon. Every connection you create may have a slightly different configuration depending on what the provider recommends and how we expect it to work Let’s add our verifier and our parser So first we’ll add in the verifier. We’re gonna put it in this Photon file, which we’re referencing from over here. In the verifier we’re receiving raw bytes and we’re ensuring that this is a valid request.
03:42 Next, we’ll add in our parser The parser is gonna look different depending on what your channel is. The parser takes in an event and parses the JSON that comes from this event. And in pretty much any case, the JSON is gonna look a little bit different. What you’re gonna wanna do is pull out the relevant parts of the JSON response and pass that through to your agent. So here we have some error handling that’s managed in here. We’re gonna pull out our content, which is either gonna be text that’s coming in from the text messages or images that’s coming in from the text messages, and
04:12 then we’re going to pass that through to our agent, and we’ll return this as type message so that the agent can respond. Okay, so now that the basics are configured for inbound messages, we’re gonna make sure that our threading is managed So when you’re parsing the request, the thread ID is pretty crucial, and this is gonna be important for the user experience of your agent. This is how you control when a new thread is created, or when a thread is destroyed. And here we’re gonna identify users by the inbound text message. So what we can do is we can hash the text message phone number into
04:46 a UUID that we can use to match that to a thread and keep track of things over a longer period of time. So if a user is texting our agent over a longer period of time, then all of those requests are managed in the same thread, and the agent will be able to keep track in context of messages that have already been sent. For example, if I send the same receipt twice. Let’s add that handler in order to hash our phone numbers into UUIDs When you’re doing this, it may look a little different depending on your hashing function. Maybe you want to reset the thread every day, or you wanna give the user the ability to reset their thread with certain commands.
05:20 You can control that depending on how you set up the thread ID and how you reset the thread ID when a user is interacting with the agent over time In our agent, we also want to send replies. When a user sends in a receipt or asks a question about the policy, we wanna make sure that we’re able to actually respond successfully to that user. So we’re gonna include a post hook as well. With post, we can send the response back to the channel provider, in this case Photon, and then Photon can handle the rest, in this case, sending out the actual text message
05:52 All right, so we’ll add our post logic into our Photon file here. This is added in, and again, the post logic might look different depending on your provider. Now we wanna add that to the channel definition. Okay, so things look good. Now our agent is going to be able to take in messages from Photon and send out messages back to Photon after handling them using the logic provided. When we receive a message, we’re going to pull out the image and the text. The agent is going to inspect the image, and based on its instructions,
06:25 it will pull out specific information, and then it will store that information in durable memory. So we end up with an agent that’s going to be able to take in receipts, triage them, and store them in a way that will be reusable later. All right, so let’s get this deployed And then we’ll take a look at how the agent works Let’s text the agent that we have a receipt to expense. Photon will receive the request, pass that on to the LangSmith deployment, and our agent server can respond. It’ll say it wants the receipt. We can pass that on.
06:55 We’ll send the photo. The agent will automatically spin up a sandbox, pull out the data it needs, and give us the response we need, and store it to memory. If we go into LangSmith, we can see the agent and the set of runs that happened, and these are traced here, so I could take a deeper look at the text message interactions from within the LangSmith portal. But we can also see in our Context Hub, in the specific memory of this agent, that it’s written to the expenses file here. So it’s created a table in Markdown that creates all of the expenses that I sent,
07:25 including the one that we just texted. Here it is. So if a user asks later on about the expenses that they’ve sent, then the agent can pull that data from Context Hub and return that back to them using durable memory. Again, if you’re building this in production with multiplayer and many users, you’re gonna need to add in authorization so that different receipts are stored in different places depending on the user that sent them, or receipts are stored in an external service. That’s a quick intro to HTTP channels. You can use these to handle inbound events to your agent from any external service, rather than just the ones that are pre-built.
07:58 You can also combine HTTP channels with some of the pre-built channels like Slack, so users have multiple interfaces with which they can interact with your agent. If you’re building a custom UI for your agent, you’re probably gonna wanna stick with the LangGraph SDK. In general, HTTP channels are always for events that you don’t have control over, where it’s sent by an external service. You need to handle the shape of the event, you need to handle parsing it out, and you need to handle verifying the event in order to ensure that it’s securely transmitted. That’s it for today. See you next time.