Web API

This is the most low-level integration possible.

We provide a WebSocket-based API that allows you to send and receive messages from Flow.ai in real-time.

Connecting

To begin a connection you'll need to make a GET call to the socket.info API method to the API endpoint at https://api.flow.ai. This provides a temporary WebSocket URL.

The socket.info method requires a sessionId and a clientId. The sessionId is something you need to create on your end. Each connection is partly identified on our end using this key

Check the dashboard to find your unique clientId.

cURL
Nodejs
C#
Swift
curl -X GET -H "Content-Type: application/json" "https://api.flow.ai/socket.info?clientId=...&sessionId=123432"
var request = require("request");

var options = { method: 'GET', url: 'https://api.flow.ai/socket.info/?clientId=...&sessionId=1234' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
var client = new RestClient("https://api.flow.ai/socket.info?clientId=...&sessionId=1234");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
var request = NSMutableURLRequest(URL: NSURL(string: "https://api.flow.ai/socket.info/?clientId=...&sessionId=1234")!,
                                        cachePolicy: .UseProtocolCachePolicy,
                                    timeoutInterval: 10.0)

Example result:

{
    "status": "Ok",
    "payload": {
        "endpoint": "wss://api.flow.ai/ws/ZTkxMjJkMWI3OThhNGRiZmI2ZTRmZTc5NjAyOTNkNDMrODQ4MmM3YjcwODI1NDkzYWE2ZTM4NDhlY2I2MTcwYWQ=/6a2c56f4791e4ac28a696eba9b115340"
    }
}

The Websocket URL provided by socket.info are single-use and are only valid for 60 seconds, so make sure to connect quickly.


Message format

Any message or other kind of event you send or receive has the same JSON format. All communication takes place over the web socket connection.

{
  "type": "...",
  "payload": {
    ...
  }
}

Fields

Property Description Type
type The message type for example: message.send string
payload The body of the message object

results matching ""

    No results matching ""