FlowlyBot

0.5.2

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.

NameIdaadObjectIdGrants
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.

IdTitleBodyGrant
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.

GET /health Liveness of the process. No request body.

Response 200

{ "ok": true }
curl -s http://localhost:3978/health
POST /api/messages Teams activity transport. Delegates to the route for that activity.

Register 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" }
}
POST /api/knowledge Search documents the asking person is allowed to read.

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": [] } }
POST /api/conversations Save the address used later for a 1:1 or channel send.

Send exactly one of a person or a channel, plus conversationId.

{ "aadObjectId": "aad-ada", "conversationId": "personal-aad-ada" }
{ "channelId": "team-general", "conversationId": "channel-general" }
POST /api/notifications/direct Queue a 1:1 notice and return a direct card.

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" } }
POST /api/notifications/channel Queue a channel notice and return a channel card.

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" } }
POST /api/notifications/summary Fold pending notices for one recipient into a digest card.

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": [] }
POST /api/decisions Open a Factory decision and return a decision card.

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" } }]
}
POST /api/decisions/{id}/votes Record one vote from a person on the voter list.

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

StatusWhenBody
400POST /api/messages body is not JSON{"ok":false,"reason":"bad-json"}
413Body larger than 1 MB{"ok":false}
404Any other path{"ok":false}
409A send has no saved address, or the decision id already exists{"ok":false,"reason":"no-conversation"}
500The 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.

AtKindActorResultDetail
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.

AtLevelMessageDetail
No logs have been recorded.