|
| 1 | + |
| 2 | +var builder = require('../../../'); |
| 3 | + |
| 4 | +module.exports = { |
| 5 | + description: "Lets you manually test each built-in prompt.", |
| 6 | + async: true, |
| 7 | + addDialogs: addDialogs, |
| 8 | + run: run |
| 9 | +}; |
| 10 | + |
| 11 | +function addDialogs(bot) { |
| 12 | + bot.add('/tests/prompts', [ |
| 13 | + function (session) { |
| 14 | + session.send("Starting test. Just answer each prompt and your answer will be echoed back to you."); |
| 15 | + builder.Prompts.text(session, "text: enter some text."); |
| 16 | + }, |
| 17 | + function (session, results) { |
| 18 | + if (results && results.response) { |
| 19 | + session.send("You entered '%s'", results.response); |
| 20 | + builder.Prompts.number(session, "number: enter a number."); |
| 21 | + } else { |
| 22 | + session.endDialog("You canceled."); |
| 23 | + } |
| 24 | + }, |
| 25 | + function (session, results) { |
| 26 | + if (results && results.response) { |
| 27 | + session.send("You entered '%s'", results.response); |
| 28 | + builder.Prompts.choice(session, "choice: choose a list style.", "auto|inline|list|button|none"); |
| 29 | + } else { |
| 30 | + session.endDialog("You canceled."); |
| 31 | + } |
| 32 | + }, |
| 33 | + function (session, results) { |
| 34 | + if (results && results.response) { |
| 35 | + var style = builder.ListStyle[results.response.entity]; |
| 36 | + builder.Prompts.choice(session, "choice: now pick an option.", "option A|option B|option C", { listStyle: style }); |
| 37 | + } else { |
| 38 | + session.endDialog("You canceled."); |
| 39 | + } |
| 40 | + }, |
| 41 | + function (session, results) { |
| 42 | + if (results && results.response) { |
| 43 | + session.send("You chose '%s'", results.response.entity); |
| 44 | + builder.Prompts.confirm(session, "confirm: is this test going well?"); |
| 45 | + } else { |
| 46 | + session.endDialog("You canceled."); |
| 47 | + } |
| 48 | + }, |
| 49 | + function (session, results) { |
| 50 | + if (results && results.response) { |
| 51 | + session.send("You chose '%s'", results.response ? 'yes' : 'no'); |
| 52 | + builder.Prompts.time(session, "time: enter a time."); |
| 53 | + } else { |
| 54 | + session.endDialog("You canceled."); |
| 55 | + } |
| 56 | + }, |
| 57 | + function (session, results) { |
| 58 | + if (results && results.response) { |
| 59 | + session.endDialog("Recognized Entity: %s", JSON.stringify(results.response)); |
| 60 | + } else { |
| 61 | + session.endDialog("You canceled."); |
| 62 | + } |
| 63 | + } |
| 64 | + ]); |
| 65 | +} |
| 66 | + |
| 67 | +function run(session) { |
| 68 | + session.beginDialog('/tests/prompts'); |
| 69 | +} |
0 commit comments