# HTTP Channels for Managed Deep Agents

## Executive summary

This session details the implementation of custom HTTP channels for Managed Deep Agents, enabling agents to receive inbound requests from external services that are outside the developer's direct control (e.g., HubSpot, Salesforce, or messaging providers like Photon/iMessage). The process involves defining the agent's instructions, integrating durable memory (Context Hub) for state management, and implementing critical functions—`verify` and `parse`—to securely process and extract data from raw inbound events. The architecture ensures the agent can maintain context across multiple user interactions via stable thread IDs.

## Key takeaways

- Use Case for HTTP Channels: Custom HTTP channels are necessary when an agent needs to handle inbound requests from external services or platforms where LangChain does not provide a built-in channel (e.g., Slack, HubSpot, or custom RCS/iMessage integrations).
- Agent Data Flow and Components: The agent requires defining instructions, utilizing durable memory (Context Hub) for persistent state (like a ledger), and implementing a custom channel definition that includes `verify` and `parse` functions.
- Handling Inbound Messages: The `verify` function ensures the incoming request is valid and secure. The `parse` function extracts relevant data (text, images) from the raw event JSON and passes it to the agent.
- Maintaining User Context: To ensure continuity over time, the agent must manage threads by hashing the inbound message phone number into a UUID, allowing the agent to maintain context across multiple interactions.
- Completing the Interaction Loop: A `post` hook is required to send the agent's successful response back to the channel provider (e.g., Photon), allowing the user to receive the final text message.

## Technical details

- Agent Setup and Memory: The agent (Reflex, an expense-reporting agent) is scaffolded using TypeScript (or Python) and configured to store its ledger in durable memory via Context Hub. For production, external services should be used for ledger storage across multiple users.
- Channel Implementation (Photon Example): Using Photon as the channel provider for iMessage/SMS, the setup requires defining a client, a verifier, and a parser. The parser must extract content (text or images) from the incoming event JSON and return it as a `type message` to the agent.
- Thread Management: Thread ID management is crucial for user experience. Users can be identified by hashing the inbound text message phone number into a UUID, ensuring all subsequent requests from that user are managed within the same thread.
- Deployment and Tracing: After deployment, interactions are traceable in LangSmith, allowing developers to review the full set of runs and see how data is written to the durable memory in Context Hub.

## Practical implications

- HTTP channels are the definitive method for handling asynchronous, uncontrolled inbound events from external services.
- When building a custom UI, developers should stick with the LangGraph SDK, reserving HTTP channels for external event integration.
- For production systems with multiple users, robust authorization mechanisms must be implemented to ensure data isolation (e.g., storing receipts in separate locations per user).

## Topics

Managed Deep Agents, HTTP Channels, LangChain, Durable Memory, Context Hub, LangSmith, Agent Orchestration, HTTP channels docs, Managed Deep Agents overview, Managed Deep Agents waitlist

Source: https://www.youtube.com/watch?v=6v0Fmsi4Ldk
