Send file attachments between bot and agent from Omnichannel for Customer Service

averner 1 Reputation point
2022-01-20T14:10:20.753+00:00

Hello!

I make integration of our Teams bot (based on MS Bot Framework) with MS Customer Service through Custom Channel (DirectLine).
The messages are sent's fine, but with attachments, I faced a problem.

In the case of sending attachments from Agent to User, I got an error in the Teams channel: "An exception occurred when converting file info card to file chiclet".
What am I doing:
I just try to map attachment from DirectLine (Microsoft.Bot.Connector.DirectLine.Attachment) context in received DirectLine Activity to General Attachment (Microsoft.Bot.Schema.Attachment) and send it to the user.
From DirectLine channel I received (when Agent send docx file):

{  
 "contentType": "application/vnd",  
 "contentUrl": "URI to download",  
 "name": "\"MyFile.docx\""  
}  

Then I create a general attachment, that sends to the user in a proactive message:

var attachment = new Microsoft.Bot.Schema.Attachment  
{  
   Content = new FileInfoCard  
   {  
       FileType = Path.GetExtension(directLineAttachment.Name),  
       UniqueId = Guid.NewGuid().ToString()  
   },  
       ContentType = FileInfoCard.ContentType,  
       ContentUrl = directLineAttachment.ContentUrl,  
       Name = directLineAttachment.Name  
}  

In the case of sending attachments from User to Agent - more incomprehensible. Because no matter how I configure Direct Line Attachment to send - in Customer Service Attachment is not received, and I can't understand why, because, as I understand, it fails when Azure Bot builds request to Omnichannel from DirectLine Channel, and this is some internal logic of Azure Bot.

Where I can find some information about sending attachments between bot and agent from Omnichannel for Customer Service through Custom Channel (DirectLine)?
I hope I explain my problem understandably.

Updates:
I found a next way to send, received by the bot attachments from DirectLine channel, to the user:
https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-add-media-attachments?view=azure-bot-service-4.0&tabs=csharp
https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bots-files

  1. Bot should download attachment as binary from external resource and then use it in Attachment.ContentUrl like a $"data:image/png;base64,{imageData}". But I'm not sure how it will work for a file attachment that is no image.
  2. Notify and request the user to upload attachment data into his OneDrive (Send File Consent card), upload attachment, and send File Download Info attachment. But I don't like additional step with sending a File Consent card.
  3. As I understand, in Teams, Attachments sharing between users through OnDrive of the Tenant. So, maybe I can configure MS Customer Service for Omnichannel to upload attachments into the OneDrive and generate a link with an access token to download and then use File Download Info attachment.
    If it is possible to configure, then where?

About sending attachments from user to agent, I still have no idea, because, as I understand, it failed, when proxy bot with DirectLine channel and Omnichannel channel map Attachment in DirectLine context to attachment of Omnichannel context, and this is some internal logic (black box).

Thank you.
Best regards.

Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,846 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sayali-MSFT 2,266 Reputation points Microsoft Vendor
    2022-02-03T05:19:11.387+00:00

    DirectLine v3.0 has support for Attachments (see Add media attachments to messages for more information about attachments). Check out the ReadBotMessagesAsync method in Program.cs to see how the Attachments are retrieved and rendered appropriately based on their type.
    Ref Doc:-
    https://github.com/microsoft/BotFramework-DirectLine-DotNet/tree/master/samples/core-DirectLine

      if (activity.Attachments != null)
         {
             foreach (Attachment attachment in activity.Attachments)
             {
                 switch (attachment.ContentType)
                 {
                     case "application/vnd.microsoft.card.hero":
                         RenderHeroCard(attachment);
                         break;
    
                     case "image/png":
                         Console.WriteLine($"Opening the requested image '{attachment.ContentUrl}'");
    
                         Process.Start(attachment.ContentUrl);
                         break;
                 }
             }
         }
    
    0 comments No comments