Skip to main content
Agent Chat is in closed beta. Contact us at [email protected] to get access.
Build a two-way agent chat in your React app. You supply the UI. Novu supplies conversation state, delivery, and the live socket.

Prerequisites

Complete channel setup first. Then you need:
  • Your application identifier from API Keys
  • A subscriber id for the signed-in person
  • The public agent identifier from the agent page in the dashboard

Install and wrap NovuProvider

@novu/react requires React 18 or later (^18.0.0 or ^19.0.0).
useAgentChat reads the Novu client from context. Place NovuProvider above the chat.
NovuProvider authenticates the subscriber. useAgentChat selects which agent to talk to.

Add Novu Agent Chat to my React app

Open in Cursor

Send a message

Omit conversationId to start a new chat. The first successful send creates the conversation.
If isRunning or isLoading is true, disable the composer. The agent is still working on the turn.

Receive and render parts

messages is the ordered timeline. Each message has role (user or assistant) and parts. Start with type === 'text'. Then handle the other part types as you need them.
Full field tables: useAgentChat.

Thinking and running

While the agent turn is in progress, isRunning is true. typing is present when the agent is typing. Assistant messages can include thinking parts before text arrives.
The first envelope of a turn can create an empty assistant message before any text is folded in. Keep that row in the list. Then fill it as parts arrive.

Tool approval and MCP connect

pendingActions lists waits that block the turn. Do not mix the two action types.
Pass action.id from pendingActions. Do not invent approve or deny ids.

Resume or start another chat

Pass conversationId so the hook loads history on mount.
Store the conversationId that sendMessage returns, or the conversationId field on the hook result. On the next visit, pass that id back in. The hook has no list-conversations API. You store the ids that you want to reopen. To start another chat, remount the component without conversationId, or clear the prop.

Switch agent

agentId selects the agent. If the identifier changes, remount with the new agentId. Omit conversationId unless that conversation belongs to the new agent. A conversation id from a different agent does not resume.

Going to production

HMAC is off by default. Turn it on before you ship. Agent Chat can require two hashes. Each hash has its own dashboard toggle. Both hashes use the same secret: the environment API secret from API Keys. Compute them on your server. Do not compute them in the browser.

subscriberHash

subscriberHash authenticates the signed-in subscriber. Without it, another person can guess a subscriberId and open that subscriber’s session, including Agent Chat. If Security HMAC encryption is on for Novu In-App, pass subscriberHash to NovuProvider. The hash is HMAC-SHA256(secretKey, subscriberId) as a lowercase hex string. Generation recipes (Node.js, Python, and more): Secure your Inbox with HMAC.

agentHash

agentHash authenticates which agent the subscriber can talk to. Without it, a client can send any public agent identifier that is linked to Agent Chat. If Security HMAC encryption is on for Agent Chat:
  1. Open Integrations.
  2. Select the Agent Chat integration.
  3. Enable Security HMAC encryption.
  4. On your server, compute HMAC-SHA256(secretKey, agentIdentifier) as a lowercase hex string.
  5. Pass that value as agentHash to useAgentChat.
If only one toggle is on, pass only that hash. If both toggles are on, pass both hashes.

Next steps

useAgentChat reference

Props, return value, callbacks, and message parts.

Channel setup

Link Agent Chat on the agent.