This site is no longer updated.Go to new Conversational Cloud docs

fileEvent


The fileEvent event occurs when the client sends a message with an attachment. A JSON object containing the content type, the link to the file being sent and other metadata is submitted in eventData.

fileEvent is supported by all inbound channels, except JivoChat, Zendesk, and Zendesk Chat.

eventData

The eventData format:

[
   {
      "url": "https://fileUrl_example_path/",
      "type": "file",
      "mimeType": "text/x-log",
      "name": "jmeter.log",
      "size": 78352,
      "message": "message",
      "data": "data object"
   }
]
  • url – link to the file.
  • type – attachment type. Takes the following values: file, image, audio, video.
  • mimeType – MIME-based media type of the submitted file.
  • name – name of the file.
  • size – size of the file in bytes.
  • message – message text.
  • data – additional channel data.

Event processing

Use the $request object in the following format to get the data of the incoming file from eventData:

$request.data.eventData

For example, output a link to download the file submitted by the client:

state: fileEvent
    event!: fileEvent
    script:
        for (var i = 0; i < $request.data.eventData.length; i++) {
            $reactions.answer($request.data.eventData[i].url);
        }