Skip to content

Commit

Permalink
Merge pull request #63 from amio-io/add_voice_upload
Browse files Browse the repository at this point in the history
feat: added support for voice command
  • Loading branch information
karelrochelt authored Jan 10, 2022
2 parents b6bb557 + 9600b96 commit f2111be
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
13 changes: 13 additions & 0 deletions lib/amio-chat-sdk-web.js

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

2 changes: 1 addition & 1 deletion lib/amio-chat-sdk-web.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/amio-chat-sdk-web.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/amio-chat-sdk-web.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amio-chat-sdk-web",
"version": "1.5.0",
"version": "1.5.1",
"description": "Amio Chat JavaScript SDK for custom webchat implementation. https://amio.io",
"main": "lib/amio-chat-sdk-web.js",
"module": "src/amio-chat-client.js",
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
SOCKET_LIST_MESSAGES: 'list_messages',
SOCKET_POSTBACK: 'postback',
SOCKET_FILE_UPLOAD: 'file_upload',
SOCKET_VOICE_UPLOAD: 'voice',

ERROR_CODE_CHANNEL_ID_CHANGED: 1,

Expand Down
16 changes: 15 additions & 1 deletion src/files.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import connection from './connection/connection'
import {
SOCKET_FILE_UPLOAD
SOCKET_FILE_UPLOAD,
SOCKET_VOICE_UPLOAD
} from './constants'

class Files {
Expand All @@ -19,6 +20,19 @@ class Files {
})
}

uploadVoice(mimeType, binaryData) {
return new Promise((resolve, reject) => {
const data = {
mime_type: mimeType,
content_buffer: Buffer.from(binaryData)
}

connection.emit(SOCKET_VOICE_UPLOAD, data)
.then(resolve)
.catch(reject)
})
}

}

export default new Files()

0 comments on commit f2111be

Please sign in to comment.