The process you host
Teams does not run this code. You run one Node process and give it a public HTTPS address. When someone writes to the bot, Microsoft calls POST /api/messages on that address. This page is the description of the process: the routes, the bodies, and the records it keeps until it stops.
The same process serves this page and the API. This page does not send anything. Factory calls a separate route for knowledge, a 1:1 notice, a channel notice, a summary, and a decision. POST /api/messages is only the Teams transport: a message asks knowledge, an invoke vote records a vote, and a conversationUpdate stores an address. A Factory notification body posted there is ignored.
Activities, votes, notices, and conversation references live in process memory and disappear when the process stops. Each accepted POST appends one row to operations and one row to logs in Postgres.
Decision action
{
"action": "vote",
"decisionId": "ship-digest",
"optionId": "yes"
}
Records in this process
People
Identity on an activity is from.aadObjectId. Grants decide which documents a search may return. The voter list is separate from grants.
| Name | Id | aadObjectId | Grants |
|---|---|---|---|
| Ada | ada |
aad-ada |
billing |
| Ben | ben |
aad-ben |
hiring |
Knowledge
search keeps a document when the person's grants include its grant and the text appears in the title or body. An empty query returns nothing.
| Id | Title | Body | Grant |
|---|---|---|---|
billing-hours |
Billing hours | Round project time to the nearest quarter hour. | billing |
hiring-panel |
Hiring panel | Two interviewers score the same exercise. | hiring |
Decision
ship-digest — Send the daily summary at 17:00? Options: yes, no. Voters: Ada.
Response 200
{ "ok": true }
curl -s http://localhost:3978/healthRegister this later on an Azure Bot as https://<your-host>/api/messages. A body that is not one of the three activities below is stored and ignored. It does not send a notice or open a decision.
Message
Calls the knowledge search for from.aadObjectId and returns a kb-answer card.
{
"type": "message",
"text": "billing hours",
"from": { "aadObjectId": "aad-ada" },
"conversation": { "id": "personal-aad-ada", "conversationType": "personal" }
}
Vote
Calls the vote route. A missing decision, an unknown option, or a person off the list returns ok: false and does not change the votes.
{
"type": "invoke",
"name": "adaptiveCard/action",
"from": { "aadObjectId": "aad-ada" },
"value": { "action": "vote", "decisionId": "ship-digest", "optionId": "yes" }
}
Install
A personal conversationUpdate stores the person. conversationType: channel stores the channel.
{
"type": "conversationUpdate",
"from": { "aadObjectId": "aad-ada" },
"conversation": { "id": "personal-aad-ada", "conversationType": "personal" }
}Factory or a Teams question. An unknown person gets an empty kb-answer card.
{ "aadObjectId": "aad-ada", "text": "billing hours" }
Response 200
{ "ok": true, "card": { "type": "kb-answer", "title": "Knowledge", "items": [] } }Send exactly one of a person or a channel, plus conversationId.
{ "aadObjectId": "aad-ada", "conversationId": "personal-aad-ada" }
{ "channelId": "team-general", "conversationId": "channel-general" }Requires a saved person address. Otherwise 409 and reason: no-conversation.
{ "aadObjectId": "aad-ada", "title": "Hours", "body": "Round to a quarter hour." }
Card
{ "type": "direct", "title": "Hours", "body": "Round to a quarter hour.", "audience": { "audience": "user", "id": "aad-ada" } }Requires a saved channel address. Otherwise 409 and reason: no-conversation.
{ "channelId": "team-general", "title": "Standup", "body": "Three items are blocked." }
Card
{ "type": "channel", "title": "Standup", "body": "Three items are blocked.", "audience": { "audience": "channel", "id": "team-general" } }audience is user or channel. An empty queue returns ok: false and reason: empty and changes nothing.
{ "audience": "user", "id": "aad-ada" }
Card
{ "type": "digest", "title": "Summary", "items": [] }target is the person or channel that should receive the card. No saved address returns 409 and does not create the decision.
{
"id": "ship-digest",
"question": "Send the daily summary at 17:00?",
"voters": ["ada"],
"options": [{ "id": "yes", "label": "Yes" }, { "id": "no", "label": "No" }],
"target": { "audience": "user", "id": "aad-ada" }
}
Card
{
"type": "decision",
"title": "Send the daily summary at 17:00?",
"actions": [{ "title": "Yes", "data": { "action": "vote", "decisionId": "ship-digest", "optionId": "yes" } }]
}A missing decision, an unknown option, or a person off the list returns ok: false and leaves the votes unchanged.
{ "aadObjectId": "aad-ada", "optionId": "yes" }Errors
| Status | When | Body |
|---|---|---|
400 | POST /api/messages body is not JSON | {"ok":false,"reason":"bad-json"} |
413 | Body larger than 1 MB | {"ok":false} |
404 | Any other path | {"ok":false} |
409 | A send has no saved address, or the decision id already exists | {"ok":false,"reason":"no-conversation"} |
500 | The operation or the log row could not be written | {"ok":false} |
What this process is holding
The lists below are the memory of this running process. They are not edited from this page.
Activities
No activity has been stored in this process yet.
Knowledge answer
No knowledge answer has been produced yet. A message whose sender has no matching grant returns an empty item list.
Direct card
No 1:1 card has been built yet.
Channel card
No channel card has been built yet.
Decision card
No decision has been opened through the API yet.
Decision votes
Send the daily summary at 17:00?
No votes recorded. Ada can vote. Anyone else leaves the record unchanged.
Notification queue
The notification queue is empty.
No summary has been built.
Conversation references
No conversation reference has been saved.
Operations
One row per accepted POST, newest first. These rows stay in Postgres after the process stops.
| At | Kind | Actor | Result | Detail |
|---|---|---|---|---|
| No operations have been recorded. | ||||
Logs
One row per accepted POST, including rejected bodies. The detail carries the path and the status that was returned.
| At | Level | Message | Detail |
|---|---|---|---|
| No logs have been recorded. | |||