copilotz 1.0.0-rc.20 → 1.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +417 -0
- package/README.md +295 -19
- package/hosts/orgs/mod.d.ts +4 -1
- package/hosts/orgs/mod.js +2 -2
- package/hosts/web/files.d.ts +6 -2
- package/hosts/web/files.js +36 -3
- package/hosts/web/node/mod.d.ts +1 -1
- package/hosts/web/node/mod.js +1 -1
- package/hosts/web/node/serve.d.ts +26 -0
- package/hosts/web/node/serve.js +23 -1
- package/hosts/web/routes.d.ts +28 -1
- package/hosts/web/routes.js +65 -10
- package/hosts/web/server.d.ts +5 -4
- package/hosts/web/server.js +1 -1
- package/package.json +2 -2
- package/plugins/access/accounts/collections/account.d.ts +2 -2
- package/plugins/access/contacts/actions/chat.d.ts +1 -0
- package/plugins/access/contacts/actions/chat.js +45 -0
- package/plugins/access/contacts/actions/forget.d.ts +1 -0
- package/plugins/access/contacts/actions/forget.js +56 -0
- package/plugins/access/contacts/actions/start.d.ts +1 -0
- package/plugins/access/contacts/actions/start.js +50 -0
- package/plugins/access/contacts/collections/contact.d.ts +81 -0
- package/plugins/access/contacts/collections/contact.js +58 -0
- package/plugins/access/contacts/contract.d.ts +10 -0
- package/plugins/access/contacts/contract.js +10 -0
- package/plugins/access/contacts/mod.d.ts +27 -0
- package/plugins/access/contacts/mod.js +49 -0
- package/plugins/access/contacts/views/contact.d.ts +8 -0
- package/plugins/access/contacts/views/contact.js +25 -0
- package/plugins/access/contacts/web.d.ts +7 -0
- package/plugins/access/contacts/web.js +11 -0
- package/plugins/access/directory/collections/credit-code.d.ts +1 -1
- package/plugins/access/directory/collections/invite.d.ts +1 -1
- package/plugins/access/identity/mod.js +8 -6
- package/plugins/access/mod.d.ts +7 -1
- package/plugins/access/mod.js +7 -2
- package/plugins/access/spaces/actions/agents.js +12 -6
- package/plugins/access/spaces/actions/create.js +10 -1
- package/plugins/access/spaces/actions/invitation.js +5 -2
- package/plugins/access/spaces/actions/keep.d.ts +1 -0
- package/plugins/access/spaces/actions/keep.js +55 -0
- package/plugins/access/spaces/actions/member.js +17 -4
- package/plugins/access/spaces/actions/rename.js +4 -0
- package/plugins/access/spaces/collections/member.d.ts +1 -1
- package/plugins/access/spaces/collections/request.d.ts +1 -1
- package/plugins/access/spaces/collections/space.d.ts +9 -0
- package/plugins/access/spaces/collections/space.js +2 -0
- package/plugins/access/spaces/contract.d.ts +4 -3
- package/plugins/access/spaces/contract.js +1 -1
- package/plugins/access/spaces/mod.d.ts +7 -1
- package/plugins/access/spaces/mod.js +8 -1
- package/plugins/access/spaces/resources/tools.d.ts +0 -5
- package/plugins/access/spaces/resources/tools.js +11 -1
- package/plugins/access/spaces/shared/agents.js +2 -2
- package/plugins/access/spaces/shared/can.d.ts +18 -3
- package/plugins/access/spaces/shared/can.js +32 -5
- package/plugins/access/spaces/shared/declared.d.ts +21 -0
- package/plugins/access/spaces/shared/declared.js +8 -0
- package/plugins/access/spaces/shared/labels.d.ts +7 -1
- package/plugins/access/spaces/shared/labels.js +56 -8
- package/plugins/access/spaces/shared/managers.js +2 -2
- package/plugins/access/spaces/shared/names.d.ts +9 -5
- package/plugins/access/spaces/shared/names.js +36 -19
- package/plugins/access/spaces/shared/reach.d.ts +20 -6
- package/plugins/access/spaces/shared/reach.js +62 -20
- package/plugins/access/spaces/shared/rules.d.ts +10 -5
- package/plugins/access/spaces/shared/rules.js +35 -10
- package/plugins/access/spaces/shared/seat.d.ts +3 -2
- package/plugins/access/spaces/shared/seat.js +9 -2
- package/plugins/access/spaces/views/where.d.ts +4 -2
- package/plugins/access/spaces/views/where.js +9 -0
- package/plugins/access/spaces/web.js +1 -1
- package/plugins/access/web.d.ts +1 -0
- package/plugins/access/web.js +1 -0
- package/plugins/agents/chat/actions/erase.d.ts +1 -0
- package/plugins/agents/chat/actions/erase.js +51 -0
- package/plugins/agents/chat/actions/open.d.ts +1 -0
- package/plugins/agents/chat/actions/open.js +49 -0
- package/plugins/agents/chat/actions/quiet.d.ts +1 -0
- package/plugins/agents/chat/actions/quiet.js +33 -0
- package/plugins/agents/chat/actions/say.d.ts +1 -0
- package/plugins/agents/chat/actions/say.js +82 -0
- package/plugins/agents/chat/actions/send.js +57 -19
- package/plugins/agents/chat/actions/shown.d.ts +1 -0
- package/plugins/agents/chat/actions/shown.js +35 -0
- package/plugins/agents/chat/collections/intent.d.ts +124 -0
- package/plugins/agents/chat/collections/intent.js +52 -0
- package/plugins/agents/chat/collections/message.d.ts +74 -1
- package/plugins/agents/chat/collections/message.js +23 -1
- package/plugins/agents/chat/collections/shown.d.ts +105 -0
- package/plugins/agents/chat/collections/shown.js +34 -0
- package/plugins/agents/chat/contract.d.ts +15 -7
- package/plugins/agents/chat/contract.js +7 -1
- package/plugins/agents/chat/mod.d.ts +20 -2
- package/plugins/agents/chat/mod.js +43 -4
- package/plugins/agents/chat/processors/failed.js +15 -5
- package/plugins/agents/chat/processors/turn.d.ts +1 -1
- package/plugins/agents/chat/processors/turn.js +95 -35
- package/plugins/agents/chat/shared/delivery.d.ts +16 -2
- package/plugins/agents/chat/shared/delivery.js +62 -7
- package/plugins/agents/chat/shared/send.d.ts +1 -3
- package/plugins/agents/chat/shared/send.js +2 -9
- package/plugins/agents/chat/shared/tools.d.ts +33 -0
- package/plugins/agents/chat/shared/tools.js +28 -0
- package/plugins/agents/chat/shared/types.d.ts +59 -1
- package/plugins/agents/chat/views/message.d.ts +4 -2
- package/plugins/agents/chat/views/message.js +22 -4
- package/plugins/agents/chat/views/prompt.js +38 -4
- package/plugins/agents/history/collections/outline.d.ts +1 -1
- package/plugins/agents/history/collections/summary.d.ts +1 -1
- package/plugins/agents/history/mod.js +2 -1
- package/plugins/agents/history/processors/erase.d.ts +3 -0
- package/plugins/agents/history/processors/erase.js +11 -0
- package/plugins/agents/memory/mod.js +2 -1
- package/plugins/agents/memory/processors/extract.d.ts +1 -1
- package/plugins/agents/memory/processors/extract.js +5 -0
- package/plugins/agents/memory/resources/tools.js +1 -1
- package/plugins/agents/memory/shared/settings.d.ts +7 -2
- package/plugins/agents/memory/shared/settings.js +9 -1
- package/plugins/agents/routines/collections/routine.d.ts +1 -1
- package/plugins/agents/routines/collections/run.d.ts +1 -1
- package/plugins/compute/apps/collections/app.d.ts +2 -2
- package/plugins/compute/cloud/resources/tools.js +3 -3
- package/plugins/compute/computers/collections/approval.d.ts +2 -2
- package/plugins/compute/computers/collections/grant.d.ts +1 -1
- package/plugins/compute/computers/collections/preview.d.ts +2 -2
- package/plugins/compute/computers/program/version.d.ts +1 -1
- package/plugins/compute/computers/program/version.js +1 -1
- package/plugins/compute/computers/resources/downloads.js +1 -1
- package/plugins/compute/computers/shared/wake.d.ts +1 -1
- package/plugins/compute/computers/shared/wake.js +17 -0
- package/plugins/interfaces/api/collections/key.d.ts +1 -1
- package/plugins/interfaces/api/shared/events.js +5 -4
- package/plugins/interfaces/maintenance/actions/read.d.ts +4 -0
- package/plugins/interfaces/maintenance/actions/read.js +76 -0
- package/plugins/interfaces/maintenance/actions/write.d.ts +4 -0
- package/plugins/interfaces/maintenance/actions/write.js +64 -0
- package/plugins/interfaces/maintenance/contract.d.ts +60 -0
- package/plugins/interfaces/maintenance/contract.js +2 -0
- package/plugins/interfaces/maintenance/mod.d.ts +52 -0
- package/plugins/interfaces/maintenance/mod.js +66 -0
- package/plugins/interfaces/maintenance/resources/routes.d.ts +71 -0
- package/plugins/interfaces/maintenance/resources/routes.js +457 -0
- package/plugins/interfaces/maintenance/shared/ops.d.ts +4 -0
- package/plugins/interfaces/maintenance/shared/ops.js +19 -0
- package/plugins/interfaces/mcp/actions/call.d.ts +11 -0
- package/plugins/interfaces/mcp/actions/call.js +304 -0
- package/plugins/interfaces/mcp/actions/prune.d.ts +1 -0
- package/plugins/interfaces/mcp/actions/prune.js +18 -0
- package/plugins/interfaces/mcp/collections/closed.d.ts +23 -0
- package/plugins/interfaces/mcp/collections/closed.js +17 -0
- package/plugins/interfaces/mcp/collections/rate.d.ts +27 -0
- package/plugins/interfaces/mcp/collections/rate.js +18 -0
- package/plugins/interfaces/mcp/collections/receipt.d.ts +46 -0
- package/plugins/interfaces/mcp/collections/receipt.js +46 -0
- package/plugins/interfaces/mcp/contract.d.ts +9 -0
- package/plugins/interfaces/mcp/contract.js +9 -0
- package/plugins/interfaces/mcp/mod.d.ts +84 -0
- package/plugins/interfaces/mcp/mod.js +122 -0
- package/plugins/interfaces/mcp/processors/closed.d.ts +13 -0
- package/plugins/interfaces/mcp/processors/closed.js +16 -0
- package/plugins/interfaces/mcp/resources/running.d.ts +21 -0
- package/plugins/interfaces/mcp/resources/running.js +36 -0
- package/plugins/interfaces/mcp/resources/server.d.ts +54 -0
- package/plugins/interfaces/mcp/resources/server.js +423 -0
- package/plugins/interfaces/mcp/resources/tools.d.ts +114 -0
- package/plugins/interfaces/mcp/resources/tools.js +324 -0
- package/plugins/interfaces/mcp/shared/caller.d.ts +45 -0
- package/plugins/interfaces/mcp/shared/caller.js +99 -0
- package/plugins/interfaces/mcp/shared/keys.d.ts +50 -0
- package/plugins/interfaces/mcp/shared/keys.js +53 -0
- package/plugins/interfaces/mcp/shared/settings.d.ts +187 -0
- package/plugins/interfaces/mcp/shared/settings.js +176 -0
- package/plugins/interfaces/mcp/views/offered.d.ts +20 -0
- package/plugins/interfaces/mcp/views/offered.js +20 -0
- package/plugins/interfaces/mod.d.ts +5 -1
- package/plugins/interfaces/mod.js +5 -1
- package/plugins/interfaces/terminal/actions/print.js +1 -1
- package/plugins/interfaces/terminal/actions/set.js +1 -1
- package/plugins/interfaces/terminal/collections/output.d.ts +1 -1
- package/plugins/interfaces/terminal/collections/shell.js +1 -1
- package/plugins/interfaces/voice/actions/block.d.ts +2 -0
- package/plugins/interfaces/voice/actions/block.js +74 -0
- package/plugins/interfaces/voice/actions/call.d.ts +19 -0
- package/plugins/interfaces/voice/actions/call.js +253 -0
- package/plugins/interfaces/voice/actions/hook.d.ts +5 -0
- package/plugins/interfaces/voice/actions/hook.js +225 -0
- package/plugins/interfaces/voice/actions/prune.d.ts +1 -0
- package/plugins/interfaces/voice/actions/prune.js +35 -0
- package/plugins/interfaces/voice/collections/blocked.d.ts +87 -0
- package/plugins/interfaces/voice/collections/blocked.js +34 -0
- package/plugins/interfaces/voice/collections/call.d.ts +279 -0
- package/plugins/interfaces/voice/collections/call.js +77 -0
- package/plugins/interfaces/voice/collections/phone.d.ts +74 -0
- package/plugins/interfaces/voice/collections/phone.js +26 -0
- package/plugins/interfaces/voice/contract.d.ts +14 -0
- package/plugins/interfaces/voice/contract.js +2 -0
- package/plugins/interfaces/voice/mod.d.ts +57 -0
- package/plugins/interfaces/voice/mod.js +118 -0
- package/plugins/interfaces/voice/processors/forget.d.ts +13 -0
- package/plugins/interfaces/voice/processors/forget.js +27 -0
- package/plugins/interfaces/voice/resources/relay.d.ts +77 -0
- package/plugins/interfaces/voice/resources/relay.js +428 -0
- package/plugins/interfaces/voice/resources/tools.d.ts +1 -0
- package/plugins/interfaces/voice/resources/tools.js +25 -0
- package/plugins/interfaces/voice/shared/caller.d.ts +27 -0
- package/plugins/interfaces/voice/shared/caller.js +38 -0
- package/plugins/interfaces/voice/shared/settings.d.ts +136 -0
- package/plugins/interfaces/voice/shared/settings.js +121 -0
- package/plugins/interfaces/voice/shared/signature.d.ts +11 -0
- package/plugins/interfaces/voice/shared/signature.js +34 -0
- package/plugins/interfaces/voice/views/call.d.ts +41 -0
- package/plugins/interfaces/voice/views/call.js +30 -0
- package/plugins/interfaces/voice/views/context.d.ts +9 -0
- package/plugins/interfaces/voice/views/context.js +14 -0
- package/plugins/interfaces/voice/views/message.d.ts +17 -0
- package/plugins/interfaces/voice/views/message.js +41 -0
- package/plugins/interfaces/whatsapp/actions/connect.js +3 -0
- package/plugins/interfaces/whatsapp/actions/disconnect.js +4 -1
- package/plugins/interfaces/whatsapp/actions/hook.js +27 -11
- package/plugins/interfaces/whatsapp/actions/set.d.ts +8 -0
- package/plugins/interfaces/whatsapp/actions/set.js +121 -0
- package/plugins/interfaces/whatsapp/collections/blocked.d.ts +29 -0
- package/plugins/interfaces/whatsapp/collections/blocked.js +22 -0
- package/plugins/interfaces/whatsapp/collections/code.d.ts +1 -1
- package/plugins/interfaces/whatsapp/collections/number.d.ts +90 -4
- package/plugins/interfaces/whatsapp/collections/number.js +36 -4
- package/plugins/interfaces/whatsapp/collections/phone.d.ts +13 -3
- package/plugins/interfaces/whatsapp/collections/phone.js +9 -3
- package/plugins/interfaces/whatsapp/collections/rate.d.ts +27 -0
- package/plugins/interfaces/whatsapp/collections/rate.js +13 -0
- package/plugins/interfaces/whatsapp/collections/sent.d.ts +24 -12
- package/plugins/interfaces/whatsapp/collections/sent.js +11 -7
- package/plugins/interfaces/whatsapp/collections/thread.d.ts +14 -6
- package/plugins/interfaces/whatsapp/collections/thread.js +7 -5
- package/plugins/interfaces/whatsapp/collections/typing.d.ts +70 -0
- package/plugins/interfaces/whatsapp/collections/typing.js +21 -0
- package/plugins/interfaces/whatsapp/contract.d.ts +27 -4
- package/plugins/interfaces/whatsapp/contract.js +34 -1
- package/plugins/interfaces/whatsapp/events/undelivered.d.ts +8 -0
- package/plugins/interfaces/whatsapp/events/undelivered.js +17 -0
- package/plugins/interfaces/whatsapp/mod.d.ts +28 -2
- package/plugins/interfaces/whatsapp/mod.js +65 -6
- package/plugins/interfaces/whatsapp/processors/forget.d.ts +6 -0
- package/plugins/interfaces/whatsapp/processors/forget.js +11 -0
- package/plugins/interfaces/whatsapp/processors/receive.d.ts +17 -3
- package/plugins/interfaces/whatsapp/processors/receive.js +264 -81
- package/plugins/interfaces/whatsapp/processors/reply.d.ts +25 -5
- package/plugins/interfaces/whatsapp/processors/reply.js +216 -20
- package/plugins/interfaces/whatsapp/processors/typing.d.ts +8 -0
- package/plugins/interfaces/whatsapp/processors/typing.js +25 -0
- package/plugins/interfaces/whatsapp/shared/customers.d.ts +13 -0
- package/plugins/interfaces/whatsapp/shared/customers.js +16 -0
- package/plugins/interfaces/whatsapp/shared/graph.d.ts +31 -6
- package/plugins/interfaces/whatsapp/shared/graph.js +117 -10
- package/plugins/interfaces/whatsapp/shared/media.d.ts +23 -0
- package/plugins/interfaces/whatsapp/shared/media.js +46 -0
- package/plugins/interfaces/whatsapp/shared/number.d.ts +19 -8
- package/plugins/interfaces/whatsapp/shared/number.js +64 -7
- package/plugins/interfaces/whatsapp/shared/parts.d.ts +94 -0
- package/plugins/interfaces/whatsapp/shared/parts.js +184 -0
- package/plugins/interfaces/whatsapp/shared/payload.d.ts +27 -1
- package/plugins/interfaces/whatsapp/shared/payload.js +36 -1
- package/plugins/interfaces/whatsapp/shared/settings.d.ts +49 -1
- package/plugins/interfaces/whatsapp/shared/settings.js +11 -0
- package/plugins/interfaces/whatsapp/views/message.d.ts +13 -0
- package/plugins/interfaces/whatsapp/views/message.js +13 -0
- package/plugins/interfaces/whatsapp/views/web/line.d.ts +24 -0
- package/plugins/interfaces/whatsapp/views/web/line.js +44 -0
- package/plugins/interfaces/whatsapp/views/web/space.d.ts +7 -5
- package/plugins/interfaces/whatsapp/views/web/space.js +17 -10
- package/plugins/interfaces/whatsapp/views/web/style.d.ts +1 -1
- package/plugins/interfaces/whatsapp/views/web/style.js +8 -0
- package/plugins/models/adapters/llm/anthropic.d.ts +1 -1
- package/plugins/models/adapters/llm/anthropic.js +28 -15
- package/plugins/models/adapters/llm/gemini.d.ts +1 -1
- package/plugins/models/adapters/llm/gemini.js +2 -1
- package/plugins/models/adapters/llm/openai-compatible.d.ts +1 -1
- package/plugins/models/adapters/llm/openai-compatible.js +2 -1
- package/plugins/models/adapters/llm/openai.d.ts +1 -1
- package/plugins/models/adapters/llm/openai.js +16 -4
- package/plugins/models/shared/types.d.ts +8 -0
- package/plugins/models/shared/types.js +10 -0
- package/runtime/actor.d.ts +6 -0
- package/runtime/actor.js +9 -4
- package/runtime/aggregate.js +8 -2
- package/runtime/blobs.d.ts +15 -12
- package/runtime/blobs.js +58 -11
- package/runtime/cache.d.ts +6 -0
- package/runtime/cache.js +19 -1
- package/runtime/define.d.ts +10 -0
- package/runtime/errors.d.ts +20 -2
- package/runtime/errors.js +7 -1
- package/runtime/executor.js +27 -11
- package/runtime/links.d.ts +31 -0
- package/runtime/links.js +60 -0
- package/runtime/maintain.d.ts +88 -0
- package/runtime/maintain.js +120 -0
- package/runtime/memory.js +7 -4
- package/runtime/mod.d.ts +6 -4
- package/runtime/mod.js +5 -2
- package/runtime/mongo.d.ts +13 -0
- package/runtime/mongo.js +39 -8
- package/runtime/observe.d.ts +2 -0
- package/runtime/observe.js +14 -10
- package/runtime/ops.d.ts +5 -0
- package/runtime/ops.js +10 -1
- package/runtime/owner.d.ts +18 -1
- package/runtime/owner.js +127 -61
- package/runtime/presence.d.ts +18 -0
- package/runtime/presence.js +25 -0
- package/runtime/registry.d.ts +5 -0
- package/runtime/registry.js +18 -0
- package/runtime/runtime.js +9 -3
- package/runtime/store.d.ts +48 -1
- package/runtime/wire.d.ts +1 -0
- package/runtime/wire.js +3 -1
- package/stores/blobs/files/mod.js +4 -2
- package/stores/blobs/gcs/mod.d.ts +3 -0
- package/stores/blobs/gcs/mod.js +6 -5
- package/stores/blobs/http/mod.d.ts +1 -1
- package/stores/blobs/http/mod.js +2 -1
- package/stores/latency/mod.js +5 -1
- package/stores/sql/postgres/maintenance.d.ts +24 -0
- package/stores/sql/postgres/maintenance.js +258 -0
- package/stores/sql/postgres/mod.d.ts +20 -4
- package/stores/sql/postgres/mod.js +363 -96
- package/stores/sql/postgres/update.js +3 -1
- package/stores/sql/shared/capped.d.ts +2 -0
- package/stores/sql/shared/capped.js +22 -0
- package/stores/sql/shared/rows.d.ts +14 -0
- package/stores/sql/shared/rows.js +29 -0
- package/stores/sql/shared/statement.d.ts +12 -0
- package/stores/sql/shared/statement.js +244 -0
- package/stores/sql/sqlite/apart.d.ts +11 -0
- package/stores/sql/sqlite/apart.js +219 -0
- package/stores/sql/sqlite/mod.d.ts +16 -2
- package/stores/sql/sqlite/mod.js +246 -51
- package/testing/mod.js +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Conversations that happen on WhatsApp, by thread id: the number and phone
|
|
3
|
-
* they're with, and whose phone it is
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* they're with, and whose phone it is: a person's, or a contact's (a
|
|
4
|
+
* customer on an open number). What agents say there to them goes out to
|
|
5
|
+
* the phone, even after they've moved on to a new conversation. Each person
|
|
6
|
+
* reads their own.
|
|
6
7
|
*/
|
|
7
8
|
import { defineCollection } from "../../../../runtime/mod.js";
|
|
8
9
|
const threadSchema = {
|
|
@@ -12,8 +13,9 @@ const threadSchema = {
|
|
|
12
13
|
/** The phone's WhatsApp id. */
|
|
13
14
|
phone: { type: "string" },
|
|
14
15
|
person: { type: "string" },
|
|
16
|
+
contact: { type: "string" },
|
|
15
17
|
at: { type: "string" },
|
|
16
18
|
},
|
|
17
|
-
required: ["number", "phone", "
|
|
19
|
+
required: ["number", "phone", "at"],
|
|
18
20
|
};
|
|
19
|
-
export const chat = defineCollection({ schema: threadSchema });
|
|
21
|
+
export const chat = defineCollection({ schema: threadSchema, indexes: [["contact"]] });
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chats an agent is answering on WhatsApp, by thread: the message it's
|
|
3
|
+
* answering (WhatsApp's id) and when "typing…" was last shown for it, so it
|
|
4
|
+
* shows again while the agent works on (WhatsApp hides it after 25 seconds).
|
|
5
|
+
* Kept in memory: gone on restart, when it matters least.
|
|
6
|
+
*/
|
|
7
|
+
import { type Infer } from "../../../../runtime/mod.js";
|
|
8
|
+
declare const typingSchema: {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly number: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
};
|
|
14
|
+
/** The message being answered. */
|
|
15
|
+
readonly wamid: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
};
|
|
18
|
+
/** When it came. */
|
|
19
|
+
readonly at: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
};
|
|
22
|
+
/** When "typing…" was last shown. */
|
|
23
|
+
readonly shown: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly required: readonly ["number", "wamid", "at", "shown"];
|
|
28
|
+
};
|
|
29
|
+
export declare const typing: {
|
|
30
|
+
schema: {
|
|
31
|
+
readonly type: "object";
|
|
32
|
+
readonly properties: {
|
|
33
|
+
readonly number: {
|
|
34
|
+
readonly type: "string";
|
|
35
|
+
};
|
|
36
|
+
/** The message being answered. */
|
|
37
|
+
readonly wamid: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
};
|
|
40
|
+
/** When it came. */
|
|
41
|
+
readonly at: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
};
|
|
44
|
+
/** When "typing…" was last shown. */
|
|
45
|
+
readonly shown: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly required: readonly ["number", "wamid", "at", "shown"];
|
|
50
|
+
};
|
|
51
|
+
events?: boolean;
|
|
52
|
+
records?: boolean;
|
|
53
|
+
durable?: false;
|
|
54
|
+
indexes?: string[][];
|
|
55
|
+
private?: string[];
|
|
56
|
+
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
number: string;
|
|
59
|
+
at: string;
|
|
60
|
+
shown: string;
|
|
61
|
+
wamid: string;
|
|
62
|
+
} & {
|
|
63
|
+
_id: string;
|
|
64
|
+
}>> | undefined;
|
|
65
|
+
vectors?: string[];
|
|
66
|
+
};
|
|
67
|
+
export type WhatsAppTyping = Infer<typeof typingSchema> & {
|
|
68
|
+
_id: string;
|
|
69
|
+
};
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chats an agent is answering on WhatsApp, by thread: the message it's
|
|
3
|
+
* answering (WhatsApp's id) and when "typing…" was last shown for it, so it
|
|
4
|
+
* shows again while the agent works on (WhatsApp hides it after 25 seconds).
|
|
5
|
+
* Kept in memory: gone on restart, when it matters least.
|
|
6
|
+
*/
|
|
7
|
+
import { defineCollection } from "../../../../runtime/mod.js";
|
|
8
|
+
const typingSchema = {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
number: { type: "string" },
|
|
12
|
+
/** The message being answered. */
|
|
13
|
+
wamid: { type: "string" },
|
|
14
|
+
/** When it came. */
|
|
15
|
+
at: { type: "string" },
|
|
16
|
+
/** When "typing…" was last shown. */
|
|
17
|
+
shown: { type: "string" },
|
|
18
|
+
},
|
|
19
|
+
required: ["number", "wamid", "at", "shown"],
|
|
20
|
+
};
|
|
21
|
+
export const typing = defineCollection({ durable: false, schema: typingSchema });
|
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The WhatsApp plugin's contract: what other plugins and apps may import:
|
|
3
3
|
* the shapes of a connected number, a linked phone and a WhatsApp
|
|
4
|
-
* conversation, and of the plugin's settings (the `whatsapp` resource)
|
|
4
|
+
* conversation, and of the plugin's settings (the `whatsapp` resource); and
|
|
5
|
+
* the medium's toolkit, for `whatsapp` Views: the parts a View returns,
|
|
6
|
+
* each one WhatsApp message, built and checked against Meta's limits
|
|
7
|
+
* (`text`, `buttons`, `list`, `carousel`, `image`, `document`; `clip` cuts a
|
|
8
|
+
* title on purpose).
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* views: {
|
|
12
|
+
* "addition:booking": {
|
|
13
|
+
* whatsapp: ({ thread }, ctx) => ({
|
|
14
|
+
* key: `trips:${search}`,
|
|
15
|
+
* parts: [carousel("Some trips for 12/11", cards)],
|
|
16
|
+
* fallback: [text(numbered)],
|
|
17
|
+
* note: "6 trips as a carousel",
|
|
18
|
+
* }),
|
|
19
|
+
* },
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* A tap comes back as the message's `tap` (`{ id, title, key }`): what was
|
|
24
|
+
* chosen, never what may be done. Agents read its id as it came, so a tool
|
|
25
|
+
* acting on one (choosing a trip) checks it against what was shown there.
|
|
26
|
+
*
|
|
5
27
|
* They reach the rest by name: its collections (`whatsapp_number`,
|
|
6
28
|
* `whatsapp_phone`, `whatsapp_thread`), its event (`whatsapp.received`) and
|
|
7
29
|
* its Actions (`whatsapp.connect`, `whatsapp.credentials`,
|
|
8
30
|
* `whatsapp.disconnect`, `whatsapp.webhook`, `whatsapp.link`,
|
|
9
|
-
* `whatsapp.unlink`, `whatsapp.move`).
|
|
31
|
+
* `whatsapp.unlink`, `whatsapp.move`, `whatsapp.set`, `whatsapp.block`).
|
|
10
32
|
*/
|
|
11
|
-
export type
|
|
33
|
+
export { GAP, type WhatsAppNumber } from "./collections/number.js";
|
|
12
34
|
export type { WhatsAppPhone } from "./collections/phone.js";
|
|
13
35
|
export type { WhatsAppCode } from "./collections/code.js";
|
|
14
36
|
export type { WhatsAppThread } from "./collections/thread.js";
|
|
15
|
-
export type { WhatsAppSettings } from "./shared/settings.js";
|
|
37
|
+
export type { WhatsAppLine, WhatsAppSettings } from "./shared/settings.js";
|
|
38
|
+
export { buttons, type Card, carousel, type Choice, clip, document, image, list, type Row, type Section, text, type WaMedia, type WaPart, } from "./shared/parts.js";
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The WhatsApp plugin's contract: what other plugins and apps may import:
|
|
3
|
+
* the shapes of a connected number, a linked phone and a WhatsApp
|
|
4
|
+
* conversation, and of the plugin's settings (the `whatsapp` resource); and
|
|
5
|
+
* the medium's toolkit, for `whatsapp` Views: the parts a View returns,
|
|
6
|
+
* each one WhatsApp message, built and checked against Meta's limits
|
|
7
|
+
* (`text`, `buttons`, `list`, `carousel`, `image`, `document`; `clip` cuts a
|
|
8
|
+
* title on purpose).
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* views: {
|
|
12
|
+
* "addition:booking": {
|
|
13
|
+
* whatsapp: ({ thread }, ctx) => ({
|
|
14
|
+
* key: `trips:${search}`,
|
|
15
|
+
* parts: [carousel("Some trips for 12/11", cards)],
|
|
16
|
+
* fallback: [text(numbered)],
|
|
17
|
+
* note: "6 trips as a carousel",
|
|
18
|
+
* }),
|
|
19
|
+
* },
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* A tap comes back as the message's `tap` (`{ id, title, key }`): what was
|
|
24
|
+
* chosen, never what may be done. Agents read its id as it came, so a tool
|
|
25
|
+
* acting on one (choosing a trip) checks it against what was shown there.
|
|
26
|
+
*
|
|
27
|
+
* They reach the rest by name: its collections (`whatsapp_number`,
|
|
28
|
+
* `whatsapp_phone`, `whatsapp_thread`), its event (`whatsapp.received`) and
|
|
29
|
+
* its Actions (`whatsapp.connect`, `whatsapp.credentials`,
|
|
30
|
+
* `whatsapp.disconnect`, `whatsapp.webhook`, `whatsapp.link`,
|
|
31
|
+
* `whatsapp.unlink`, `whatsapp.move`, `whatsapp.set`, `whatsapp.block`).
|
|
32
|
+
*/
|
|
33
|
+
export { GAP } from "./collections/number.js";
|
|
34
|
+
export { buttons, carousel, clip, document, image, list, text, } from "./shared/parts.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `whatsapp.undelivered`: Meta took a message the number sent and then
|
|
3
|
+
* couldn't deliver it (a failed status on its webhook: a picture it couldn't
|
|
4
|
+
* fetch, say). Its id is WhatsApp's message id, so a status Meta sends again
|
|
5
|
+
* records nothing new.
|
|
6
|
+
*/
|
|
7
|
+
import type { EventDef } from "../../../../runtime/mod.js";
|
|
8
|
+
export declare const undelivered: EventDef;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const undelivered = {
|
|
2
|
+
description: "A message a connected WhatsApp number sent wasn't delivered",
|
|
3
|
+
schema: {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
/** The connected number (its id here). */
|
|
7
|
+
number: { type: "string" },
|
|
8
|
+
/** WhatsApp's id for what was sent. */
|
|
9
|
+
wamid: { type: "string" },
|
|
10
|
+
/** Whom it was to (their WhatsApp id). */
|
|
11
|
+
to: { type: "string" },
|
|
12
|
+
/** What Meta said went wrong. */
|
|
13
|
+
errors: { type: "array" },
|
|
14
|
+
},
|
|
15
|
+
required: ["number", "wamid", "to"],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -8,14 +8,40 @@
|
|
|
8
8
|
* webhook of its own to set up in Meta's dashboard (`whatsapp.webhook`).
|
|
9
9
|
* - **A phone** is linked to a person in that space: they ask the app for
|
|
10
10
|
* a code (`whatsapp.link`) and send it to the number from WhatsApp.
|
|
11
|
-
* Anyone else who writes is told how, once a day, and nothing more
|
|
11
|
+
* Anyone else who writes is told how, once a day, and nothing more,
|
|
12
|
+
* unless the number is open to anyone.
|
|
13
|
+
* - **A customer line:** those who manage the space open the number to
|
|
14
|
+
* anyone (`whatsapp.set`), or the app declares one in its settings
|
|
15
|
+
* (`resources.whatsapp.lines`: the space, Meta's ids, token and secret,
|
|
16
|
+
* its verify token, its webhook's path, its agent and gap), kept as they
|
|
17
|
+
* say with no person, and changed only there. A stranger who writes is then a contact
|
|
18
|
+
* (someone outside the org), in a chat of their own in the number's
|
|
19
|
+
* space, answered by its agent: they reach that chat and nothing else; the
|
|
20
|
+
* space's members read it. A chat quiet for the number's `gap` (12 hours)
|
|
21
|
+
* is over, and their next message starts a new one. Its managers block a
|
|
22
|
+
* customer's phone (`whatsapp.block`); a customer sending more than the
|
|
23
|
+
* number's `rate` a minute (20) goes unanswered. Erasing a contact
|
|
24
|
+
* (`contact.forget`) erases its phone here too.
|
|
12
25
|
* - **What they send** becomes `chat.send`, as them, in their WhatsApp
|
|
13
26
|
* conversation, in the space they choose (their Personal space unless
|
|
14
27
|
* they say: `whatsapp.move`, or `/space <name>` from the phone); photos,
|
|
15
28
|
* documents and voice notes too (chat transcribes audio). `/new` starts a
|
|
16
29
|
* new conversation. Meta delivering a message again changes nothing.
|
|
17
30
|
* - **What agents say there** to them goes back to the phone, as WhatsApp
|
|
18
|
-
* formats it, a long answer in several messages
|
|
31
|
+
* formats it, a long answer in several messages; "typing…" shows while
|
|
32
|
+
* they work, and nothing says "please wait".
|
|
33
|
+
* - **WhatsApp is a medium:** a View for it (renderer `whatsapp`) returns
|
|
34
|
+
* parts, each one WhatsApp message, built with the toolkit in the contract
|
|
35
|
+
* (`text`, `buttons`, `list`, `carousel`, `image`, `document`), which
|
|
36
|
+
* checks Meta's limits. A message shows through its `message` View (this
|
|
37
|
+
* plugin's: its text). After an answer come the features' additions
|
|
38
|
+
* (chat's `additions` resource, an `addition:<name>` View here): each goes
|
|
39
|
+
* once per chat per key, the answer's text in the first one's body when
|
|
40
|
+
* there's room (one message, not two: Meta charges each), and its fallback
|
|
41
|
+
* when Meta refuses it, or later says it couldn't deliver it (a picture
|
|
42
|
+
* it failed to fetch). A tap comes back as its title, with its id.
|
|
43
|
+
* Pictures and files go as links (public ones; signed ones to the app's
|
|
44
|
+
* routes and files, with its `links` resource), or uploaded to Meta.
|
|
19
45
|
* - **The webhook** (`/hooks/whatsapp/<number>`, the web host's `routes`
|
|
20
46
|
* resource) checks Meta's signature before anything else. Credentials are
|
|
21
47
|
* kept where no event and no reader outside reaches them.
|
|
@@ -8,14 +8,40 @@
|
|
|
8
8
|
* webhook of its own to set up in Meta's dashboard (`whatsapp.webhook`).
|
|
9
9
|
* - **A phone** is linked to a person in that space: they ask the app for
|
|
10
10
|
* a code (`whatsapp.link`) and send it to the number from WhatsApp.
|
|
11
|
-
* Anyone else who writes is told how, once a day, and nothing more
|
|
11
|
+
* Anyone else who writes is told how, once a day, and nothing more,
|
|
12
|
+
* unless the number is open to anyone.
|
|
13
|
+
* - **A customer line:** those who manage the space open the number to
|
|
14
|
+
* anyone (`whatsapp.set`), or the app declares one in its settings
|
|
15
|
+
* (`resources.whatsapp.lines`: the space, Meta's ids, token and secret,
|
|
16
|
+
* its verify token, its webhook's path, its agent and gap), kept as they
|
|
17
|
+
* say with no person, and changed only there. A stranger who writes is then a contact
|
|
18
|
+
* (someone outside the org), in a chat of their own in the number's
|
|
19
|
+
* space, answered by its agent: they reach that chat and nothing else; the
|
|
20
|
+
* space's members read it. A chat quiet for the number's `gap` (12 hours)
|
|
21
|
+
* is over, and their next message starts a new one. Its managers block a
|
|
22
|
+
* customer's phone (`whatsapp.block`); a customer sending more than the
|
|
23
|
+
* number's `rate` a minute (20) goes unanswered. Erasing a contact
|
|
24
|
+
* (`contact.forget`) erases its phone here too.
|
|
12
25
|
* - **What they send** becomes `chat.send`, as them, in their WhatsApp
|
|
13
26
|
* conversation, in the space they choose (their Personal space unless
|
|
14
27
|
* they say: `whatsapp.move`, or `/space <name>` from the phone); photos,
|
|
15
28
|
* documents and voice notes too (chat transcribes audio). `/new` starts a
|
|
16
29
|
* new conversation. Meta delivering a message again changes nothing.
|
|
17
30
|
* - **What agents say there** to them goes back to the phone, as WhatsApp
|
|
18
|
-
* formats it, a long answer in several messages
|
|
31
|
+
* formats it, a long answer in several messages; "typing…" shows while
|
|
32
|
+
* they work, and nothing says "please wait".
|
|
33
|
+
* - **WhatsApp is a medium:** a View for it (renderer `whatsapp`) returns
|
|
34
|
+
* parts, each one WhatsApp message, built with the toolkit in the contract
|
|
35
|
+
* (`text`, `buttons`, `list`, `carousel`, `image`, `document`), which
|
|
36
|
+
* checks Meta's limits. A message shows through its `message` View (this
|
|
37
|
+
* plugin's: its text). After an answer come the features' additions
|
|
38
|
+
* (chat's `additions` resource, an `addition:<name>` View here): each goes
|
|
39
|
+
* once per chat per key, the answer's text in the first one's body when
|
|
40
|
+
* there's room (one message, not two: Meta charges each), and its fallback
|
|
41
|
+
* when Meta refuses it, or later says it couldn't deliver it (a picture
|
|
42
|
+
* it failed to fetch). A tap comes back as its title, with its id.
|
|
43
|
+
* Pictures and files go as links (public ones; signed ones to the app's
|
|
44
|
+
* routes and files, with its `links` resource), or uploaded to Meta.
|
|
19
45
|
* - **The webhook** (`/hooks/whatsapp/<number>`, the web host's `routes`
|
|
20
46
|
* resource) checks Meta's signature before anything else. Credentials are
|
|
21
47
|
* kept where no event and no reader outside reaches them.
|
|
@@ -25,25 +51,34 @@
|
|
|
25
51
|
* resources: { whatsapp: { graph: "https://graph.facebook.com/v23.0" } } // the default
|
|
26
52
|
* ```
|
|
27
53
|
*/
|
|
28
|
-
import { definePlugin } from "../../../runtime/mod.js";
|
|
54
|
+
import { definePlugin, linksOf } from "../../../runtime/mod.js";
|
|
29
55
|
import { connectAction, credentialsAction } from "./actions/connect.js";
|
|
30
56
|
import { disconnectAction, webhookAction } from "./actions/disconnect.js";
|
|
31
57
|
import { hookAction, HOOKS } from "./actions/hook.js";
|
|
32
58
|
import { linkAction, moveAction, unlinkAction } from "./actions/link.js";
|
|
59
|
+
import { blockAction, setAction } from "./actions/set.js";
|
|
33
60
|
import { code } from "./collections/code.js";
|
|
34
61
|
import { number } from "./collections/number.js";
|
|
35
62
|
import { phone } from "./collections/phone.js";
|
|
63
|
+
import { rate } from "./collections/rate.js";
|
|
64
|
+
import { blocked } from "./collections/blocked.js";
|
|
36
65
|
import { secret } from "./collections/secret.js";
|
|
37
66
|
import { sent } from "./collections/sent.js";
|
|
38
67
|
import { chat } from "./collections/thread.js";
|
|
68
|
+
import { typing } from "./collections/typing.js";
|
|
39
69
|
import { received } from "./events/received.js";
|
|
70
|
+
import { undelivered } from "./events/undelivered.js";
|
|
71
|
+
import { forgetProcessor } from "./processors/forget.js";
|
|
40
72
|
import { receiveProcessor } from "./processors/receive.js";
|
|
41
|
-
import { replyProcessor } from "./processors/reply.js";
|
|
73
|
+
import { replyProcessor, undeliveredProcessor } from "./processors/reply.js";
|
|
74
|
+
import { typingProcessor } from "./processors/typing.js";
|
|
75
|
+
import { messageView } from "./views/message.js";
|
|
42
76
|
import { rules } from "./shared/rules.js";
|
|
77
|
+
import { linesOf } from "./shared/settings.js";
|
|
43
78
|
export * from "./contract.js";
|
|
44
79
|
export const whatsapp = definePlugin({
|
|
45
80
|
name: "whatsapp",
|
|
46
|
-
requires: ["chat", "spaces"],
|
|
81
|
+
requires: ["chat", "spaces", "contacts"],
|
|
47
82
|
collections: {
|
|
48
83
|
whatsapp_number: number,
|
|
49
84
|
whatsapp_secret: secret,
|
|
@@ -51,8 +86,11 @@ export const whatsapp = definePlugin({
|
|
|
51
86
|
whatsapp_code: code,
|
|
52
87
|
whatsapp_thread: chat,
|
|
53
88
|
whatsapp_sent: sent,
|
|
89
|
+
whatsapp_typing: typing,
|
|
90
|
+
whatsapp_rate: rate,
|
|
91
|
+
whatsapp_blocked: blocked,
|
|
54
92
|
},
|
|
55
|
-
events: { "whatsapp.received": received },
|
|
93
|
+
events: { "whatsapp.received": received, "whatsapp.undelivered": undelivered },
|
|
56
94
|
actions: {
|
|
57
95
|
"whatsapp.connect": connectAction,
|
|
58
96
|
"whatsapp.credentials": credentialsAction,
|
|
@@ -62,12 +100,33 @@ export const whatsapp = definePlugin({
|
|
|
62
100
|
"whatsapp.link": linkAction,
|
|
63
101
|
"whatsapp.unlink": unlinkAction,
|
|
64
102
|
"whatsapp.move": moveAction,
|
|
103
|
+
"whatsapp.set": setAction,
|
|
104
|
+
"whatsapp.block": blockAction,
|
|
65
105
|
},
|
|
66
106
|
processors: {
|
|
67
107
|
"whatsapp.receive": receiveProcessor,
|
|
68
108
|
"whatsapp.reply": replyProcessor,
|
|
109
|
+
"whatsapp.undelivered": undeliveredProcessor,
|
|
110
|
+
"whatsapp.typing": typingProcessor,
|
|
111
|
+
"whatsapp.forget": forgetProcessor,
|
|
69
112
|
},
|
|
113
|
+
// WhatsApp as a medium: what a message is there (a feature's additions bring their own).
|
|
114
|
+
views: { message: { whatsapp: messageView } },
|
|
70
115
|
guard: rules,
|
|
116
|
+
// At start: links to what it sends (a secret too short is refused), and the app's own lines.
|
|
117
|
+
check: (merged) => {
|
|
118
|
+
linksOf(merged.resources);
|
|
119
|
+
for (const [name, line] of Object.entries(linesOf(merged))) {
|
|
120
|
+
for (const field of ["in", "phoneId", "token", "secret", "verify"]) {
|
|
121
|
+
if (typeof line?.[field] !== "string" || !line[field]) {
|
|
122
|
+
throw new Error(`whatsapp.lines.${name} needs its ${field}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (line.path !== undefined && !line.path.startsWith("/")) {
|
|
126
|
+
throw new Error(`whatsapp.lines.${name}: its path starts with "/"`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
71
130
|
resources: {
|
|
72
131
|
whatsapp: {},
|
|
73
132
|
routes: { whatsapp: { path: HOOKS, action: "whatsapp.hook", methods: ["GET", "POST"] } },
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A contact erased (`contact.deleted`): its phone is erased here too, and the
|
|
3
|
+
* record of which WhatsApp chats were its: nothing of it stays.
|
|
4
|
+
*/
|
|
5
|
+
import type { ProcessorDef } from "../../../../runtime/mod.js";
|
|
6
|
+
export declare const forgetProcessor: ProcessorDef;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const forgetProcessor = {
|
|
2
|
+
on: "contact.deleted",
|
|
3
|
+
key: (event) => String(event.data._id),
|
|
4
|
+
run: async (ctx, event) => {
|
|
5
|
+
const contact = String(event.data._id);
|
|
6
|
+
await ctx.as().transaction(async (tx) => {
|
|
7
|
+
await tx.db.collection("whatsapp_phone").deleteMany({ contact });
|
|
8
|
+
await tx.db.collection("whatsapp_thread").deleteMany({ contact });
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
* once a day, and nothing else. A six-digit code they send is tried:
|
|
7
7
|
* one the app gave a person, unexpired, links the phone to them (five
|
|
8
8
|
* wrong ones in an hour, and it stops listening to codes for a while).
|
|
9
|
+
* - **A customer**, on an open number (a customer line), is a stranger too,
|
|
10
|
+
* who is answered: a contact (made from their first message), writing in
|
|
11
|
+
* a chat of their own in the number's space, to its agent. A chat quiet
|
|
12
|
+
* for the number's `gap` (12 hours) is over: their next message starts a
|
|
13
|
+
* new one. What they write always goes to the agent (commands are linked
|
|
14
|
+
* people's), except a code that links their phone. More than the number's
|
|
15
|
+
* `rate` a minute (20) goes unanswered; a phone its people blocked, or took
|
|
16
|
+
* out of its chat (until the gap passes), is let go without a word; what
|
|
17
|
+
* they're told is in the number's `language`.
|
|
9
18
|
* - **Someone linked**, still in the number's space: their message is
|
|
10
19
|
* marked read (with "typing…") and becomes `chat.send`, as them, in
|
|
11
20
|
* their WhatsApp conversation, in the space they chose (their Personal
|
|
@@ -14,11 +23,16 @@
|
|
|
14
23
|
* quoting an agent's message, or one sent while an agent waits on their
|
|
15
24
|
* answer there, answers it. `/new`, `/space` and `/help` are commands
|
|
16
25
|
* (see shared/commands.ts).
|
|
26
|
+
* - **A tap** (a button, a list's row, a carousel card's reply) comes as its
|
|
27
|
+
* title, with what it meant (`tap.id`) and the addition it was in
|
|
28
|
+
* (`tap.key`), answering the message it was on.
|
|
17
29
|
*
|
|
18
30
|
* It reads the number, its phones and codes as the system (who's linked is
|
|
19
|
-
* what it's here to find out), and acts as the person
|
|
20
|
-
* do. Meta sending a message again changes nothing: the
|
|
21
|
-
* one. A retried delivery finds the calls it made answered
|
|
31
|
+
* what it's here to find out), and acts as the person, or the contact, for
|
|
32
|
+
* everything they do. Meta sending a message again changes nothing: the
|
|
33
|
+
* event is the same one. A retried delivery finds the calls it made answered
|
|
34
|
+
* from the log, and what it makes has ids from the message, so it makes the
|
|
35
|
+
* same ones.
|
|
22
36
|
*/
|
|
23
37
|
import type { ProcessorDef } from "../../../../runtime/mod.js";
|
|
24
38
|
export declare const receiveProcessor: ProcessorDef;
|