Send Message as Bot

Send Message as Bot

 

In this article

Overview

You can use this Snap to programmatically send messages to Microsoft Teams channels or chats using a bot identity. This enables automated communication and integration between your business systems and Teams.

send-message-as-bot-snap-overview.png

Key benefits:

  • Sends automated messages to Teams channels or direct chats.

  • Includes rich content like text, images, and attachments.

  • Integrates Teams with other business applications and workflows.

  • Provides notifications and alerts directly within Teams conversations.

  • Enables bot-like interactions without building a full Teams bot application.

Snap Type

The Send Message as a Bot Snap is a Write-type Snap

Prerequisites

  • Valid Teams account with the required permissions.

Support for Ultra Pipelines  

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

 

 

  • Min: 0

  • Max: 1

  • Mapper

  • Copy

Example of an input document:

{ "message": "Welcome to the channel! This is a bot message.", "teamId": "b22e8da4-17c1-45c0-baa9-47aed7344e92", "channelId": "19:fec55eed11e94378b2846b3d4bf48ea9@thread.tacv2" }

Output

Document

 

  • Min: 0

  • Max: 1

  • Mapper

  • Router

The output document contains:

  • Message ID - Unique identifier of the sent message

  • Confirmation details - Status and metadata about the message delivery

  • Timestamp - When the message was sent

  • Channel information - Details about where the message was posted

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab:

  • Stop Pipeline Execution: Stops the current pipeline execution if the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

  • Expression : JavaScript syntax to access SnapLogic Expressions to set field values dynamically (if enabled). If disabled, you can provide a static value. Learn more.

  • SnapGPT : Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.

  • Suggestion : Populates a list of values dynamically based on your Account configuration.

  • Upload : Uploads files. Learn more.

Learn more about the icons in the Snap Settings dialog.

Field Name

 

Field Type

Description

Field Name

 

Field Type

Description

Label*

 

 

String

The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Default ValueSend Message as Bot
ExampleSend Message as Bot

Service URL*

String/Expression

Specify the Service URL.

This Snap allows messages to be sent successfully even when the Service URL field contains non-standard Service URLs. For example, when a Service URL such as the following is provided, the messages are successfully delivered as long as the Conversation ID and Message fields are valid.

  • https://smba.trafficmanager.net/amer/Select*into employee, or

  • https://smba.trafficmanager.net/amer/c3033f67-b837-4b3d-8eb3-77415dc71002/ (where the unique ID is invalid),

