Set up a trigger for Rigel
agent.trigger.create
POST/api/v1/households/{household_id}/commands/agent.trigger.create
- Command
- Rigel runs it
- Applies offline
Sets up work Rigel does after something happens, such as "when a recipe is cooked, ask that evening how it went" or "when something is added to the shopping list, check the pantry has none". Use it when someone asks for a reaction to a change, not for a time schedule (that is a routine). Name the commands that set it off in commands (tool names with dots), say when to act after them in when, and give a title in plain words for the settings list and a task written for a run with nobody present: the run is shown what happened. It runs with the authority of for_person_id (default: the person asking) and may only tell the family through dashboard cards and notifications. Fails with unknown_command if a name is not a command, person_not_found if for_person_id isn't in the household, and person_required if nobody is named and the requester has no person. Returns the trigger's ID.
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
Idempotency-Keyheaderstringoptional | The command's ID. Reuse it when retrying the same command. |
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
titlestringrequired | What the routine does in plain words for the list in settings, 1–120 characters, such as "Suggest a new recipe on Wednesdays". |
taskstringrequired | The instructions Rigel follows each time, up to 4000 characters, written to be read with nobody around: what to check, when to do something, and what to leave alone. |
appone of: meals, recipes, shopping, inventory, calendar, email, tasks, documents, chat, maintenance, null or nulloptional | The app whose guide Rigel reads for this work; null or left out for none. |
for_person_idstringoptional | Whose authority it runs with and who it is for. Defaults to the person asking. |
commandsarray of stringsrequired | The commands that set it off, 1–20, by tool name with dots, such as [" |
whenone of 3 shapesrequired | When Rigel acts after the event: "soon" (about a minute after, so a burst of changes is one run), "after" some minutes, or "at" a time of day (the next time the household's clock shows it, at least a minute after the event). Example: { "kind": "at", "time": "19:00" }. |
| Shape 1 | |
when.kindone of: soonrequired | No description. |
| Shape 2, with minutes | |
when.kindone of: afterrequired | No description. |
when.minutesintegerrequired | How long after the event, 1 to 1,440 minutes (one day). |
| Shape 3, with time | |
when.kindone of: atrequired | No description. |
when.timestringrequired | The time of day in the household's time zone, 24-hour "HH:MM", such as "09:00". |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.trigger_idstringrequired | The new trigger. |
versionintegerrequired | The household version after the command. |
Errors#
Every error has the same envelope: error.code, error.message, error.details, error.recovery and error.request_id.
| Status | Code | When |
|---|---|---|
400 | validation_failed | A field is missing, misspelled or out of range. details.fields lists each problem. |
401 | unauthenticated | The request has no valid session. |
404 | person_not_found | A person who isn't in the household. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | unknown_command |
|
409 | idempotency_key_reused | The Idempotency-Key was already used for a different command. |
Examples#
These are real. Each scenario is one of the command's test cases, run on a household when this site was built, and the response is what the API returned.
Sets up a trigger for the person asking
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"title": "Ask how a new recipe went",
"task": "Ask how it went.",
"app": "recipes",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "at",
"time": "19:00"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Ask how a new recipe went",
task: "Ask how it went.",
app: "recipes",
commands: [
"recipes.cook.log",
],
when: {
kind: "at",
time: "19:00",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"title": "Ask how a new recipe went",
"task": "Ask how it went.",
"app": "recipes",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "at",
"time": "19:00"
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0GSP1QNAK5YJVDJMP
{
"result": {
"trigger_id": "trg_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}For someone else, watching several commands, after some minutes
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000BBBBBBBBBBBBBBBB' \
-d '{
"title": "Check the pantry",
"task": "Check the pantry has none.",
"for_person_id": "per_01JC000000000000000000000A",
"commands": [
"inventory.item.add",
"inventory.item.adjust"
],
"when": {
"kind": "after",
"minutes": 30
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000BBBBBBBBBBBBBBBB",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Check the pantry",
task: "Check the pantry has none.",
for_person_id: "per_01JC000000000000000000000A",
commands: [
"inventory.item.add",
"inventory.item.adjust",
],
when: {
kind: "after",
minutes: 30,
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000BBBBBBBBBBBBBBBB
{
"title": "Check the pantry",
"task": "Check the pantry has none.",
"for_person_id": "per_01JC000000000000000000000A",
"commands": [
"inventory.item.add",
"inventory.item.adjust"
],
"when": {
"kind": "after",
"minutes": 30
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R01AK9B176BB9D3025
{
"result": {
"trigger_id": "trg_01JC4N00004J057T2A2FXGZEXG"
},
"version": 1
}Soon
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000CCCCCCCCCCCCCCCC' \
-d '{
"title": "Tell me",
"task": "Tell me.",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "soon"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000CCCCCCCCCCCCCCCC",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Tell me",
task: "Tell me.",
commands: [
"recipes.cook.log",
],
when: {
kind: "soon",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000CCCCCCCCCCCCCCCC
{
"title": "Tell me",
"task": "Tell me.",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "soon"
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0Q7XMSSC51V3ESMRT
{
"result": {
"trigger_id": "trg_01JC4N0000MF7D5SWWQQ5KK6CM"
},
"version": 1
}A name that is not a command
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000DDDDDDDDDDDDDDDD' \
-d '{
"title": "Typo",
"task": "Never fires.",
"commands": [
"recipes.cook.recrod"
],
"when": {
"kind": "soon"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000DDDDDDDDDDDDDDDD",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Typo",
task: "Never fires.",
commands: [
"recipes.cook.recrod",
],
when: {
kind: "soon",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000DDDDDDDDDDDDDDDD
{
"title": "Typo",
"task": "Never fires.",
"commands": [
"recipes.cook.recrod"
],
"when": {
"kind": "soon"
}
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0TJAECKR1KVW3MRBZ
{
"error": {
"code": "unknown_command",
"message": "There's no command named recipes.cook.recrod. Use the exact tool names, with dots. No changes were applied.",
"details": {
"commands": [
"recipes.cook.recrod"
]
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0TJAECKR1KVW3MRBZ"
}
}An internal command can't be watched
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000EEEEEEEEEEEEEEEE' \
-d '{
"title": "Internal",
"task": "Not allowed.",
"commands": [
"recipes.cook.log",
"agent.trigger.ran"
],
"when": {
"kind": "soon"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000EEEEEEEEEEEEEEEE",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Internal",
task: "Not allowed.",
commands: [
"recipes.cook.log",
"agent.trigger.ran",
],
when: {
kind: "soon",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000EEEEEEEEEEEEEEEE
{
"title": "Internal",
"task": "Not allowed.",
"commands": [
"recipes.cook.log",
"agent.trigger.ran"
],
"when": {
"kind": "soon"
}
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0H7GPKKP2AQ8FAWW4
{
"error": {
"code": "unknown_command",
"message": "There's no command named agent.trigger.ran. Use the exact tool names, with dots. No changes were applied.",
"details": {
"commands": [
"agent.trigger.ran"
]
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0H7GPKKP2AQ8FAWW4"
}
}A query name is not a command
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000FFFFFFFFFFFFFFFF' \
-d '{
"title": "Query",
"task": "Not allowed.",
"commands": [
"agent.trigger.list"
],
"when": {
"kind": "soon"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000FFFFFFFFFFFFFFFF",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Query",
task: "Not allowed.",
commands: [
"agent.trigger.list",
],
when: {
kind: "soon",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000FFFFFFFFFFFFFFFF
{
"title": "Query",
"task": "Not allowed.",
"commands": [
"agent.trigger.list"
],
"when": {
"kind": "soon"
}
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0NW4R2DG4PFXPQJWA
{
"error": {
"code": "unknown_command",
"message": "There's no command named agent.trigger.list. Use the exact tool names, with dots. No changes were applied.",
"details": {
"commands": [
"agent.trigger.list"
]
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0NW4R2DG4PFXPQJWA"
}
}A person who isn't in the household
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000HHHHHHHHHHHHHHHH' \
-d '{
"title": "Who?",
"task": "Nobody.",
"for_person_id": "per_01JC000000000000000000000Z",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "soon"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000HHHHHHHHHHHHHHHH",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Who?",
task: "Nobody.",
for_person_id: "per_01JC000000000000000000000Z",
commands: [
"recipes.cook.log",
],
when: {
kind: "soon",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000HHHHHHHHHHHHHHHH
{
"title": "Who?",
"task": "Nobody.",
"for_person_id": "per_01JC000000000000000000000Z",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "soon"
}
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0NX7Z0B812B2K80DE
{
"error": {
"code": "person_not_found",
"message": "That person isn't in the household. No changes were applied.",
"details": {
"person_id": "per_01JC000000000000000000000Z"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0NX7Z0B812B2K80DE"
}
}Set up a trigger
Work Rigel does after something happens: it names the commands that set it off, and how long after to act.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CTCG4J1SPNDVF3C898WX' \
-d '{
"title": "Ask how a new recipe went",
"task": "When a recipe is cooked for the first time, ask that evening how it went and whether to keep it in the rotation.",
"app": "recipes",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "after",
"minutes": 120
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CTCG4J1SPNDVF3C898WX",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Ask how a new recipe went",
task: "When a recipe is cooked for the first time, ask that evening how it went and whether to keep it in the rotation.",
app: "recipes",
commands: [
"recipes.cook.log",
],
when: {
kind: "after",
minutes: 120,
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CTCG4J1SPNDVF3C898WX
{
"title": "Ask how a new recipe went",
"task": "When a recipe is cooked for the first time, ask that evening how it went and whether to keep it in the rotation.",
"app": "recipes",
"commands": [
"recipes.cook.log"
],
"when": {
"kind": "after",
"minutes": 120
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CTCGHA6DMER74GQB46FV
{
"result": {
"trigger_id": "trg_01M6V9CTCG6HY7NK67ENWMSS1Z"
},
"version": 318
}Set up a trigger that acts right away
soon acts a moment after the command, once a burst of changes settles.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CTCJ23MWNHSHDMMXT58V' \
-d '{
"title": "Restock the furnace filter",
"task": "When the furnace filter task is checked off, look at the pantry. If there is no spare filter, add a pack to the shopping list.",
"app": "maintenance",
"commands": [
"maintenance.task.complete"
],
"when": {
"kind": "soon"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CTCJ23MWNHSHDMMXT58V",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Restock the furnace filter",
task: "When the furnace filter task is checked off, look at the pantry. If there is no spare filter, add a pack to the shopping list.",
app: "maintenance",
commands: [
"maintenance.task.complete",
],
when: {
kind: "soon",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CTCJ23MWNHSHDMMXT58V
{
"title": "Restock the furnace filter",
"task": "When the furnace filter task is checked off, look at the pantry. If there is no spare filter, add a pack to the shopping list.",
"app": "maintenance",
"commands": [
"maintenance.task.complete"
],
"when": {
"kind": "soon"
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CTCJ9421NKM4N21PAPNX
{
"result": {
"trigger_id": "trg_01M6V9CTCJM5QBJAYNNWJSW67W"
},
"version": 319
}Watch a command that doesn't exist
Command names are checked against the ones Rigel knows.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CTCK0TB7C2SJFHCG7DFF' \
-d '{
"title": "Watch a command that isn'\''t there",
"task": "Do something.",
"commands": [
"tasks.task.explode"
],
"when": {
"kind": "soon"
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CTCK0TB7C2SJFHCG7DFF",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Watch a command that isn't there",
task: "Do something.",
commands: [
"tasks.task.explode",
],
when: {
kind: "soon",
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/agent.trigger.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CTCK0TB7C2SJFHCG7DFF
{
"title": "Watch a command that isn't there",
"task": "Do something.",
"commands": [
"tasks.task.explode"
],
"when": {
"kind": "soon"
}
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01M6V9CTCK6ENVSHXH6CTG5P2Z
{
"error": {
"code": "unknown_command",
"message": "There's no command named tasks.task.explode. Use the exact tool names, with dots. No changes were applied.",
"details": {
"commands": [
"tasks.task.explode"
]
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01M6V9CTCK6ENVSHXH6CTG5P2Z"
}
}For Rigel#
Rigel's tool for this command is agent_trigger_create. Rigel runs this on its own, then says what it did. The agent guide has the rest.