POST /webhooks/messaging_profile/<id>. channelRoutes verifies the signature, then messagingWebhook in channels/index.ts reads the event:
stubFor addresses its instance exactly as the mount does:
encodeAgentName(conversation) is encodeAgentName(), the encoding the mount applies to the name in every address.
conversationis the sender’s number, so the text reaches the same instance as/agents/support-agent/<number>.env[binding]is the actor namespace thattelnyx.tomlbinds, andidFromNamereturns the stub of the instance with that id. The stub calls any public method of the class in-process.
receiveVia in managed/agent.ts is the second ingress path, and deliberately not @rpc, so only the function’s own handlers, which verified the signature, can name where a reply goes:
this.setState() is setState().
- The entry is keyed by the message’s key, not the run’s id, and written before
admitqueues the run, since the run’s task may start the moment it is queued; Delivery reads it asstate.replyTo?.[run.key]. setState()merges the patch, so the newreplyToentry joins those of other messages.- A redelivered message carries the same key, so it overwrites its own entry with the same target and
admitanswersduplicate: true. noteRundeletes the entry withnullonce the run ends.
via is kept in state under the message key, before the run exists, and Delivery reads it when the run completes.