Skip to content

Commit

Permalink
Merge branch 'AE-2110_agent_file_sharing'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eden Kupermintz committed Jun 11, 2019
2 parents 98996e6 + 61b5f58 commit 1b8847e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pages/documents/AgentExperience/AgentWorkspaceWidgetSDK/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ _Note: The updateCallback must be the same callback provided for the bind._
| "Write ChatLine" | write text to the chat input. In real-time chat the text should be sent in **HTML** format, in async messaging conversation in **plain text** format.| lpTag.agentSDK.cmdNames.write | {text: "text to write", quickReplies: {...}} <br><br> quickReplies is optional. |
| "Write StructuredContent" | send structured content | lpTag.agentSDK.cmdNames.writeSC | {json: {...}, quickReplies: {...}, metadata: [...]} <br><br> quickReplies and matadata are optional |
| "Send Notification" | send notification | lpTag.agentSDK.cmdNames.notify | {} |
| "Send File" | send a file. Supported by async messaging only. | lpTag.agentSDK.cmdNames.sendFile | {file: {...//File or Blob}, name: "name_of_file.png"} |

<div class="important">Two permissions exist that pertain to file sharing: one for sharing files directly from your file system and one for sharing files from a custom widget. The API checks that at least <b>one</b> of these permissions is enabled. This means that a user with permissions to send files from a custom widget only could theoretically still use this API to send files directly from their file system</div>

Example 1 - 'Write ChatLine':

Expand Down Expand Up @@ -371,6 +374,34 @@ Example 5 - 'Send Notification':
}
```

Example 6 - 'Send File':

```javascript
{
var notifyWhenDone = function(err) {
if (err) {
// Do something with the error
}
// called when the command is completed successfully,
// or when the action terminated with an error.
};

var cmdName = "Send File";
var url = 'https://some/url/to/a/file.png';
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function (ev) {
if (this.status === 200) {
var file = this.response;
var name = url.split('\\').pop().split('/').pop();
lpTag.agentSDK.command(cmdName, {file: file, name: name}, notifyWhenDone);
}
};
xhr.send();
}
```

*Note: notifyWhenDone is an optional callback.*

### dispose
Expand Down

0 comments on commit 1b8847e

Please sign in to comment.