Sep 18 2023 08:34 AM
Hi All,
I am working on the Teams bot application and we wanted to send attachments from the team personal chat to the team group channel.
We have set supportedFiles to true in the manifest file and used the connector client to send the message from personal chat to the team group channel and vice versa.
ConnectorClient connectorClient = new ConnectorClient(new Uri(serviceUrl), microsoftAppCredentials);
connectorClient.Conversations.SendToConversationAsync(MessageActivity);
Message activity contains the attachment that personal chat has attached. But at the channel side the image is not visible or wrong image path,
Sep 19 2023 11:34 PM
Sep 21 2023 03:30 AM
you can send a message from a bot in a Teams channel to a bot in a Teams personal chat using the Bot Connector client. To achieve this, you need to use the proactive messaging feature of the Teams platform.
Here is an example of how you can send a message from a bot in a Teams channel to a bot in a Teams personal chat using the Bot Connector client:
Fetch the team roster to get the list of users in the team. You can use the Microsoft Teams API or the Bot Connector API to fetch the team roster.
Iterate through the list of users and send a direct message to each user. You can use the Bot Connector API to send a direct message to a user.
Here is an example code snippet in C# that demonstrates how to send a message from a bot in a Teams channel to a bot in a Teams personal chat using the Bot Connector client:
using Microsoft.Bot.Connector;
using Microsoft.Bot.Connector.Teams;
using Microsoft.Bot.Connector.Authentication;
// Fetch the team roster
var connectorClient = new ConnectorClient(new Uri(serviceUrl), new MicrosoftAppCredentials(appId, appPassword));
var teamRoster = await connectorClient.Conversations.GetConversationMembersAsync(teamId);
// Send a direct message to each user in the team
foreach (var member in teamRoster)
{
var conversationParameters = new ConversationParameters
{
Bot = new ChannelAccount { Id = botId },
Members = new ChannelAccount[] { new ChannelAccount { Id = member.Id } },
ChannelData = new TeamsChannelData { Tenant = new TenantInfo { Id = tenantId } }
};
var response = await connectorClient.Conversations.CreateConversationAsync(conversationParameters);
var conversationId = response.Id;
var message = Activity.CreateMessageActivity();
message.From = new ChannelAccount { Id = botId };
message.Conversation = new ConversationAccount { Id = conversationId };
message.Text = "Hello from the bot in the Teams channel!";
await connectorClient.Conversations.SendToConversationAsync(conversationId, (Activity)message);
}
In the above code, serviceUrl
is the URL of the Bot Connector service, appId
and appPassword
are the credentials of the bot, teamId
is the ID of the Teams channel, botId
is the ID of the bot, and tenantId
is the ID of the tenant.
Make sure to replace these placeholders with the actual values specific to your bot and Teams environment.
By using the Bot Connector client and the proactive messaging feature, you can send messages from a bot in a Teams channel to a bot in a Teams personal chat.
Sep 22 2023 07:34 AM - edited Sep 22 2023 07:35 AM
My requirement is for sending attachments (images/ screenshots/smiley) from team's channel to the personal chat and vice versa . (not directly attaching a png/jpeg file. Need to send the same attachment from the sender to the recipient )
The example shared works fine while sending message but note for attachments (images/screenhots/smiley) But while adding the attachment from user activity to teams channel activity it is throwing exception as 'Bad Request'
I want to send the screenshot from personal chat to teams channel and vice versa
var message = Activity.CreateMessageActivity();
message.From = new ChannelAccount { Id = recipient.Bot.Id };
message.Conversation = new ConversationAccount { Id = conversationId };
message.Text = "Hello from the bot in the Teams channel!";
message.Attachments = messageActivity.Attachments; ('messageActivity' will be the sender and 'message' should be the activity send to the recepient with the attachment send from sender )
'messageActivity' will be the sender and 'message' should be the activity send to the recipient with the attachment send from sender.
Sep 25 2023 08:26 PM
@Sayali-MSFT , is there any alternative to send images as attachments from personal chat to teams channel and vice versa.
Sep 28 2023 02:22 AM
@Sayali-MSFT , is there any update on this query
Sep 28 2023 05:44 AM
Sep 29 2023 03:56 AM
This document doesn't contain any sample by passing the same attachment from the teams sender to the recipient.
In all these samples, they are directly attaching the image address or providing the image path in the system itself. That is working scenario which we have already tested.
This is not the user case scenario that we needed we want to send the message activity which contains the attachment from the sender to the recipient.
Sep 29 2023 07:07 AM
Oct 03 2023 04:19 AM
Oct 03 2023 05:16 AM
Oct 14 2023 10:09 AM
Is there any update on this issue? Its already one week done. Do we have any alternative way to send image attachments between personal chat and channel in teams
Oct 16 2023 06:53 AM
Oct 18 2023 10:13 AM
Its clearly mentioned in the issue that we are not adding any images path directly, directly sending the image or screenshot in teams app by copy paste. It is getting automatically added in the turn context activity of bot.
Below are the attachment format for image attachment ,
If possible can you set up a meeting or remote session for further investigation. We are already spending weeks for a solution for this issue
Oct 31 2023 03:04 AM
Nov 08 2023 12:25 AM - last edited on Nov 08 2023 10:02 PM by Sayali-MSFT
Nov 08 2023 12:25 AM - last edited on Nov 08 2023 10:02 PM by Sayali-MSFT
Nov 09 2023 01:01 AM
@LimnaAdmin -We have also checked the above scenario, got the same issue as mentioned above.
Currently, this is not the possible scenario.
Could you please help by suggesting this feature on - Microsoft Teams · Community