Send a text message from Formant with more data

Q: I want to send a text message from Formant with more configuration/metadata than possible with Formant’s default behavior.

  • I want to include additional metadata, such as the location
  • I want to customize the URL it sends, to send a link to a view other than the default view

  1. We will expand the event functionality using a webhook. First we will create a webhook.
  2. Next we will create an event to trigger off a datapoint and send a POST request to the webhook when the event is fired.
  3. We will host a Webhook handler to listen for requests.
  4. The webhook handler will re-ingest a datapoint with the intended text as its payload. We will then fire a different event on the presence of this datapoint.
  5. Configure the event to send an SMS using the {{datapoint_value}} flag.
Example logic using webhooks.

Example logic using webhooks.

Example webhook handler (AWS Lambda)

This is not a functional example, but is intended to act as a general framework for how this webhook handler might be programmed.

import json
from import Client
from import Device
from import IngestionRequest
def process(event):
   # Parse Payload
   request = json.loads(event["body"])
   payload = request["payload"]
   device_id = payload["deviceId"]
   timestamp = payload["timestamp"]
   tags = payload["tags"]

   # Get Device Information
   formant_client = Client()
   device = formant_client.admin.devices.get_device(device_id).parsed
   location = device.tags.additional_properties['location']
   device_name =

   # Format Payload
   url = "" % (device_name, timestamp)
   text_payload = "%s spotted something at %s. Follow the link to see: %s" % (device_name, location, url)

   # Ingest Payload
   ingestion_request = IngestionRequest(device_id, tags, timestamp)

def main(event, context):
   except Exception as error:
       print(f"Failed to process request: {event} {error}")
       return {"statusCode": 500, "body": json.dumps({})}

   return {"statusCode": 200, "body": json.dumps({})}

if __name__ == "__main__":
   main({}, {})

See also


If you notice an issue with this page or need help, please reach out to us! Use the 'Did this page help you?' buttons below, or get in contact with our Customer Success team via the Intercom messenger in the bottom-right corner of this page, or at [email protected].