Skip to main content

Chat Interface (Part B)

Your Chat Interface is where users interact with your agent. It calls Daemo's HTTP API and can be any frontend — website, mobile app, Slack bot, or API integration.

Note

This is separate from your Functions Service. Your chat UI can live in a completely different repo, different tech stack, different deployment.


Quick Start

Call the HTTP Query API from anywhere:

curl -X POST https://api.daemo.ai/agents/{agent_id}/query \
-H "Content-Type: application/json" \
-H "X-API-Key: daemo_live_your_key" \
-d '{"query": "Show me all users"}'

That's it. Your functions service executes the query and returns a response.


Integration Examples

Next.js / React

app/api/chat/route.ts
export async function POST(req: Request) {
const { message, threadId } = await req.json();

const response = await fetch(
`https://api.daemo.ai/agents/${process.env.DAEMO_AGENT_ID}/query`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.DAEMO_API_KEY!,
},
body: JSON.stringify({
query: message,
threadId,
}),
}
);

return response;
}

Python / FastAPI

main.py
import httpx
from fastapi import FastAPI

app = FastAPI()

@app.post("/chat")
async def chat(message: str, thread_id: str = None):
async with httpx.AsyncClient() as client:
response = await client.post(
f"https://api.daemo.ai/agents/{AGENT_ID}/query",
headers={
"Content-Type": "application/json",
"X-API-Key": DAEMO_API_KEY,
},
json={
"query": message,
"threadId": thread_id,
},
)
return response.json()

Node.js / Express

server.js
app.post('/chat', async (req, res) => {
const { message, threadId } = req.body;

const response = await fetch(
`https://api.daemo.ai/agents/${process.env.DAEMO_AGENT_ID}/query`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.DAEMO_API_KEY,
},
body: JSON.stringify({
query: message,
threadId,
}),
}
);

res.json(await response.json());
});

Multiple Interfaces

One of Daemo's strengths: deploy your functions once, integrate everywhere.

🌐Website
📱Mobile App
💼Admin Portal
💬Slack Bot
All calling the sameHTTP Query APIYour Functions Service

Common Patterns

Monorepo

Everything in one repo — simple for small projects.

my-app/
├── functions/ ← Part A (deploy separately)
│ └── src/
└── web/ ← Part B (your frontend)
└── app/

Better for teams and multiple interfaces.

# Functions Service (Part A)
my-agent/
├── src/functions/
└── package.json

# Website (Part B)
my-website/
└── components/ChatWidget.tsx

# Mobile App (Part B)
my-mobile/
└── screens/ChatScreen.tsx

API Reference

See the full HTTP Query API documentation → for:

  • Request/response formats
  • Streaming support
  • Thread management
  • Error handling

Deploying Your Chat Interface

Your chat interface deploys like any other frontend:

PlatformGood For
VercelNext.js, React
NetlifyStatic sites, React
AWS AmplifyFull-stack AWS
App StoreiOS apps
Play StoreAndroid apps
Tip

The key insight: Your chat interface doesn't need the Daemo SDK. It just makes HTTP requests to the Query API.