我在Azure中运行了一个LUIS bot服务。当我尝试使用图像回复用户(通过Microsoft团队)时,它会失败。我可以使用bot模拟器和图像的本地路径在本地运行相同的代码,并且它可以工作。代码如下。失败的代码行是这一行:
await connector.Conversations.ReplyToActivityAsync(reply);
public async Task ChitChatResult(IDialogContext context, LuisResult result)
{
ConnectorClient connector = new ConnectorClient(new Uri(context.Activity.ServiceUrl));
var activity = new Activity();
Activity reply = ((Activity)context.Activity).CreateReply();
reply.Attachments = new List<Attachment>();
reply.Attachments.Add(new Attachment()
{
ContentType = "image/png",
Name = "ShutIt.PNG",
//ContentUrl = $"C:\\Users\\casieo\\ShutIt.png"//when I debug locally in the bot emulator with this ContentUrl, the image is returned in the reply
ContentUrl = $"https://xxx.scm.azurewebsites.net/dev/api/files/wwwroot/images/ShutIt.PNG"
});
await connector.Conversations.ReplyToActivityAsync(reply);
await context.PostAsync($"Just kidding. But seriously, I'm not good at chit chat, but if you ask me a specific question, I should be able to help. For ideas about what I understand, reply back with 'what can i say?'");
}
如果我在ConnectorClient对象中包含MicrosoftAppId和MicrosoftAppPassword,则没有区别。可以使用我包含的ContentUrl在浏览器中访问该图像。
有什么想法吗?