Before I upgrade the Bot Framework with C# environment
I can only send an image attachment in Skype with the following code
var replyMessage = context.MakeMessage();
Attachment attachment = null;
attachment = GetInlineAttachment();
replyMessage.Attachments = new List<Attachment> { attachment };
context.PostAsync(replyMessage);
private static Attachment GetInlineAttachment()
{
var imagePath = HttpContext.Current.Server.MapPath("~/App_Data/p1.png");
var imageData = Convert.ToBase64String(File.ReadAllBytes(imagePath));
return new Attachment
{
Name = "p1.png",
ContentType = "image/png",
ContentUrl = $"data:image/png;base64,{imageData}"
};
}
but after the upgrade, It do not work for Skype but still work well on Bot Emulator
How to fix it ?
BTW, I think that is impossible to send a "txt" file from bot to user or save a txt file from user client now, is it?
(the txt file is saved in the C# project )
@gmiloveyou Hello, to troubleshoot this problem we will need more context such as your bot id or conversation id for the failed request. Thank you!
@konstlut
First, thanks you guys for response.
Now,I can give you the information is the post response I got from bot in Emulator.
The others needs some time due to some reason.
/*
Remind that the code work well in Emulator
However, it do not response anything in Skype.
In normal condition, I suppose that I will get the message from the bot framework.
like "Sorry, my bot code has some problem" if my code went wrong.
But in this case, My bot response nothing and I can continue to interact with my bot.
*/
Is that Enough?
{
"type": "message",
"timestamp": "2017-03-31T05:45:31.2390338Z",
"serviceUrl": "https://327285a3.ngrok.io",
"channelId": "emulator",
"from": {
"id": "6a3m955cmjfc2kf51c",
"name": "Bot"
},
"conversation": {
"id": "jk4e6l2imk3cmc"
},
"recipient": {
"id": "default-user",
"name": "User"
},
"locale": "zh-TW",
"text": "",
"attachments": [
{
"contentType": "image/png",
"contentUrl": "data:image/png;base64,iVBORw0KGgoAAAANSU....(very long)".
"name": "p1.png"
}
],
"entities": [],
"replyToId": "gfkcn28gg943kb1c"
}
@gmiloveyou That payload is fine. Could you please share your bot msa app id and I will search backend logs for possible errors? Thank you.
@konstlut
d49d65e8-1b54-4ef5-952c-1a221d157ac2 thanks
@gmiloveyou, are you still able to reproduce the issue? If so, what error do you get from BotFramework side?
Could you please show the full server response and timestamp? It would be extremely helpful :)
@konstlut @ilyalukinykh hello, thanks for reply

--
Recently I found that sometimes the bot work on Skype.
This picture shows my problem. When I type in "pic", the bot should show me a picture.
It sometimes works.(Maybe 5% when I try recently) .

However, It always work on Emulator

I guess the emulator will reply any message correctly.
But in Skype, when the execution time takes to long, Skype just ignore the reply ?
I have the same problem when I try to using "SendToConversation()" to send a message directly.
The message do not always send.
@gmiloveyou, that's quite strange. Let me dive in logs to understand what could be the reason.
By the way, could you please show the HTTP response body that bot is getting after the request that you've shown above?
context.PostAsync(replyMessage);
@ilyalukinykh
Actually, I do not known how to get the HTTP response body from Skype. Maybe I should check something on Azure?
(Sorry for my low technical ability,I hope that do not cause any unnecessary problems )
I suppose you mean the information from Emulator?

@gmiloveyou, by the way, please notice that context.PostAsync(replyMessage) call is asynchronous, however it's not being awaited in the code listed above.
Shouldn't it be await context.PostAsync(replyMessage) in this case?
@ilyalukinykh
When I use "await" is the same. Work on Emulator but not in Skype.
Additional, I found the problem may cause by my code structure.
But I could understand why this would happen.
First I use IDialog , when this IDialog got a message from user, I analysis the message.
Then use "reflection invoke" since I have too many function (or condition) to handle
(
Type tType = Type.GetType("myfunction_name");
MethodInfo mInfo = tType.GetMethod(myfunction_name);
mInfo.Invoke(Activator.CreateInstance(tType), new object[] { context });
)
to execute a function ,pass the context object into the function
so I can reply or create a message in that function
(exp: I type in "pic" ,then execute the pic(context){} function)
And I try to place the code about sending a picture before the reflection as a test.
Then It works on Skype.
Is that related to anything about thread or context issue?
@konstlut @ilyalukinykh
Thanks you guys help, after you guys tell me about the issue about the await.
It reminds me that I forget to check something in my code.
Then I found that there is a deadlock problem when I try to
"mInfo.Invoke(Activator.CreateInstance(tType), new object[] { context });"
after use "task.ConfigureAwait(false);"
Now everything is back on the track now.
Appreciate you guys patient and help.
It really helps a lot in my work. You guys are awesome.
Most helpful comment
@konstlut @ilyalukinykh
Thanks you guys help, after you guys tell me about the issue about the await.
It reminds me that I forget to check something in my code.
Then I found that there is a deadlock problem when I try to
"mInfo.Invoke(Activator.CreateInstance(tType), new object[] { context });"
after use "task.ConfigureAwait(false);"
Now everything is back on the track now.
Appreciate you guys patient and help.
It really helps a lot in my work. You guys are awesome.