Skip to content

Instantly share code, notes, and snippets.

@ouadie-lahdioui
Last active July 13, 2018 08:25
Show Gist options
  • Save ouadie-lahdioui/ecd6101ede73ed31c14dfaab73ceadb2 to your computer and use it in GitHub Desktop.
Save ouadie-lahdioui/ecd6101ede73ed31c14dfaab73ceadb2 to your computer and use it in GitHub Desktop.
// Buttons
Builder.CardAction.imBack(session, "1", "Trouver un emploi")
new builder.CardAction(session).title('Add a number').value('Add').type('imBack')
Builder.CardAction.dialogAction(session, "weather", "Seattle, WA", "Current Weather")
Builder.CardAction.postBack(...)
// Send Attachement
var msg = session.message;
var attachment = msg.attachments[0];
session.send({
text: "You sent:",
attachments: [{
contentType: attachment.contentType,
contentUrl: attachment.contentUrl,
name: attachment.name
}]
});
//detect Facebook Messenger message here
if (session.message.address.channelId === "facebook")
//create a facebook share button using sourceEvent
var msg = new botbuilder.Message(session).sourceEvent({
//specify the channel
facebook: {
//format according to channel's requirements
//(in our case, the above JSON required by Facebook)
attachment: {
type: "template",
payload: {
template_type: "generic",
elements: [
{
title: "Microsoft Bot Framework",
subtitle: "Check it out!",
buttons: [
{
type: "web_url",
url: "https://dev.botframework.com",
title: "Go to Dev Portal"
},
{
//this is our share button
type: "element_share"
}
]
}
]
}
} //end of attachment
}
});
// Prompts
var choices = [{ value: 'en', title: "English" },{ value: 'es', title: "Español" }];
builder.Prompts.choice(session, "Please select your preferred language.", choices);
builder.Prompts.choice(session, "What's your preferred language?", 'English|Español|Italiano');
// Session
session.error(err);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment