Nota
O acesso a esta página requer autorização. Podes tentar iniciar sessão ou mudar de diretório.
O acesso a esta página requer autorização. Podes tentar mudar de diretório.
Siga estas etapas para baixar anexos de um bot do Azure no Omnichannel.
Obtenha o token para seu bot usando a ID do aplicativo Microsoft e o segredo do cliente do bot.
Obtenha o
attachmentIdURL do anexo.Por exemplo, se o URL for
https://us-api.asm.skype.com/v1/objects/0-eus-d1-5360689c55c308cb4e3b51722e46b801/, então oattachmentIdé0-eus-d1-5360689c55c308cb4e3b51722e46b801.Insira o
attachmentIdem umaRequestUrivariável e, em seguida, useRequestUriem umaGETsolicitação, desta forma:string requestUri = $"https://botapi.skype.com/amer/v3/attachments/{attachmentId}/views/original"; var httpRequest = new HttpRequestMessage(HttpMethod.Get, requestUri); var authorization = new AuthenticationHeaderValue("bearer", <add the botToken here>); var requestHeaders = new Dictionary<string, string>() { { "Authorization", authorization.ToString() } }; foreach (var header in requestHeaders) { httpRequest.Headers.Add(header.Key, header.Value); } HttpResponseMessage response = await client.SendAsync(httpRequest);
Gerir anexos de ficheiros
Observação
As informações nesta seção são aplicáveis apenas ao Government Community Cloud (GCC).
Esta seção descreve como gerenciar anexos de arquivo na plataforma de mensagens do serviço de bot omnichannel.
Primeiro, vamos analisar rapidamente os formatos de anexo de arquivo no canal de serviço de bot omnichannel.
Formatos de anexos de ficheiros
Quando anexos de ficheiro são enviados do Dynamics 365 Contact Center para o bot do Azure no canal de serviço de bot Omnichannel, as informações necessárias para baixar os ficheiros são passadas nos campos amsReferences e amsMetadata da propriedade Activity.ChannelData.
Canal de serviço de bot omnichannel
{
"recipient":{
"id":"8:acs:5ecf37b1-11 Oc-414g-ab33-804ffd6b4a33_eooe0010-7c57-1ceb-nec-113aOdOOb272",
"name":"Omnichannel-test-bot",
"aadObjectId":null,
"role":null
},
"attachments ":null,
"channelData":{
"tags":"Channelld-lcw,FromCustomer",
"deliveryMode":"bridged",
"fromUserId":"8:acs:5ecf37b1-110c-4149-ab33-804ffd6b4a33_00000010-61 b9-ab1 d-3dfe-9c3aOd009ea4",
"amsReferences":[
"0-wus-d6-20e7797d208fab388cc11b09674d166"
],
"amsMetadata":[
{
"contentType":"image/png",
"fileName":"SurnmerTime.png"
}
],
"sourceChannelId":"omnichannel"
}
}
Como gerenciar anexos de arquivo em seu código de bot do Azure
As informações de anexo são passadas no canal de serviço do bot omnichannel e podem ser acessadas no código do bot, conforme mostrado no exemplo a seguir.
// 1. Retrieve Attachment ID from ChannelData["amsReferences"]
if (turnContext.Activity.ChannelData != null &&
turnContext.Activity.ChannelData is JObject incomingRequestChannelData &&
incomingRequestChannelData.TryGetValue("amsReferences", out JToken amsReferencesArray))
{
string attachmentId = JsonConvert.DeserializeObject<string[]>(amsReferencesArray.ToString()).FirstOrDefault();
// 2. Build HTTP request for specified attachment ID.
string requestUri = $"https://botapi.skype.com/amer/v3/attachments/{attachmentId}/views/original";
var httpRequest = new HttpRequestMessage(HttpMethod.Get, requestUri);
// 3. Acquire authentication token and add it to request headers
var token = await new MicrosoftAppCredentials("botAppId", "botAppSecret").GetTokenAsync();
var authorization = new AuthenticationHeaderValue("bearer", token);
httpRequest.Headers.Add("Authorization", authorization.ToString());
// 4. Add Azure Communication Services Bot ID to request header. This is required to achieve good download performance.
httpRequest.Headers.Add("BotAcsId", turnContext.Activity.Recipient.Id);
// 5. Use HttpClient to execute the request and download attachment
var response = await client.SendAsync(httpRequest);
// 6. Save HTTP response stream to the file
var responseContentStream = await response.Content.ReadAsStreamAsync();
using (FileStream fileCreateStream = new FileStream("file path", FileMode.Create))
{
fileCreateStream.CopyTo(responseContentStream);
}
}
Informações adicionais
Suporte de cartão por canal
Suporte para chat ao vivo e canais assíncronos