Skip to main content
POST /webhooks/messaging_profile/<id>. channelRoutes verifies the signature, then messagingWebhook in channels/index.ts reads the event:
The sender’s number is the conversation, and stubFor addresses its instance exactly as the mount does:
encodeAgentName(conversation) is encodeAgentName(), the encoding the mount applies to the name in every address.
  • conversation is the sender’s number, so the text reaches the same instance as /agents/support-agent/<number>.
  • env[binding] is the actor namespace that telnyx.toml binds, and idFromName returns 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 admit queues the run, since the run’s task may start the moment it is queued; Delivery reads it as state.replyTo?.[run.key].
  • setState() merges the patch, so the new replyTo entry joins those of other messages.
  • A redelivered message carries the same key, so it overwrites its own entry with the same target and admit answers duplicate: true.
  • noteRun deletes the entry with null once the run ends.
The message id is the key, so a redelivered webhook runs nothing. via is kept in state under the message key, before the run exists, and Delivery reads it when the run completes.