Inbound Payloads
When Beam receives a payload from Somewear, it can forward the data with two different methods: a script or a webhook.
Configure a Beam Script Hook
You can have Beam run a script whenever it receives an inbound payload. Similar to webhooks, the payload will be sent to your script as a JSON. Your script can access the JSON data from stdin or BEAM_PAYLOAD
environment variable. Beam will print your script's stdout.
To configure a Beam script hook, you need to add an inbound-hook
key-value pair to your beam.properties
file:
The sample script above echo $BEAM_PAYLOAD
will simply print the JSON payload. If you'd like to do something else, simply edit the beam.properties
file and rerun beam up
.
Examples
Run Python Script
Write inbound payloads to file
Echo JSON messages to Slack
Configure a Beam Webhook
Like our cloud webhooks, Beam webhooks make a POST request to a URL of your choosing. This is done by configuring Beam with a webhook. For example, if you had a local web server running alongside Beam, you could configure Beam webhook with http://localhost:8080/somewear
and your web server will start receiving Beam traffic at that endpoint.
To configure a Beam webhook you need to add a webhook-address
key-value pair to your beam.properties
file:
If you'd like to quickly test this out without standing up a web server yourself, try out https://webhook.site/.
JSON Format
Beam script hooks and webhooks will receive data in the following format. The JSON format is designed to match the cloud-based webhooks.
Although payload
and events
are arrays, you can safely assume that you'll only receive one element for each. If we do upgrade Beam to support batching and this changes, it will require an opt-in flag.
Message
Location
Data
Last updated