Last active
October 23, 2018 07:32
-
-
Save eblancoh/09918c42cc49bd136a36919d6d7c424c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bot.dialog('locationfavorites', [ | |
(session, results, next) => { | |
var msg = new builder.Message(session) | |
.text("¿Desea seleccionar una localización predeterminada? Si no, diga o escriba 'no'") | |
.suggestedActions( | |
builder.SuggestedActions.create( | |
session, [ | |
builder.CardAction.postBack(session, "orense_madrid", "Casa"), | |
builder.CardAction.postBack(session, "gran_via", "Trabajo"), | |
builder.CardAction.postBack(session, "distrito_telefonica", "Distrito"), | |
builder.CardAction.postBack(session, "paseo_chopera", "eSports"), | |
builder.CardAction.postBack(session, "plaza_castilla", "Plaza de Castilla") | |
] | |
)); | |
builder.Prompts.choice(session, msg, ["orense_madrid", "gran_via", "distrito_telefonica", "paseo_chopera", "plaza_castilla"]); | |
next(); | |
}, | |
(session, results, next) => { | |
if (results.response) { | |
session.dialogData.place = {streetAddress: results.response.entity}; | |
var direction = "" | |
switch(results.response.entity) { | |
case "gran_via": | |
direction = "Calle Gran Vía, 32, Madrid, Comunidad de Madrid, España"; | |
break; | |
case "orense_madrid": | |
direction = "Calle Orense, 21, Madrid, Comunidad de Madrid, España"; | |
break; | |
case "distrito_telefonica": | |
direction = "Distrito Telefónica, Madrid, Comunidad de Madrid, España"; | |
break; | |
case "paseo_chopera": | |
direction = "Paseo de la Chopera, Madrid, Comunidad de Madrid, España"; | |
break; | |
case "plaza_castilla": | |
direction = "Plaza de Castilla, Madrid, Comunidad de Madrid, España"; | |
break; | |
default: | |
direction = "Calle Gran Vía, 32, Madrid, Comunidad de Madrid, España"; | |
break; | |
} | |
session.send('Se ha seleccionado la dirección: ' + direction) | |
} else { | |
session.cancelDialog(); | |
} | |
session.endDialogWithResult({ response: session.dialogData.place }); | |
}, | |
]); | |
bot.localePath(path.join(__dirname, './locale')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment