Closed ambrishverma closed 7 years ago
Try sending a native Facebook message via .sourceEvent()
Thanks @craigjensen . I replaced the above code with SourceEvent() as shown below but it does not seem to send anything to FB Messenger. Any suggestions what might be wrong here:
msg = new builder.Message(session) msg.sourceEvent({ facebook: { "type":"template", "payload":{ "template_type":"generic", "elements":[{ "title": titleStr, "subtitle": contentStr, "image_url":"https://thechangreport.com/img/lightning.png", "buttons":[{ "type":"element_share" }] }] } } session.send(msg);
Try changing "facebook" to "attachment" as follows:
msg = new builder.Message(session) msg.sourceEvent({ "attachment": { "type":"template", "payload":{ "template_type":"generic", "elements":[{ "title": titleStr, "subtitle": contentStr, "image_url":"https://thechangreport.com/img/lightning.png", "buttons":[{ "type":"element_share" }] }] } }}); session.send(msg);
Thanks again @craigjensen . I still don't get any message. I think I might be missing something basic here as I tried many different messages via .SourceEvent() but none of them showed up.
got this to work. It needed both "facebook" and then "attachment" Here is the working code:
msg = new builder.Message(session);
msg.sourceEvent({
facebook: {
attachment:{
type:"template",
payload:{
template_type:"generic",
elements:[{
title:"title",
subtitle:"context",
image_url:"https://en.wikipedia.org/wiki/Space_Needle.jpg",
item_url: "http://m.me",
buttons:[{
type:"element_share"
}]
}]
}
}
}
});
Hello, I have the same concern but with c#. How I can make to add 'Share Button' in CardAction ? Thanks for your help. Junior
I guess you can follow the same, Try sending a native Facebook message via .sourceEvent() . Sample code above.
@ambrishverma I do also want to make this working on C# but I cannot find the .sourceEvent() method
Look for ChannelData in c#
Ok, this works:
dynamic messageData = new JObject();
messageData.attachment = new JObject();
messageData.attachment.type = "template";
messageData.attachment.payload = new JObject();
messageData.attachment.payload.template_type = "generic";
messageData.attachment.payload.elements
= new JArray(
new JObject(
new JProperty("title", "hola"),
new JProperty("subtitle", "Mundo"),
new JProperty("buttons",
new JArray(
new JObject(
new JProperty("type", "element_share")
)
)
)
)
);
replyToConversation.ChannelData = messageData;
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
await connector.Conversations.ReplyToActivityAsync(replyToConversation);
@ambrishverma Hello Ambrish, I want add share button in Thumbnail card in how can i achieve it? please check see the attachment.
How do you add a share button on plain text or a quick reply? Not interested for hero cards and carousels
@slidenerd have you tried with a quick reply button with the type set to "type:"element_share"" ?
@fercom I have posted answer for above question on stack overflow please refer below link for more details, https://stackoverflow.com/questions/44195271/share-button-in-facebook-chatbot-in-node-js/44968612#44968612
Hi There, I am using Node.js botFramework to create a bot for Facebook Messenger platform. I am not able to figure out how to I create a "Share" button (as explained here: https://developers.facebook.com/docs/messenger-platform/send-api-reference/share-button ) .
I tried to pass the button type "element_share" as following but it didn't work:
I'd appreciate if any suggestions on this.