Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Properties:
Prompt types can be one of:

* `text` [default] - Prompts for free text. This options is set in case no `type` property is provided
* `multiprompt` - Prompts for free text or an attachment.
* `number` - Request for a valid number
* `time` - Request for a time construct like "2 hours ago", "yesterday", etc.
* `confirm` - Yes \ No
Expand Down
29 changes: 23 additions & 6 deletions lib/GraphDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var Node = require('./Node');
var IntentScorer = require('./IntentScorer');
var Common = require('./Common');
var Validator = require('./Validator');
var multiPrompt = require('botframework_multiprompt');

// the GraphDialog class manages the dialog's state
class GraphDialog {
Expand Down Expand Up @@ -106,6 +107,7 @@ class GraphDialog {
// this is where the magic happens. loops this list of steps for each node.
setBotDialog() {
var _this = this;
this.options.bot.dialog('multiPrompt', multiPrompt.multiPrompt);
this.options.bot.dialog(this.internalPath, [
async (session, args, next) => {
session.dialogData.data = args || {};
Expand Down Expand Up @@ -153,6 +155,14 @@ class GraphDialog {
var promptType = currentNode.data.type || 'text';
currentNode.data.options = currentNode.data.options || {};

//replace handlebars
currentNode.data.text = strformat(currentNode.data.text, session.dialogData.data);
for(var i = 0; i < currentNode.data.options.length; i++){
if (typeof(currentNode.data.options[i] == 'string')){
currentNode.data.options[i] = strformat(currentNode.data.options[i], session.dialogData.data);
}
}

var listStyle = (currentNode.data.config
&& currentNode.data.config.listStyle
&& builder.ListStyle[currentNode.data.config.listStyle])
Expand All @@ -162,7 +172,14 @@ class GraphDialog {
currentNode.data.options.listStyle = listStyle;
}

builder.Prompts[promptType](session, currentNode.data.text, currentNode.data.options, { listStyle });
if (currentNode.data.type == 'multiprompt'){
//handle multiprompt
builder.Prompts.multiPrompt = multiPrompt.multiPromptsLauncher;
multiPrompt.multiPromptsLauncher(session, currentNode.data.text );
} else{
builder.Prompts[promptType](session, currentNode.data.text, currentNode.data.options, { listStyle });
}

break;

case Node.NodeType.score:
Expand Down Expand Up @@ -226,20 +243,20 @@ class GraphDialog {
generateHeroCard(session, data) {
var hero = new builder.HeroCard(session);

if (data.title) hero.title(data.title);
if (data.subtitle) hero.subtitle(data.subtitle);
if (data.text) hero.text(data.text);
if (data.title) hero.title(strformat(data.title, session.dialogData.data));
if (data.subtitle) hero.subtitle(strformat(data.subtitle, session.dialogData.data));
if (data.text) hero.text(strformat(data.text, session.dialogData.data));

if (data.images && data.images.length > 0) {
hero.images([
builder.CardImage.create(session, data.images[0])
builder.CardImage.create(session, strformat(data.images[0], session.dialogData.data))
]);
}

if (data.tap) {
switch (data.tap.action) {
case "openUrl":
hero.tap(builder.CardAction.openUrl(session, data.tap.value));
hero.tap(builder.CardAction.openUrl(session, strformat(data.tap.value, session.dialogData.data)));
break;
}
}
Expand Down
28 changes: 27 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"homepage": "https://github.com/CatalystCode/bot-graph-dialog#readme",
"dependencies": {
"botbuilder": "^3.8.4",
"botframework_multiprompt": "^1.0.3",
"extend": "^3.0.0",
"jsep": "^0.3.0",
"request-promise": "^4.1.1",
Expand Down