teams_v2) normally receives activities on its HTTPS messaging endpoint, POST /api/teams/v2/messages/{bot_id}, which Teams must be able to reach from the internet. Socket delivery turns that around: Genesis opens outbound WebSockets to Teams, and activities arrive over them. No inbound endpoint, tunnel or certificate is needed.
When to choose socket delivery
Choose it when Genesis cannot accept inbound HTTPS from Microsoft:- Genesis runs behind a firewall or on a private network with no public ingress.
- You are developing or evaluating against a new bot and do not want to publish an endpoint or run a tunnel.
amer.botapi.skype.com, emea.botapi.skype.com and apac.botapi.skype.com, and any proxy or firewall must allow WebSocket upgrades and long-lived connections.
Turn it on
The bot registration and Genesis must agree. Switch both.1. Switch the bot registration
In Teams Developer Portal:- Go to Tools > Bot management and select the bot.
- Select Configure.
- Under Delivery method, select Socket mode, and then select Save.
2. Switch Genesis
Setteams_v2.delivery to socket (Settings, or the TEAMS_V2_DELIVERY environment variable). teams_v2.enabled, teams_v2.app_id and teams_v2.client_secret must already be set, as for HTTPS delivery.
The sockets carry the activities of one agent: the one named in teams_v2.socket_agent_id, or, when that is empty, the one agent with a Teams adapter. With several such agents, set teams_v2.socket_agent_id; until then no socket is opened and the status says no_agent.
Genesis reads these settings every 15 seconds, so no restart is needed.
What Genesis does
- One server holds the sockets. Teams allows only a few sockets per app and region (more are refused with HTTP 429). On a deployment with several Genesis servers, the one holding the
teams_v2_socketlease in the metadata database opens them. It renews the lease every 15 seconds. When that server stops, another takes the lease and reconnects within a minute; a clean shutdown hands over at once. - One socket per region (amer, emea, apac), as Teams requires. A dropped region reconnects by itself with backoff, honoring Teams’
Retry-After. If a whole start fails, or Teams refuses a region for good (for example after the app secret was rotated), Genesis closes the sockets and starts again after 5 seconds, then 15, 30, 60, 120 and every 300 seconds, reading the app’s credentials again each time. - Fails closed. A server that cannot read the lease or its settings closes its sockets, so two servers never hold them at once. A shutting-down server closes its sockets and frees the lease first, then gives answers already running up to 10 seconds to finish.
- Same handling as HTTPS. Messages, group chats, channels, Approve and Deny cards, question cards and account links behave exactly as they do over HTTPS. The serviceUrl and tenant allowlists apply too.
- The 25-second reply limit. Teams fails an activity whose reply comes later than 25 seconds. Genesis acknowledges a message at once and sends the agent’s answer separately, as it always does. A card click whose decision takes longer than 20 seconds is answered “Still working on this”; when the request is approved or denied, the card is redrawn for everyone. A click that ends in a refusal after that point is logged and counted, but its clicker sees no further message.
Check its status
Admins can readGET /api/teams/v2/socket/status:
Server logs carry the same events under
Teams v2 socket:.
Troubleshooting
Switch back to HTTPS
Setteams_v2.delivery to https, then switch the registration back: in Developer Portal select HTTPS endpoint and enter the messaging endpoint URL, or run teams app update <app-id> --messaging-mode http --endpoint <https-url>. Genesis closes its sockets and frees the lease at its next tick.
Microsoft’s reference: Configure the delivery method for an agent.
