You can use Flock's webhooks to send and receive messages from external services using JSON packets. An incoming webhook posts messages to a Flock channel from an external service.

Create an incoming webhook

Webhooks_Dev01.png

Webhooks_Dev02.png

Webhooks_Dev03.png

curl -X POST <Incoming Webhook URL> -H "Content-Type: application/json" -d '{
"text": "This is a test message"
}'


Transforming JSON payload formats

Flock's incoming webhooks support Message objects with two common attributes or keys - "text" for message content and "flockml" for message formatting.

curl -X POST <Incoming Webhook URL> -H "Content-Type: application/json" -d '{
"text": "This is a test message."
}'

OR

curl -X POST <Incoming Webhook URL> -H "Content-Type: application/json" -d '{
"flockml":"<flockml>Hello! Welcome to <b>Flock</b>!</flockml>"
}'


Some external apps and services may send data that does not follow Flock's JSON payload format, and hence it is not parsed.

In the following example, the JSON payload received is not in a compatible format, so no message is generated:

curl -X POST <Incoming Webhook URL> -H "Content-Type: application/json" -d '{
"product": "iPhone", "units": "1", "customer": "Adam", "price": "1000"
}'


To receive messages via an incoming webhook from an app and service that uses an incompatible JSON format, you'll need to transform the data into a Flock-compatible format.

{"text": "$(json.customer) bought $(json.units) $(json.product) @ $$$(json.price)"}

Webhooks_Dev04.png