Receiving messages (Flow Socket)

Learn about receiving message response information for the Flow socket API

The format for both received replies and sent messages is the same.

Payload Example

The following is an example of receiving a message example or reply.

{
  "type": "message.received",
  "payload": {
    "threadId": "EXAMPLE8917250d54bcbb596",
    "messages": [
      {
        "fallback": "hallo",
        "responses": [
          {
            "type": "text",
            "payload": {
              "text": "hallo"
            }
          }
        ]
      }
    ],
    "originator": {
      "userId": "USERID4bcbb59657a8a2a891",
      "name": "USER NAME",
      "role": "user",
      "profile": {
        "fullName": "USER NAME",
        "firstName": "USER",
        "lastName": "NAME",
        "locale": "nl",
        "gender": "M",
        "picture": "https://flowai.domain.com/identities/profile/EXAMPLE-318a-4d58-b5e1-b430934b8e23"
      }
    }
  }
}

The following table has the payload message parameters and descriptions.

ParameterDescriptionType
threadIdRequired. A unique key that identifies a user or channel.string
messagesList of Message templatesarray
originatorSimilar to the originator when sending messagesobject

Advanced Reply Example

The following is an example of receiving a message with an advanced reply.

{
  "type": "message.received",
  "payload": {
    "threadId": "EXAMPLE327348ed3bd1439e7b",
    "messages": [
      {
        "fallback": "Hi, how can we help?",
        "silent": false,
        "replyTo": "event attachment",
        "originator": {
          "userId": "flowai|system",
          "name": "system",
          "role": "bot",
          "profile": {
            "picture": "https://flow.ai/img/EXAMPLE/flowai.svg"
          }
        },
        "actions": [],
        "responses": [
          {
            "type": "text",
            "payload": {
              "text": "Hi, how can we help?",
              "quickReplies": [
                {
                  "label": "Chat with flow.ai",
                  "value": "Chat with someone from flow.ai",
                  "type": "text"
                },
                {
                  "label": "Call flow.ai",
                  "value": "What is your phone number?",
                  "type": "text"
                },
                {
                  "label": "Ask a question",
                  "value": "I want to ask a question",
                  "type": "text"
                }
              ]
            },
            "delay": 0
          }
        ],
        "flow": {
          "flowId": "EXAMPLE-9335-4e74-abb3-5745d26707f7",
          "title": "Intro"
        },
        "step": {
          "stepId": "EXAMPLE-e526-4252-b70c-e6e5af3338e0",
          "title": "INTRO",
          "type": "EVENT"
        },
        "params": {
          "event": [
            {
              "type": "custom",
              "value": {
                "name": "INTRO"
              }
            }
          ]
        }
      }
    ],
    "originator": {
      "userId": "flowai|system",
      "name": "system",
      "role": "bot",
      "profile": {
        "picture": "https://flow.ai/img/EXAMPLE/flowai.svg"
      }
    }
  }
}

The following table has the advanced reply message parameters and descriptions.

ParameterDescriptionType
fallbackSpeech representation of the messagestring
silentTrue if the message does not have any output for a userboolean
replyToOptionally contains the text the message is a direct reply tostring
originatorOriginator specific to this messageobject
actionsOptional action names being calledarray
responsesCollection of response templatesarray
flowInformation about the matched flowobject
stepInformation about the matched stepobject
paramsHash table with Parametersobject

More information

See our complete reference of the JSON responses in Github for more information.