Skip to main content
Test messaging, Adaptive Card actions, and Graph calling controls with a Microsoft Twin Run. These examples use the Microsoft Teams Python SDK and synthetic identities. You do not need a live Microsoft tenant or access to Arga’s server repository.

1. Create a bot scenario

Install or update the Arga CLI to version 0.1.24 or later, then sign in. Save the following as scenario.json, then import the Scenario:
scenario.json
Replace <scenario-id> with the ID returned by the import. Wait until the run is ready. Copy the Microsoft base_url from the run’s status; the examples use its public drop-in URL. The fixed IDs and password above are synthetic test data. The Graph permission is granted inside the twin only. See the Microsoft reference for other seed fields.

2. Configure Python

Use Python 3.12 or later. These examples target Teams SDK 2.2.1.
Replace the URL with the Microsoft twin’s returned base_url. Keep these environment variables set in each terminal used below. The SDK uses this public API URL; the inspector uses a separate authenticated URL. Read the run status:
To open the inspector, append /ui/bots?token=<proxy_token> to twins.microsoft.admin_url, using the proxy_token from the same status response. For example, replace both placeholders in https://<admin-host>/ui/bots?token=<proxy_token>. Treat the token and this URL as credentials. The browser exchanges the token for a session cookie. Do not use the public base_url for the inspector: it blocks the control requests that the UI needs.

3. Echo messages and approve a card

Save this complete example as socket_bot.py. Socket Mode connects outward to the twin, so you do not need to expose a local callback server.
socket_bot.py
After the terminal prints Socket ready:
  1. Open the authenticated inspector described above and select Example bot · personal-example.
  2. Send Hello Teams as Ada Lovelace. The bot replies Echo: Hello Teams with an approval card.
  3. Click Approve. The card changes to Approved.
  4. Check Delivery history for successful acknowledgments. Click Refresh if the reply has not appeared yet.
The token helper requests a Connector token. The SDK handles socket negotiation, SignalR frames, and acknowledgments. The example creates a fresh connection after a close or connection failure. Keep the bot running while you interact with the inspector.

4. Exercise calling controls

Save this as calling.py beside socket_bot.py. It reuses the token helper, requests a separate Graph token, and creates a synthetic call to the seeded user.
calling.py
You should see successful participant reads, 200 for the three controls, and 204 for hangup. Call state is visible in the inspector under Sockets and calls. This example checks call state and controls without delivering callbacks. Its .invalid callback URL is a placeholder. To test calling notifications, use a reachable HTTPS receiver, validate the twin’s signed JWTs, and deliver the queued call events. Socket Mode activity delivery and Graph calling notifications use separate transports.

Reset and scope

Use Twin Run reset to restore the saved Scenario. Reset removes messages, calls, socket sessions, and pending deliveries; restart the bot after the reset finishes. Stop the bot with Ctrl+C and tear down the Twin Run when you finish. Calling media is synthetic: these examples do not connect to PSTN, capture a microphone, or stream real audio/video. For production bot authentication and SDK behavior, use Microsoft’s Bot Connector authentication guide and Teams SDK.