Cards are not shown when sent in a resolving Promise on ConsoleConnector
Hi! I'm using Node.js library version 3.1.1.
I'm facing problems on my app, so I did a quick test as a POC to help replicate it.
I copied the Skype Bot example for sending a ThumbnailCard (/actions, /weather and .beginDialogAction calls as well)
Also, I added a self-resolving promise. Something like what's below. And the card is not sent on ConsoleConnector. But it works on ChatConnector (testing on Facebook).
` Promise.all([ new Promise((done, reject) => { setTimeout(done, 1000); }), new Promise((done, reject) => { setTimeout(done, 2000); }), new Promise((done, reject) => { setTimeout(done, 3000); })
]).then((body) => {
var msg = new builder.Message(session)
.textFormat(builder.TextFormat.xml)
.attachments([
new builder.ThumbnailCard(session)
.title("Hero Card")
.subtitle("Space Needle")
.text("The <b>Space Needle</b> is an observation tower in Seattle, Washington, a landmark of the Pacific Northwest, and an icon of Seattle.")
.images([
builder.CardImage.create(session, "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Seattlenighttimequeenanne.jpg/320px-Seattlenighttimequeenanne.jpg")
])
.buttons([
builder.CardAction.dialogAction(session, "weather", "Seattle, WA", "Current Weather")
])
]);
session.send(msg);
});
`
To be fair... no cards are being displayed on ConsoleConnector...
Any input on this?
This is quite frustrating, as I need to send a card based on the response of a WebService call.
Ever since I implemented it, I can't use the ConsoleConnector to debug my code, and I have to push my code live and test it on Facebook...
@Stevenic is the expert on this, but I do not think the SDK supports setTimeout / closures / promises in this way. Are you trying to "proactively" message your user, at a later time?
It's not proactive. I fire a http request and build a sentence out of its answer. So I need to send a message inside a promise.
That works fine with Facebook (UniversalConnector) but not with ConsoleConnector
On 12 Aug 2016 19:51, "Dan Marshall" [email protected] wrote:
@Stevenic https://github.com/Stevenic is the expert on this, but I do not think the SDK supports setTimeout / closures / promises in this way. Are you trying to "proactively" message your user, at a later time?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/761#issuecomment-239578468, or mute the thread https://github.com/notifications/unsubscribe-auth/ACGGJ5tRoJEHkLI8wSjQaLhZ9e-WuNpdks5qfPjWgaJpZM4JQNiX .
I just took a pull request which should fix this. There were a couple of bugs in the ConsoleConnector related to this. It wasn't properly calling done()
Closing this issue. If it's not fixed, please either open a new issue or reply to this one asking to reopen. thanks!
Hi! Has it been released? I'm still facing this as of version 3.2.3.
Example code:
/*Building the card*/
const message = new ZipController.builder.Message(session);
message
.textFormat(ZipController.builder.TextFormat.plain)
.attachments([
new ZipController.builder.ThumbnailCard(session)
.title("[[Text]]")
.subtitle("[[Subtitle]]")
.buttons([
ZipController.builder.CardAction.postBack(session, "sim", "sim"),
ZipController.builder.CardAction.postBack(session, "não", "não")
])
]);
/*Simulating call to external service and sending card when the request is finished*/
new Promise((res) => {
setTimeout(()=>res(), 1000);
}).then(()=>{
console.log("sent");
builder.Prompts.choice(session, message, "sim|não");
});
I get "sent" printed on the console, but no card.
Sorry... It has now. Check the latest 3.3 release.