Botframework-sdk: [Feature Request] Add support for Facebook Message Tags

Created on 10 Jun 2017  路  22Comments  路  Source: microsoft/botframework-sdk

Adding a Message Tag allows you to send it outside the 24+1 window, for a limited number of use cases (shipping update, reservations, and issue resolution), per Messenger Platform policy.

Documentation

System Information (Required)

  • SDK Language: Node.js
  • SDK Version: 3.8.4

Issue Description

Since Facebook decided that the 'tag' should be outside of the 'message' object, it isn't possible to add this tag using Message.sourceEvent. This is quite an important feature for the Facebook Messenger channel since it allows you to send users a proactive message after 24 hours.

Expected Behavior

{
  "recipient": { 
    "id": "USER_ID"
  },
  "message":{
    ...
  },
  "tag": "SHIPPING_UPDATE"
}

Actual Results

{
  "recipient": { 
    "id": "USER_ID"
  },
  "message":{
      "tag": "SHIPPING_UPDATE"
  }
}

Most helpful comment

With the help of the comments above I have finally solved this for anyone looking for any further help. @EricDahlvang's post above re-inspired me to look at this again and it works. I have posted the details on Stack Overflow here:
https://stackoverflow.com/questions/49082513/microsoft-bot-framework-how-to-set-facebook-message-tag

Thanks :-)

All 22 comments

We also need this feature and if possible a way to tag the conversation from the webchat component. Also, if anyone has a workaround for this, please let us know.

Thank you.

Please let us know if anyone has any news about it, because we need it. Thank you!

Facebook just added 5 extra Message Tags in an update of the Messenger Platform. At the moment this is a huge limitation of the Bot Framework for more advanced bots on Facebook, since you can't send users a message anymore after the 24+1 window.

Any idea if this is on the Bot Framework roadmap (@nwhitmont)?

Hello, do you have any news about this feature request?
Thanks

Any updates or a work-around? This is quite a blocker for proactive messages on Facebook, since it isn't possible for most usecases without this Message Tag..

Facebook just announced more new Message Tags (https://messenger.fb.com/blog/3-new-tags-now-available-for-customer-messaging/).

Unfortunately no update at this time. Feel free to check back periodically, good luck!

Any updates or a work-around? +1

I found how to add a tag using C#

var activity = (Activity)message;
activity.Properties = new Newtonsoft.Json.Linq.JObject();
activity.Properties.Add("tag", "APPLICATION_UPDATE");

@Ma3yTa Have you tested it? how do you know it works?

@etbuilder I tested it and it works as expected because I got approvement for proactive messages from Facebook. They give this approvement only if you have any tag in a payload.
https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags

Can someone from Microsoft (@JasonSowers ) confirm this is the right place in C# to implement message tags?

@etbuilder due to Microsoft you can use ChannelData to implement channel specific functionality https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-channeldata . I didn't try to use ChannelData because overriding properties using Properties works for me.

Hi, is there any update on this? @Ma3yTa are you sure you鈥檙e not just getting it to work by using subscription messaging? You鈥檙e code above doesn鈥檛 work for me. See my comment on this issue #4154.

Thanks

@stuprice it works for me.
Try to use just this two lines without setting ChannelData

var activity = (Activity)message;
activity.Properties = new Newtonsoft.Json.Linq.JObject();
activity.Properties.Add("tag", "APPLICATION_UPDATE");

Hi, thanks for your reply. I've tried the code above and it still doesn't work for me. I've posted the full details on Stack Overflow, would you mind having a look?

How to Set Facebook Message Tag

Thanks

@stuprice I posted code of class which I use for proactive messages on stack overflow https://stackoverflow.com/a/49148650/5113846 .

Is there any solution for Node.js? It would be great if a don鈥檛 need to migrate all my session.send lines to native FB messages and add the new property...

I'm testing a solution for Node.js versi贸n based on a middleware. What I do for each reply message is the following:
send: (event: BotBuilder.IEvent, next: Function) => {
if (event.source === 'facebook') {
event.sourceEvent.messaging_type = 'RESPONSE';
}
next();
}
I do not receive any error from FB platform, but I'm not sure if the message is sent including the new field. Do you know where I can see the final format of the request sent to FB API?

@advl03 Viewing the message sent by the connector services to FB Api is not currently a feature.

Closing this issue. Messenger feature requests are tracked here: https://github.com/Microsoft/BotBuilder/issues/4360 (I've referenced this one there)

Note: Message tags can be done with the Bot Builder by using Channel Data:

dot net sdk:

activity.ChannelData = JObject.FromObject(new { tag = "APPLICATION_UPDATE", messaging_type = "MESSAGE_TAG" });

node sdk:

   let msg = new builder.Message(session).sourceEvent({ facebook: {         
      "messaging_type": "MESSAGE_TAG",
      "tag": "NON_PROMOTIONAL_SUBSCRIPTION",
      "text": "Hello Facebook!"
    } });

With the help of the comments above I have finally solved this for anyone looking for any further help. @EricDahlvang's post above re-inspired me to look at this again and it works. I have posted the details on Stack Overflow here:
https://stackoverflow.com/questions/49082513/microsoft-bot-framework-how-to-set-facebook-message-tag

Thanks :-)

Was this page helpful?
0 / 5 - 0 ratings