This behavior is caused by the Microsoft Bot Framework API’s routing layer, which only validates and routes requests based on the /v3/conversations/... segment of the URL.
Any additional or extraneous path segments that appear after /amer are ignored by the routing logic.

  • Arbitrary or malformed path segments after /amer do not prevent message delivery.

  • However, if the region segment itself (for example, amer is changed to amer1, or if extra paths are added after the expected URL structure, message delivery fails.

We recommend that you always use the documented and supported endpoint format as shown below: {serviceUrl}/v3/conversations/{conversationId}/activities

All clients must use only valid and documented service URL structures to ensure compatibility with future updates of the Microsoft Bot Framework. Learn more: https://learn.microsoft.com/en-us/answers/questions/5576695/unexpected-behavior-bot-framework-api-accepts-arbi?page=0&orderby=helpful&comment=answer-12273566&translated=false#newest-answer-comment

Default Valuehttps://smba.trafficmanager.net/teams
Example: https://smba.trafficmanager.net/amer/v3/conversations/19:abcd1234efgh5678@thread.tacv2/activitie

Conversation ID

 

 

String/Expression

The Conversation ID is a unique identifier for a Microsoft Teams conversation (channel or chat) that you need to obtain from Microsoft Teams.

The Conversation ID is obtained from the user’s message activity response. The key difference between the conversation ID in a personal chat and a channel is that in a channel, the message ID is included in the conversation ID. This inclusion allows replies to be sent in the same message thread. If the message ID is not included, the message will appear as a separate thread.

Here’s an example of a conversation with a message ID:

'19:fec55eed11e94378b2846b3d4bf48ea9@thread.tacv2;messageid=1758791100665'

You can use any of the following methods to obtain the Conversation ID:

  1. From Teams Web/Desktop App:

    1. Open the Teams channel or chat where you want to send the message.

    2. Copy the URL in your browser or copy the link from the ellipsis of the conversation

    3. The Conversation ID is embedded in the URL format like: 19:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@thread.tacv2

  2. Using Microsoft Graph API:

    1. Call the Graph API to list conversations/channels.

    2. Use endpoints like /teams/{team-id}/channels to get channel information.

    3. The response will include the Conversation ID for each channel.

  3. From Teams Bot Framework

    1. If you're building a bot, the conversation ID is provided in the activity context when your bot receives messages.

    2. It's available in the conversation.id property of incoming activities

  • Teams Admin Center:

    • For administrators, you can find conversation details through the Teams admin portal.

    • Navigate to the specific team/channel to view its properties.

For production use, you'd typically want to:

  • Make this a pipeline parameter instead of hardcoding it.

  • Or retrieve it dynamically from an API call.

  • Or pass it as input data to your pipeline.

Default Value: N/A
Example:

  • '19:fec55eed11e94378b2846b3d4bf48ea9@thread.tacv2'

  • $conversationID1

Text format*

Dropdown list

The format for the text message. The supported formats are Plain/Markdown and XML.

Default Value: N/A
Example: Plain

Message*

String/Expression

The actual content that will be sent to the Microsoft Teams channel or chat. It contains the body text of the message that your bot will post to Teams, and users will see in the conversation.

This field supports Plain text, Rich formatting text, and Unicode characters. You can use expressions to make messages dynamic. For example, "Alert: Server ${serverName} is down. Status: ${status}"

Default Value: N/A
Example:
CRITICAL ALERT 🚨
Server: web-prod-01
Status: DOWN
Time: 2024-10-22 14:30 UTC
Action Required: Immediate investigation needed

Images

Use this field set to attach image files to your Teams messages. This allows your bot to send visual content along with text messages to enhance communication and provide richer information.

URL/Data

String/Expression

The URL for the images that are publicly accessible or Base64-encoded image data for embedded images.

Default Value: N/A
Example: https://www.snaplogic.com/media-kit/Logocombo_SnapLogic_RGB.png

Content type

String/Expression

The format of the message content to send to Microsoft Teams. This field determines how Teams interprets, processes, and renders your message content.

Default Value: N/A
Example: image/jpeg

Name

String

The name of the image to help identify your bot in Teams conversations.

Default Value: N/A
Example: "System Alert Bot" - Messages appear from "System Alert Bot"

Number of Retries

String/Expression

The maximum number of attempts to attempt when the Snap fails. 

Default Value: N/A
Example: 3

Retry interval (seconds)

String/Expression

The time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception.

Default Value: N/A
Example: 1

Snap Execution

 

Dropdown list

Select one of the following three modes in which the Snap executes:

  • Validate & Execute: Performs limited execution of the Snap based on Preview Document Count value in User settings and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.

  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default Value
Example: Validate & Execute

Example

Send a bot message to the Teams channel

This example pipeline demonstrates sending a message as a bot to a Microsoft Teams channel.  It generates a test message containing various Unicode characters and special symbols, maps the necessary parameters for the Teams API call, and sends the message with an image attachment to a specified Teams conversation.

Download this Pipeline

ex-send-msg-as-bot-pipeline.png
  1. Configure the JSON Generator Snap to generate a comprehensive test message containing placeholder text and various Unicode characters, including emojis, international characters, mathematical symbols, and special characters.

    1. Lorem ipsum text - Standard placeholder text

    2. Various Unicode characters - International characters, emojis, mathematical symbols

    3. Special characters - Testing how Teams handles different character encodings

  2. Configure the Mapper Snap to map various parameters needed for the Teams API call (conversation ID, service URL, and message content), preparing the data structure required for sending messages to the Teams channel.

    ex-bot-msg-mapper-config.png


    On validation, the Mapper Snap maps various Teams bot configuration parameters, including conversation IDs, service URLs, and message content, for sending to the Teams channel.

    ex-bot-msg-mapper-output.png

 

  1. Configure Send Message as Bot Snap to send the mapped message content as a bot to the specified Teams conversation, including an image attachment, and use plain text formatting for the message.

    ex-send-msg-as-bot-config.png

On execution, the Snap sends the mapped message content as a bot to a Microsoft Teams channel, including an attached image from SnapLogic's media kit.

ex-msg-sent-to-channel.png

Downloads

  1. Download and import the pipeline into the SnapLogic application.

  2. Configure Snap accounts, as applicable.

  3. Provide pipeline parameters, as applicable.

 

Snap Pack History

Related Content