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

fix: Cast Text and Speak to string format #3844

Merged
merged 4 commits into from
Jul 2, 2021
Merged
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
6 changes: 6 additions & 0 deletions libraries/botbuilder-core/src/activityFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ export class ActivityFactory {
const value: any = messageValue[key];

switch (property.toLowerCase()) {
case 'text':
activity.text = typeof value === 'string' ? value : JSON.stringify(value);
break;
case 'speak':
activity.speak = typeof value === 'string' ? value : JSON.stringify(value);
break;
case 'attachments':
activity.attachments = this.getAttachments(value);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ function assertActivityWithHeroCardAttachment(activity) {
function assertCustomizedActivityType(activity) {
assert.strictEqual(activity.type, 'xxx');
assert.strictEqual(activity.name, 'hi');
assert.strictEqual(activity.text, '{"a":"b"}');
assert.strictEqual(activity.speak, '{"c":"d"}');
}

function assertHandoffActivity(activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]

# HeroCardTemplate(type)
[HeroCard
[HeroCard
title=Cheese gromit!
subtitle=${type}
text=This is some text describing the card, it's cool because it's cool
Expand All @@ -32,7 +32,7 @@
]

# ThumbnailCardTemplate(type)
[ThumbnailCard
[ThumbnailCard
title=Cheese gromit!
subtitle=${type}
text=This is some text describing the card, it's cool because it's cool
Expand Down Expand Up @@ -95,7 +95,7 @@
# AnimationCardTemplate
[AnimationCard
Title=Animation Card
Subtitle=look at it animate
Subtitle=look at it animate
autostart=true
autoloop=${true}
Image= ${{url:'https://docs.microsoft.com/en-us/bot-framework/media/how-it-works/architecture-resize.png'}}
Expand All @@ -117,6 +117,8 @@

# customizedActivityType
[Activity
text = ${{a:'b'}}
speak= ${{c:'d'}}
type = xxx
Name = hi
]
Expand Down Expand Up @@ -224,7 +226,7 @@
]

# SuggestedActionsReference(text)
[ Activity
[ Activity
Text = ${text}
${WelcomeActions()}
]
Expand Down Expand Up @@ -412,4 +414,4 @@
}
]
}
```
```