Ask everyone, tally the answers
Send one question to a topic and every holder gets their own copy to answer. The send returns a group handle; collecting on it streams each person's answer as it lands and ends once everyone has responded.
Good for: quick team polls, headcounts, go/no-go checks across a crew, "who is on site tomorrow?".
bash
# send, then collect every answer as NDJSON; ends when everyone answered
sp task -t crew --format json --title "Team dinner on Friday?" \
-c "Yes,No,Maybe" \
| sp collect --inputspython
import asyncio
from collections import Counter
from simplepush import Client, ChoiceInput, TaskCompleted
client = Client(api_token="YOUR_API_TOKEN")
group = client.send_task(
topic="crew",
title="Team dinner on Friday?",
inputs=[ChoiceInput(options=["Yes", "No", "Maybe"])],
)
async def main():
tally = Counter()
async for g in group.inputs(timeout=3600):
if isinstance(g.item, TaskCompleted):
answer = g.item.uploads[0].value
tally[answer] += 1
print(f"{g.recipient}: {answer}")
print(dict(tally))
await client.aclose()
asyncio.run(main())ts
import { Client } from '@simplepush/sdk'
const client = new Client({ apiToken: 'YOUR_API_TOKEN' })
const group = await client.sendTask({
topic: 'crew',
title: 'Team dinner on Friday?',
inputs: [{ type: 'choice', options: ['Yes', 'No', 'Maybe'], required: true }],
})
const tally = new Map<string, number>()
for await (const { item, recipient } of group.inputs({ idleMs: 3_600_000 })) {
if (item.kind === 'taskCompleted') {
const choice = item.uploads.find((u) => u.kind === 'choice')
if (choice?.kind === 'choice') {
tally.set(choice.value, (tally.get(choice.value) ?? 0) + 1)
console.log(`${recipient?.name}: ${choice.value}`)
}
}
}
console.log(tally)
client.close()bash
# sending works fine over plain HTTP...
curl -i -X POST https://api.simplepu.sh/v1/tasks \
-H "API-Token: $SP_API_TOKEN" \
-H "Topic: crew" \
-H "Title: Team dinner on Friday?" \
-H "Choice-Input: Yes,No,Maybe"
# ...but `Wait: true` only returns the FIRST answer. To gather all of
# them, collect the group with `sp collect` or an SDK stream instead.Each recipient answers independently on their own instance, so late answers don't block early ones and you see who said what. The CLI pipe emits one JSON line per answer plus a final end line with counts ({"members":{"total":5,"completed":5,...}}), ready for jq or an agent to consume.
The timeouts above measure silence across the whole group: one quiet teammate doesn't end the stream, but an hour with no new answers does.