Hello,
I have a problem, i must task offered Microsoft one in this offered framework make and which offered shall distribute merry-go-round in the result of Hero Cards, he does this I must incredibly, now make the results “click cash” or insert a badge, too, however, the result gets callable perhaps in a new one.
The second problem is, how I can think offered in Facebook insert
Sorry, for the many questions I am a greenhorn in this area: -)
Best from Munich
Flo
var rp = require("request-promise");
var builder = require("botbuilder");
var restify = require("restify");
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function() {
console.log("%s listening to %s", server.name, server.url);
});
var connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
// Eingabe des Benutzers empfangen
server.post("/api/messages", connector.listen());
var bot = new builder.UniversalBot(connector, [
function(session) {
session.send(
"Hey ich helfe dir bei der Jobsuche!"
);
session.beginDialog("askForjob");
}
]);
// Dialog um nach dem Job zu fragen
bot.dialog("askForjob", [
function(session) {
session.dialogData.query = {};
builder.Prompts.text(
session,
"Gib mir ein Stichwort nach welchem Job Ich suchen soll"
);
},
function(session, results, next) {
if (results.response) {
session.dialogData.query.keyword = results.response;
builder.Prompts.text(
session,
`Wo soll ich für Dich nach ${session.dialogData.query.keyword} suchen?`
);
} else {
next();
}
},
function(session, results) {
if (results.response) {
session.dialogData.query.location_label = results.response;
session.send(
`Ich habe in ${session.dialogData.query.location_label} nach ${session
.dialogData.query.keyword} gesucht, dass habe ich gefunden :`
);
var options = {
uri: `https://jnprod.herokuapp.com/v1/b2c/jobs?keywords=${session
.dialogData.query.keyword}&location;_label=${session.dialogData.query
.location_label}&per_page=10`,
json: true
};
rp(options).then(res => {
//session.send(res.jobs.map(e => e.title).join("<br/>"))
var attachments = res.jobs.map((e)=> {
return new builder.HeroCard(session)
.title(e.title)
.subtitle(e.city)
.text(e.description.substring(0,100))
.images([
builder.CardImage.create(
session,
e.picture_url
)
])
})
var msg = new builder.Message(session);
msg.attachmentLayout(builder.AttachmentLayout.carousel);
msg.attachments(attachments);
session.send(msg).endDialog();
});
}
}
]);