botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

push notifications wth facebook and trapping failures

Open karlbarber opened this issue 9 years ago • 3 comments

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;
          }

karlbarber avatar Jan 17 '17 09:01 karlbarber

@LarsLiden?

eanders-ms avatar Jan 26 '17 22:01 eanders-ms

Try fix this by adding MicrosoftAppCredentials.TrustServiceUrl(serviceUrl); before sending message. I'm sure you have stored serviceUrl :).

ghost avatar Apr 04 '17 07:04 ghost

@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,

JasonSowers avatar May 23 '17 19:05 JasonSowers