Forum Discussion

Lakshmi_145's avatar
Lakshmi_145
Iron Contributor
Sep 05, 2023

Send attached images in teams to another connected user or agent.

I am working on a Bot framework project.

We have a feature called 'Connect to Agent' for connecting the user to live teams agents. Once connected with the agent, the user can send text messages to the agent and vice versa using ConnectorClient.

 

We wanted to add a new feature to send screenshots/ attach images either from agent or user to the connected one. 

 

 

 We have used the below code to get the attachment content details,

 

foreach (var attachment in activity.Attachments)
{
if (attachment.ContentType == "text/html")
{
message = attachment.Content.ToString();
}
}

 

And to send the message ,

IMessageActivity messageActivity = utilities.CreateMessageActivity(recipient, message);

ConnectorClient.Conversations.SendToConversationAsync((Activity)MessageActivity);

 

Able to send the image to the connected user or agent , but its not displaying as the path is not correct.

 

 

 

Is there any other possible ways we can get the attached image and send to the connected teams channel (agent or user)

 

 

 

15 Replies

    • Lakshmi_145's avatar
      Lakshmi_145
      Iron Contributor

      Sayali-MSFT 

       

      Is there any update on this.  Will be able to send images to connected user or agent using bot framework ?

       

      • Lakshmi_145's avatar
        Lakshmi_145
        Iron Contributor

        Lakshmi_145 

         

        I also tried the below code,

         

         

        IMessageActivity forwardedMessage = activity;
        foreach (var attachment in activity.Attachments)
        {
        if (attachment.ContentType.StartsWith("image/"))
        {
        forwardedMessage = Activity.CreateMessageActivity();
        forwardedMessage.Attachments = new List<Attachment> { attachment };
        forwardedMessage.ApplyConversationReference(recipient);
        }
        }

         

         

         and send the message activity using connector client. Got the same image invalid in recipient teams bot 

         

         

         

        Also tried to access the content url we are getting in the activity attachment , but it shows the below authorization error message 

         

        {"message":"Authorization has been denied for this request."}

         

        We are trying to send message from teams bot personal chat to the teams groups chat.

         

        Image was getting received at group chat side when manually edited the attachment conent url with a jpeg image .

Resources