Skip to content

Commit 8047646

Browse files
author
Botium
authored
Merge pull request #25 from codeforequity-at/develop
Release 0.0.14
2 parents e9300df + 27e7040 commit 8047646

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ class BotiumConnectorDirectline3 {
136136
} else if (a.contentType === 'application/vnd.microsoft.card.adaptive') {
137137
const textBlocks = this._deepFilter(a.content.body, (t) => t.type, (t) => t.type === 'TextBlock')
138138
const imageBlocks = this._deepFilter(a.content.body, (t) => t.type, (t) => t.type === 'Image')
139+
const buttonBlocks = this._deepFilter(a.content.body, (t) => t.type, (t) => t.type.startsWith('Action.'))
139140

140141
botMsg.cards.push({
141142
text: textBlocks && textBlocks.map(t => t.text),
142143
image: imageBlocks && imageBlocks.length > 0 && mapImage(imageBlocks[0]),
143-
buttons: a.content.actions && a.content.actions.map(mapButton)
144+
buttons: ((a.content.actions && a.content.actions.map(mapButton)) || []).concat((buttonBlocks && buttonBlocks.map(mapButton)) || [])
144145
})
145146
} else if (a.contentType === 'application/vnd.microsoft.card.animation' ||
146147
a.contentType === 'application/vnd.microsoft.card.audio' ||
@@ -243,9 +244,7 @@ class BotiumConnectorDirectline3 {
243244
UserSays (msg) {
244245
debug('UserSays called')
245246
return new Promise(async (resolve, reject) => {
246-
const activity = {
247-
from: { id: this.me }
248-
}
247+
const activity = msg.sourceData || {}
249248
if (msg.buttons && msg.buttons.length > 0 && (msg.buttons[0].text || msg.buttons[0].payload)) {
250249
let payload = msg.buttons[0].payload || msg.buttons[0].text
251250
try {
@@ -255,13 +254,16 @@ class BotiumConnectorDirectline3 {
255254
activity.type = this.caps[Capabilities.DIRECTLINE3_BUTTON_TYPE]
256255
activity[this.caps[Capabilities.DIRECTLINE3_BUTTON_VALUE_FIELD]] = payload
257256
} else {
258-
if (msg.sourceData && msg.sourceData.type) {
259-
activity.type = msg.sourceData.type
260-
} else {
257+
if (!activity.type) {
261258
activity.type = 'message'
262259
}
263260
activity.text = msg.messageText
264261
}
262+
if (!activity.from) {
263+
activity.from = { id: this.me }
264+
} else if (!activity.from.id) {
265+
activity.from.id = this.me
266+
}
265267

266268
if (msg.forms) {
267269
activity.value = {}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "botium-connector-directline3",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"description": "Botium Connector for Bot Framework Direct Line 3 API",
55
"main": "dist/botium-connector-directline3-cjs.js",
66
"module": "dist/botium-connector-directline3-es.js",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
adaptive
2+
3+
#me
4+
BUTTON card bingsports
5+
6+
#bot
7+
Welcome to Mockbot v4!
8+
9+
#bot
10+
BUTTONS Image action|Column action|Container action

0 commit comments

Comments
 (0)