This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Add task module samples #65
Open
nehasahu1505
wants to merge
1
commit into
master
Choose a base branch
from
taskmodule
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Task Module Ids | ||
// tslint:disable-next-line:variable-name | ||
export const TaskModuleTitles = { | ||
AdaptiveCardSingleStepTitle: "Post command to bot using single step adaptive card", | ||
AdaptiveCardMultiStepTitle: "Post command to bot using multi step adaptive card", | ||
ActionSubmitResponseTitle: "Action.Submit Response", | ||
SingleStepHtmlCardTitle: "Post Command to bot using single step html card", | ||
MultistepHtmlCardTitle: "Post Command to bot using multistep html card", | ||
}; | ||
|
||
// Task Module Ids | ||
// tslint:disable-next-line:variable-name | ||
export const TaskModuleIds = { | ||
CustomForm: "customform", | ||
}; | ||
|
||
// Task Module Sizes | ||
// tslint:disable-next-line:variable-name | ||
export const TaskModuleSizes = { | ||
customform: { | ||
width: 510, | ||
height: 500, | ||
}, | ||
adaptivecard: { | ||
width: 700, | ||
height: 255, | ||
}, | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
|
||
import * as constants from "../../constants"; | ||
import { renderACAttachment } from "../../utils/CardUtils"; | ||
import * as config from "config"; | ||
|
||
// Function that works both in Node (where window === undefined) or the browser | ||
export function appRoot(): string { | ||
if (typeof window === "undefined") { | ||
return config.get("app.baseUri"); | ||
} else { | ||
return window.location.protocol + "//" + window.location.host; | ||
} | ||
} | ||
|
||
export const cardTemplates: any = { | ||
adaptiveCard: { | ||
"type": "AdaptiveCard", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"separator": true, | ||
"size": "Large", | ||
"weight": "Bolder", | ||
"text": "Enter Command:", | ||
"isSubtle": true, | ||
"wrap": true, | ||
}, | ||
{ | ||
"type": "Input.Text", | ||
"id": "commandToBot", | ||
"placeholder": "E.g. timezone", | ||
}, | ||
], | ||
"actions": [ | ||
{ | ||
"type": "Action.Submit", | ||
"id": "postCommand", | ||
"title": "Post Command", | ||
"data": { | ||
"taskResponse": "{{responseType}}", | ||
}, | ||
}, | ||
{ | ||
"type": "Action.Submit", | ||
"id": "cancel", | ||
"title": "Cancel", | ||
}, | ||
], | ||
"version": "1.0", | ||
}, | ||
adaptiveCardSubmitResponse: { | ||
"type": "AdaptiveCard", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"weight": "Bolder", | ||
"text": "Action.Submit Results", | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"separator": true, | ||
"size": "Medium", | ||
"text": "{{results}}", | ||
"wrap": true, | ||
}, | ||
], | ||
"actions": [ | ||
{ | ||
"type": "Action.Submit", | ||
"title": "OK", | ||
"data": { | ||
"taskResponse": "final", | ||
"taskModule": "acResponse", | ||
}, | ||
}, | ||
], | ||
"version": "1.0", | ||
}, | ||
}; | ||
|
||
export const fetchTemplates: any = { | ||
adaptivecardsinglestep: { | ||
"task": { | ||
"type": "continue", | ||
"value": { | ||
"title": constants.TaskModuleTitles.AdaptiveCardSingleStepTitle, | ||
"height": constants.TaskModuleSizes.adaptivecard.height, | ||
"width": constants.TaskModuleSizes.adaptivecard.width, | ||
// Below wraps it as a builder.Attachment | ||
"card": renderACAttachment(cardTemplates.adaptiveCard, { responseType: "message" }), | ||
}, | ||
}, | ||
}, | ||
adaptivecardmultistep: { | ||
"task": { | ||
"type": "continue", | ||
"value": { | ||
"title": constants.TaskModuleTitles.AdaptiveCardMultiStepTitle, | ||
"height": constants.TaskModuleSizes.adaptivecard.height, | ||
"width": constants.TaskModuleSizes.adaptivecard.width, | ||
"fallbackUrl": null, | ||
// Below wraps it as a builder.Attachment | ||
"card": renderACAttachment(cardTemplates.adaptiveCard, { responseType: "continue" }), | ||
}, | ||
}, | ||
}, | ||
|
||
singlestephtmlcard: { | ||
"task": { | ||
"type": "continue", | ||
"value": { | ||
"title": constants.TaskModuleTitles.SingleStepHtmlCardTitle, | ||
"height": constants.TaskModuleSizes.customform.height, | ||
"width": constants.TaskModuleSizes.customform.width, | ||
"fallbackUrl": `${appRoot()}/${constants.TaskModuleIds.CustomForm}?type=singlestep`, | ||
"url": `${appRoot()}/${constants.TaskModuleIds.CustomForm}?type=singlestep`, | ||
}, | ||
}, | ||
}, | ||
multistephtmlcard: { | ||
"task": { | ||
"type": "continue", | ||
"value": { | ||
"title": constants.TaskModuleTitles.MultistepHtmlCardTitle, | ||
"height": constants.TaskModuleSizes.customform.height, | ||
"width": constants.TaskModuleSizes.customform.width, | ||
"fallbackUrl": `${appRoot()}/${constants.TaskModuleIds.CustomForm}?type=multistep`, | ||
"url": `${appRoot()}/${constants.TaskModuleIds.CustomForm}?type=multistep`, | ||
}, | ||
}, | ||
}, | ||
submitMessageResponse: { | ||
"task": { | ||
"type": "message", | ||
"value": "Task completed!", | ||
}, | ||
}, | ||
|
||
submitResponse: { | ||
"task": { | ||
"type": "continue", | ||
"value": { | ||
"title": constants.TaskModuleTitles.ActionSubmitResponseTitle, | ||
"height": "small", | ||
"width": "medium", | ||
"card": {}, | ||
}, | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add comments here (in each "case" block") explaining conceptually what these invokes mean and how we respond to them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also mention which properties are standard from the framework, and which ones you added. For example, "taskModule" is something that you added in the "data" field of the adaptive card action. I'd like this to be clear because it's hard, when reading a sample, to separate what comes from the framework and what the developer added herself.