Enable your Agents to stream updates to your UI.
Our Database AI Agent now features a realtime chat UI
databaseAgentChannel
takes a unique threadId
as an argument, ensuring that each discussion has its own channel.
We also added two topics to the channel:
messages
: For all messages sent by the Agentsstatus
: For global status updatespublish()
function, which we’ll use to publish updates to the UI:
publish()
takes a channel topic as an argument, ensuring end-to-end type safety when writing your publish calls.
All messages sent using publish()
are guaranteed to be delivered at most once with the lowest latency possible.
threadId
as follows.
In a Next.js application, triggering Inngest functions can be achieved using a Server Action:
useInngestSubscription
hook:
startChat()
callback is called when the user clicks the “Run” button or presses Enter.startChat()
callback calls the runDatabaseAgent()
server action to trigger the Agent.runDatabaseAgent()
server action generates a unique threadId
and sends it to the Agent.fetchSubscriptionToken()
server action fetches a subscription token for the threadId
.useInngestSubscription()
hook subscribes to the messages
and status
topics and updates the UI in realtime.data
object, which contains the latest updates from the Agent:
useInngestSubscription()
hook, please refer to the Inngest Realtime API documentation.