Skip to content

Commit 5b817cb

Browse files
author
Botium
authored
Merge pull request #13 from codeforequity-at/feature/BOT-487-directline-add-support-for-form
feature/BOT-487-directline-add-support-for-form
2 parents a4c4df8 + b1d48b9 commit 5b817cb

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,3 @@ _Default: false_
113113
Botium simulates conversations with username _me_. Depending on your implementation, running multiple conversations with the same username could make them fail (for example, session handling).
114114

115115
Setting this capability to _true_ will generate a new username (uuid) for each conversation.
116-
117-
## Open Issues and Restrictions
118-
119-
* Media Attachments currently cannot be sent, as Node.js environment is [not fully supported by DirectLine](https://github.com/Microsoft/BotFramework-DirectLineJS/issues/107)

index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const util = require('util')
12
const uuidv4 = require('uuid/v4')
23
const mime = require('mime-types')
34
const _ = require('lodash')
@@ -212,6 +213,13 @@ class BotiumConnectorDirectline3 {
212213
activity.text = msg.messageText
213214
}
214215

216+
if (msg.forms) {
217+
activity.value = {}
218+
msg.forms.forEach(f => {
219+
activity.value[f.name] = f.value
220+
})
221+
}
222+
215223
if (msg.media && msg.media.length > 0) {
216224
debug('Posting activity with attachments ', JSON.stringify(activity, null, 2))
217225
const formData = new FormData()
@@ -248,12 +256,16 @@ class BotiumConnectorDirectline3 {
248256
},
249257
body: formData
250258
}).catch(err => {
251-
debug('Error posting activity', err)
259+
debug('Error posting activity with attachments', err)
252260
reject(new Error(`Error posting activity: ${err}`))
253261
}).then(async (res) => {
254262
const json = await res.json()
255-
debug('Posted activity, assigned ID:', json.id)
256-
resolve()
263+
if (json.id) {
264+
debug('Posted activity with attachments, assigned ID:', json.id)
265+
resolve()
266+
} else {
267+
reject(new Error(`Error posting activity with attachments: ${util.inspect(json)}`))
268+
}
257269
})
258270
} else {
259271
debug('Posting activity ', JSON.stringify(activity, null, 2))

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.9",
3+
"version": "0.0.10",
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
form
2+
3+
#me
4+
BUTTON card inputs
5+
6+
#bot
7+
Welcome to Mockbot v4!
8+
9+
#bot
10+
BUTTONS Open Url|Submit|Show Card
11+
12+
#me
13+
FORM SimpleVal|myname
14+
FORM UrlVal|myhomepage
15+
FORM EmailVal|myemail
16+
FORM CompactSelectVal|2
17+
FORM MultiSelectVal|1;2
18+
FORM IsCool
19+
20+
#bot
21+
You posted

0 commit comments

Comments
 (0)