Posts

Showing posts from September, 2017

Generate "session" object using bot.loadSession()

I need to send a reminder message within a function which outside "bot.dialog()". This function is triggered by a HTTP post event and so no "session" parameter will be passed in. I want to create a "HeroCard" message which needs "session" object. I search around in google and then found out the solution which is using "bot.loadSession()". You need to pass in the message address (session.message.address) to this function. The sample code is as below: var msg = new builder.Message().address(address); bot.loadSession(address, (error, session) => {  msg.attachments([  new builder.HeroCard(session)  .title(title)  .text("XXXXX")  .images([builder.CardImage.create(session, "imageURL")])  .buttons([ builder.CardAction.openUrl(session, "actionURL", "XXXX") ]) ]);  session.send(msg); });