-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
All API traffic flows through the Express server on port
3000. Admin endpoints require theX-Admin-Tokenheader.
β Navigation: Home Β· Architecture Β· Setup
| Environment | URL |
|---|---|
| Local development | http://localhost:3000 |
| Production | Proxied by Nginx β see Deployment |
Two auth mechanisms are used depending on the endpoint:
| Type | Header | Used for |
|---|---|---|
| Bearer token | Authorization: Bearer {token} |
Token refresh only β token comes from POST /conversation
|
| Admin token | X-Admin-Token: {ADMIN_TOKEN} |
All admin-protected endpoints |
β οΈ TheADMIN_TOKENvalue is set inserver/.envand must match the token used in the admin dashboard login form exactly (case-sensitive).
Start a new Direct Line conversation.
Auth: None required.
Response:
{
"conversationId": "abc123",
"token": "eyJ...",
"expires_in": 1800,
"streamUrl": "wss://directline.botframework.com/..."
}The conversationId is automatically persisted to SQLite. The client opens a WebSocket to streamUrl using the returned token.
Send a message to the Copilot Studio agent.
Auth: None required.
Request body:
{
"text": "What are the graduation requirements?",
"from": "student"
}
fromis optional and defaults to"student"if omitted.
Response: Forwards the Direct Line activity response from Azure.
Refresh an expiring Direct Line token.
Auth: Authorization: Bearer {current_token}
Response:
{
"token": "eyJ...",
"expires_in": 1800
}Direct Line tokens expire after 30 minutes. The client should refresh proactively before expiry to keep long sessions alive.
π All endpoints in this section require the
X-Admin-Tokenheader.
List all stored conversation records from SQLite.
Auth: X-Admin-Token: {ADMIN_TOKEN}
Response:
[
{ "id": 1, "conversationId": "abc123", "createdAt": "2024-01-15T10:30:00Z" },
{ "id": 2, "conversationId": "def456", "createdAt": "2024-01-15T11:15:00Z" }
]Retrieve a single conversation by its SQLite row ID.
Auth: X-Admin-Token: {ADMIN_TOKEN}
URL parameter: id β the integer row ID from the database (not the conversationId string).
Submit a star rating for a conversation.
Auth: None required.
Request body:
{
"rating": 4
}
ratingmust be an integer from1to5. Values outside this range are rejected.
Retrieve all feedback entries, counts, and average rating.
Auth: X-Admin-Token: {ADMIN_TOKEN}
Response:
{
"average": 4.2,
"total": 38,
"distribution": { "1": 2, "2": 3, "3": 5, "4": 14, "5": 14 },
"entries": [...]
}| Status | Meaning |
|---|---|
400 |
Bad request β missing or invalid body field (e.g. rating out of range) |
401 |
Unauthorized β missing or incorrect X-Admin-Token
|
404 |
Not found β conversation ID does not exist |
500 |
Server error β check DIRECT_LINE_SECRET is set correctly |
These keys are managed entirely by the client and are not sent to the server as headers β they are used for local state persistence only.
| Key | Contents |
|---|---|
opotin_chat_messages |
Serialised chat history array |
opotin_conversation |
Conversation metadata object |
opotin_watermark |
Last seen Direct Line watermark |
opotin_admin_token |
Admin token (admin app only) |
β Next: π Setup & Configuration Β· π Deployment
π Live π¬ Chatbot π Admin Dashboard
π Pages
π Home ποΈ Architecture β¨ Features π API Reference π Setup & Config π οΈ Tech Stack π Deployment π₯ Team π©Ί Troubleshooting
π Subprojects
client/ Β· Chat UI Β· :5173
server/ Β· Proxy + API Β· :3000
admin/ Β· Dashboard Β· :5174
TAMK Student Guide