Webhooks are an easy option for do-it-yourself integrations if you’d like to post messages into Fleep conversations from other systems (with incoming webhooks) or to send messages out of Fleep conversations (with outgoing webhooks).
Be it then your monitoring system, statistics bot etc. Whatever the need is you can get started here:
How to use webhooks in Fleep?
Incoming webhook example:
- John, Scott and Paul have created a Fleep conversation called “Stats”
- John creates a new webhook by opening Conversation Settings > Integrations and clicking on the Add button and then Create on the next popup window to generate a new custom hook
- After that a new screen with the Hook URL will open and with this link John configures their statistics gathering script to send daily summaries to the URL https://fleep.io/hook/Z0Ph_W2LTVa8sgicQ5Gruw
- Daily Stats script creates a summary and posts it via hook into the conversation.
- John, Scott and Paul will receive new Fleep messages into “Stats” conversation.
Python example using JSON payload:
>>> import requests >>> requests.post( ... "https://fleep.io/hook/IJONmBuuSlWlkb_ttqyXJg", ... json={"message": "Testing hook with\nPython", "user": "Python"})
Note that the “user” parameter is what will be used as the sender name in the conversation for that message.
cURL example:
curl -X POST https://fleep.io/hook/IJONmBuuSlWlkb_ttqyXJg -d 'message=Testing%0AWith%0ACurl'
Node.js example using multipart/form-data to upload files:
var rp = require('request-promise'); var options = { method: 'POST', uri: 'https://fleep.io/hook/IJONmBuuSlWlkb_ttqyXJg', formData: { message: 'uploading some files', files: [{ value: 'uploading files using request-promise', options: { filename: 'test_file.txt', contentType: 'text/plain' } }] } }; rp(options) .then(function (body) { // POST succeeded... }) .catch(function (err) { // POST failed... });
Python example using multipart/form-data to upload files:
import requests url = 'https://fleep.io/hook/IJONmBuuSlWlkb_ttqyXJg' message = 'uploading some files' files = [('files', ('test_file.txt', 'file content as string')), ('files', open('test_image.jpeg', 'rb'))] requests.post(url, data={'message': message}, files=files)
How to convert outgoing hook payload into a plain text message?
Here’s the outgoing hook JSON format:
{ "reply_url": Hook URL for reply message, "contacts": [ <ContactInfo> objects related to the message(s) ], "conversations": [ <ConvInfo> objects related to the message(s) ], "hooks": [ <HookInfo> objects related to the message(s) ], "messages": [ <MessageInfo> objects ] }