1. Microsoft Teams
  2. Setup Template

Microsoft Teams

Setup Template

Explains sending Microsoft Teams messages from a template action's notifications. Useful for replying to Teams chats with text and files, and for routing replies back to a stub.

Overview

Teams messages are sent from the notifications section of an action, with the microsoft-teams platform.

A bot can only message a chat it has already received a message from. When someone messages your bot, Stubber saves the chat on the stub in stub.data._incoming_microsoft_teams_data. The notification uses that saved chat to reply.

Send message out

loading...

Message types

The message is an object with the text in value and the format in type. The type decides how Teams shows the text, or sends a typing indicator instead.

type Teams shows
text The text as plain text, exactly as written. This is the default.
markdown The text with Markdown formatting
xml The text with a subset of HTML formatting
indicator A typing indicator. No text is sent.

If type is missing or isn't one of these, the message is sent as text.

Text

The text is shown exactly as written. Markdown and HTML characters, such as * or <b>, appear as is. Use text for messages from people, so their text isn't formatted by accident.

loading...

Markdown

The text is formatted with Markdown. Teams supports bold (**bold**), italic (_italic_), strikethrough (~~struck~~), links ([text](https://...)), numbered and bulleted lists, inline code, code blocks and headings.

loading...

XML

The text is formatted with a subset of HTML tags. Teams supports <b>, <strong>, <i>, <em>, <u>, <s>, <a href="...">, <br/>, <p>, <ul>, <ol>, <li>, <pre>, <code>, <blockquote> and <h1> to <h3>.

loading...
TIP

Use <br/> or <p> for line breaks with xml. Use single quotes around attribute values, such as href='...', so you don't have to escape them in JSON.

NOTE

Teams doesn't show tags it doesn't support, and some tags, such as headings and quotes, look different on desktop and mobile. Check your message on the Teams apps your users have.

Typing indicator

Shows "bot name is typing…" in the chat. Use it before a step that takes a while, such as an AI reply, so the person knows a reply is coming. No value is needed, and attachments are ignored.

loading...
NOTE

Teams shows the indicator for a few seconds, or until the bot's next message arrives. Send it again if a reply takes longer. Teams shows typing indicators in personal and group chats, not in channels.

Parameters

Everything inside platforms.microsoft-teams should be considered parameters for this notification.


profileuuid
required
string

The Microsoft Teams profile (bot) to send from. The profile must belong to the same org as the stub.

Use ~~stub.data._incoming_microsoft_teams_data.profileuuid to reply from the bot that received the message.


channel
required
object

The Teams chat to send to. Use ~~stub.data._incoming_microsoft_teams_data.channel to reply to the chat the message came from.

If the person is in a stubsession with this stub, the reply always goes to the chat of that stubsession.


message
required without attachments
object

The message that is sent out, or { "type": "indicator" } for a typing indicator. See Message types for examples.

Show child attributes
value
required, except for indicator
string

The text of the message.

type
optional
string

How Teams formats value: text, markdown or xml. Use indicator to send a typing indicator instead of a message. An unknown type is sent as text.

Default: text

Default: null


attachments
required without message
array

Files to send with the message. Each item is a Stubber file object with a fileuuid, for example the files from a file upload or the attachments of an incoming Teams message. Stubber gets the file name and content type from the file server and sends Teams a link to the file.

You can set name or contentType on an item to override the values from the file server.

loading...
NOTE

Teams shows images inline. Teams might not show other file types, such as PDFs, when a bot sends them.

Default: []


stubsession
optional
object

Controls the stubsession, which decides which stub gets the person's next messages in this chat. Without a stubsession, incoming messages follow the routes on the profile.

Default: null


stubsession.set_new_with_timeout_hours
optional
number

Opens a stubsession for this chat for this many hours. Until it ends, the person's messages in this chat go to the stub that sent the notification.

Default: null


stubsession.set_feedback_action
optional
string

The action to run on the stub for incoming messages during the stubsession. If you leave it out, Stubber uses the current stubsession's action, or the feedback action of the profile route.

Default: null


stubsession.cancel_current_existing_stubsession
optional
boolean

Set to true to end the stubsession for this chat. Incoming messages then follow the profile routes again.

Default: false

Incoming message data

When a message is received, the feedback action gets the message in stubpost.message, and any files sent with it in the post's attachments. Stubber also saves the following on stub.data._incoming_microsoft_teams_data:

  • profileuuid: the profile that received the message
  • channel: the chat the message came from, used to reply
  • message: the message text
  • attachments: the files sent with the message, saved to the Stubber file server