Choose which Gmail mail Rigel reads
email.connection.set_filter
POST/api/v1/households/{household_id}/commands/email.connection.set_filter
- Command
- Rigel runs it
- Applies offline
Sets the Gmail labels and sender addresses or domains whose mail Rigel reads from a connected Gmail account; mail that matches neither is never read. Creates the connection the first time and replaces the filter after that. At least one label or sender is required. Fails with integration_not_found, or wrong_service when the integration isn't Gmail.
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 |
|---|---|
integration_idstringrequired | The connected Gmail account. |
labelsarray of stringsrequired | Gmail labels to read, up to 20. Can be empty if senders is not. |
sendersarray of stringsrequired | Sender addresses or domains to read, up to 20. Can be empty if labels is not. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.email_connection_idstringrequired | The connection that was created or changed. |
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 | integration_not_found | An integration that isn't there is refused. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | wrong_service | Only Gmail can be read. |
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.
Creates the connection and its rules the first time
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"Rigel",
"Quotes"
],
"senders": [
"smithhvac.example"
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
integration_id: "int_01JC0000000000000000000001",
labels: [
"Rigel",
"Quotes",
],
senders: [
"smithhvac.example",
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"Rigel",
"Quotes"
],
"senders": [
"smithhvac.example"
]
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0QH5HDR9PNPA890N3
{
"result": {
"email_connection_id": "emc_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Senders alone are enough, and repeats count once
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"integration_id": "int_01JC0000000000000000000001",
"labels": [],
"senders": [
"kim@example.com",
"kim@example.com"
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
integration_id: "int_01JC0000000000000000000001",
labels: [],
senders: [
"kim@example.com",
"kim@example.com",
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"integration_id": "int_01JC0000000000000000000001",
"labels": [],
"senders": [
"kim@example.com",
"kim@example.com"
]
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0PHF60554XR02CF0X
{
"result": {
"email_connection_id": "emc_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Replaces the rules, keeps the ones that stay, and clears the problem
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"Keep",
"New"
],
"senders": []
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
integration_id: "int_01JC0000000000000000000001",
labels: [
"Keep",
"New",
],
senders: [],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"Keep",
"New"
],
"senders": []
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0XA5HWKKFEP82J1TH
{
"result": {
"email_connection_id": "emc_01JC0000000000000000000001"
},
"version": 1
}An integration that isn't there is refused
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"x"
],
"senders": []
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
integration_id: "int_01JC0000000000000000000001",
labels: [
"x",
],
senders: [],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"x"
],
"senders": []
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0QDP1F2S3Q06BATT3
{
"error": {
"code": "integration_not_found",
"message": "That account isn't connected any more. No changes were applied.",
"details": {},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0QDP1F2S3Q06BATT3"
}
}Only Gmail can be read
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"x"
],
"senders": []
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
integration_id: "int_01JC0000000000000000000001",
labels: [
"x",
],
senders: [],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"integration_id": "int_01JC0000000000000000000001",
"labels": [
"x"
],
"senders": []
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0F40TBCKBA4MXPG7H
{
"error": {
"code": "wrong_service",
"message": "Only a connected Gmail account can be read this way. No changes were applied.",
"details": {
"service": "google_calendar"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0F40TBCKBA4MXPG7H"
}
}For Rigel#
Rigel's tool for this command is email_connection_set_filter. Rigel runs this on its own, then says what it did. The agent guide has the rest.