push notifications wth facebook and trapping failures
We are sending out push notifications to facebook as part of our app and this normally working fine, but since the activation of the new facebook approval for pages_messaging_subscriptions we are seeing some issues in the bot framework website for facebook.
e.g.
{"error":{"message":"(#10) This message is sent outside of allowed window. You need page_messaging_subscriptions permission to be able to do it. Learn more about the new policy here: https:\/\/developers.facebook.com\/docs\/messenger-platform\/policy-overview","type":"OAuthException","code":10,"error_subcode":2018065,"fbtrace_id":"H\/vnkB0t7Fk"}}
and
There was an error sending this message to your bot.
I am adding the relevant permission to facebook so this should be fine, but is there a way to capture these errors programmatically rather than just seeing them in the web portal?
I am trapping any exceptions and also checking the content of the response from connector.Conversations.SendToConversationAsync
e.g.
var reply = await connector.Conversations.SendToConversationAsync((Activity)message);
// trap possible other errors ?
if (!string.IsNullOrEmpty(reply?.Message))
{
_objLogger.Info(JsonConvert.SerializeObject(reply));
_objLogger.Error("Failed to process message trapped with 'repy'content [" + reply.Message + "]");
}
QueueHelper.AddtoQueue("msg.audit", message, "out");
}
catch (Exception e)
{
_objLogger.Info(JsonConvert.SerializeObject(message));
_objLogger.Error("Failed to process message " +
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + " " +
System.Reflection.MethodBase.GetCurrentMethod().Name + "]" + e.Message +
((e.InnerException != null) ? ": " + e.InnerException.Message + " : " : ""));
return false;
}
@LarsLiden?
Try fix this by adding MicrosoftAppCredentials.TrustServiceUrl(serviceUrl); before sending message. I'm sure you have stored serviceUrl :).
@karlbarber I am going to close this issue for inactivity. If it is still outstanding for you please continue the discussion here as it can be reopened,