How to connect a Teams agent
This guide connects Microsoft Teams to your Agent: someone @mentions your agent in a Teams channel, the message triggers a flow, and the agent’s answer is posted back into a channel, with conversation memory per Teams thread.
Unlike Slack and Discord, Teams does not use a socket connection or the gateway service. Teams is a webhook channel: Teams delivers each message over HTTP to a Publicus webhook, the same way Telegram and WhatsApp do. You wire up two webhooks that point in opposite directions:
- An outgoing webhook in Teams (the trigger): people @mention its name in a channel, and Teams sends the message to your Publicus webhook URL, signed with a shared secret that Publicus verifies on every request.
- A workflow webhook in Teams (the reply): the flow posts the agent’s answer to this URL, and Teams shows it in the channel the webhook was created for.
Prerequisites
Section titled “Prerequisites”- A Microsoft Teams team where you can manage apps, so you can create an outgoing webhook and add a workflow.
- An LLM provider key for the Agent, either stored as a secret or already set as a workspace key under AI models.
1. Create the inbound webhook in Publicus
Section titled “1. Create the inbound webhook in Publicus”-
In your workspace, go to Webhooks (under Services) and create one. Give it a name, and set Channel handler to Microsoft Teams. The handler is what verifies each request’s HMAC signature; leave Shared secret empty for now, because Teams only reveals the secret in the next step.


-
Save, then copy the webhook’s address, under its name, with Copy. This is the callback URL Teams needs.


2. Create the outgoing webhook in Teams
Section titled “2. Create the outgoing webhook in Teams”- In Teams, open the team, go to Manage team → Apps, and choose Create an outgoing webhook (the exact location varies a little between Teams client versions).
- Set the name (this is what people @mention, so pick something like
Support), paste the Publicus webhook URL from step 1 as the callback URL, and add a description. - When you create it, Teams shows a security token once. Copy it before closing the dialog. This is the shared secret Publicus verifies signatures with, and it does not expire.
3. Store the secret and finish verification
Section titled “3. Store the secret and finish verification”-
Back in Publicus, edit your webhook and pick a secret in Shared secret. The field’s + button creates the secret in place: name it
teams_shared_secretand paste the security token from step 2 as the value.

-
Save. From now on, Publicus checks the
Authorization: HMACsignature on every request against this secret before anything is stored or run. Requests that fail the check are rejected and leave no trace in the webhook’s request log.
4. Create the reply webhook in Teams
Section titled “4. Create the reply webhook in Teams”The flow answers by posting a message card to a Teams webhook URL that targets one channel.
- In Teams, open the channel the agent should answer in, and add a workflow from the template Post to a channel when a webhook request is received (the Workflows app). Point it at the team and channel, and copy the request URL it gives you.
- Store the URL as an opaque secret named
teams_webhook_urlin Secrets (a tab of Connections). This keeps the URL out of the flow definition, so it is not exported with the flow.
5. Build the flow
Section titled “5. Build the flow”Create the flow that answers each @mention. On the Templates page (under Automation), the Channel / Teams example in the One flow per node section imports a minimal flow with the reply node already wired, or start from an empty flow and add the nodes yourself.
-
Add a Webhook trigger node (under Triggers — start the flow), point its webhook field at the webhook from step 1, and connect its trigger handle to Start.
-
The incoming request lands on
$start, with the Teams message under$start->payload:Field Expression message text {!! $start->payload->text !!}conversation id {{ $start->payload->conversation->id }}sender id {{ $start->payload->from->id }}sender name {!! $start->payload->from->name !!}The message text includes the @mention itself as a tag, for example
<at>Support</at> where is my order?. Use{!! !!}for the text and the sender name so characters like quotes, apostrophes, and ampersands reach the agent unescaped. -
Wire
Start → Agent → Teams. On the Agent, setpromptto{!! $start->payload->text !!}and tell it insystemMessagethat every message starts with an<at>mention tag it should ignore. Leavecredentialempty to use the workspace key for the provider, or pick your own LLM secret. -
Connect a Chat Thread node to the Agent’s Memory handle, with
channelset toteams,conversationIdto{{ $start->payload->conversation->id }}, anduserIdto{{ $start->payload->from->id }}. In Teams, every new channel post starts a new conversation id, and replies inside that post’s thread share it, so the agent’s memory follows the Teams thread. -
On the Teams reply node (under Channels — send a reply), set
webhookUrlto{!! $secrets->teams_webhook_url !!}andtextto{!! $prev->content !!}. Both need{!! !!}: the workflow URL contains query parameters with&, and the agent’s answer may contain characters that escaping would corrupt. The optionaltitleandthemeColorfields style the message card. -
Publish the flow, then arm the trigger: click the Webhook node’s badge on the canvas and switch Active on. Arming takes effect immediately. Live messages run the published version, so later edits to the draft do not reach Teams until you publish again; a flow that has never been published answers from its draft.
Verify it works
Section titled “Verify it works”-
Delivery: @mention the webhook’s name in a channel of the team, for example
@Support what can you help with?. The request appears in the webhook’s Deliveries tab (and under Traffic in Operations), with the run it started.

-
Run: under Runs, a run of your flow completes.
-
Reply: the agent’s answer appears in the channel the workflow webhook targets, posted by the Workflows bot.
-
Memory: under Conversations, a thread exists for the Teams conversation. Reply inside the same Teams post’s thread with a follow-up @mention that refers to your earlier message, and confirm the agent remembers.
Troubleshooting
Section titled “Troubleshooting”-
Teams shows an error under the @mention: partly expected. Publicus acknowledges the request and processes it in the background, so Teams gets no inline reply message to render. The real answer arrives separately through the workflow webhook. Only investigate if that separate message never comes.
-
Nothing appears in the Deliveries tab: the signature check is failing or the URL is wrong. Confirm the
teams_shared_secretsecret holds the security token exactly as Teams showed it, and that the outgoing webhook’s callback URL matches the Publicus webhook’s address. Rejected requests are refused before storage, so they never show up. Also check the webhook’s Allowed IP addresses is empty, or includes Microsoft’s addresses. -
A request appears but starts no run: the trigger is not armed, points at a different webhook, or its trigger handle is not connected to Start. The Deliveries tab’s Runs column shows what each request started, and skips are recorded on the request.
-
No reply arrives in Teams: open the run under Runs; a failed reply node also marks the run failed. If the reply node failed with
Teams webhook returned unexpected status, the error names the status it received: an error status means theteams_webhook_urlsecret holds a wrong URL or the workflow in Teams is turned off, while a202means the workflow accepted the card without the200answer the node requires, so check whether the card still arrived in the channel. -
The reply lands in the wrong channel: a workflow webhook posts to the one channel it was created for. Create a webhook per channel if the agent should answer in more than one.
-
A message got no reply while another was being answered: the Webhook trigger’s without overlapping setting (on by default) skips a new run while one is still in progress, and records the skip on the request. Turn it off to answer concurrent messages.


-
The agent forgets mid-conversation: memory is keyed by the Teams conversation id. A fresh channel post starts a new conversation, and only replies within the same post’s thread share memory.
Related
Section titled “Related”- Connect an agent to a chat channel, the channel overview.
- Connect a Telegram agent and Connect a WhatsApp agent, the other webhook channels.
- Connect a Slack agent, a bot that dials out, for contrast.
- Receive webhooks, the webhook edge in full.
- Channel / Teams · Secrets · Conversations.