Contact Sales

All fields are required

Advanced communications from the source. | SignalWire

List LaML Messages to CSV (Ruby)

List all the incoming and outgoing LaML messages sent/received within your SignalWire Project.

Technical Success Manager

Cassie Bowles
Why do you need it?

This snippet might be helpful to you if you need to pull your message records from SignalWire into a more readable format or somewhere easy to store. You can use one or more of the following parameters to further filter your records and return only the specific information that you need: DateSent, DateSentAfter, DateSentBefore, From, and To.

You can read more about the List Messages API here.

What does it do?

This code will query your project and return all of the messages (both inbound and outbound) within your project, limited by whatever parameters you choose to use. This example shows how to filter all messages by a particular date range and specifies a page size. It will then take this data and insert it into a CSV for your records or further use.

Technical specifications
  1. For the Ruby version of this snippet, You MUST have ActiveSupport installed. You can read about installing active support here.

  2. You must have the SignalWire Ruby SDK installed. You can install that here.

Change the following variables
  1. ProjectID - Your project ID is an alphanumeric string that tells the SignalWire SDK where to find your project. You can find this in an easily copyable format by going to your SignalWire Portal and clicking the API tab on the left-hand side.

  2. AuthToken - Your Auth Token is an alphanumeric string that helps to authenticate your HTTP requests to SignalWire. You can create this (if you haven’t already) or copy this in an easily copyable format by going to your SignalWire Portal and clicking the API tab. If you have not created an API token, press the blue new button. If you have, click show and copy the string.

  3. SpaceURL - Your space URL is the domain of your space, i.e. This can also be found in an easily copyable format within the API tab in your SignalWire space.

  4. Change the date and page size when calling clients.messages.list() to specify the date range and amount of results returned that you need. If you are filtering by another parameter, you can add it within client.messages.list()

Step by step guide with the code

This snippet uses the Ruby SDK to query the SignalWire API and return all the message data matching the parameters you choose to set. This data is then inserted into a CSV file with the following columns:

  • From phone number

  • To phone number

  • Date

  • Status (queued, sending, sent, delivered, undelivered, failed, receiving, received)

  • MessageSID (361d7f20-f30d-4baf-b8ca-c7912dleaacf)

  • Direction

  • Price

Getting Started Guide

If you are looking for more information about using SignalWire, refer to our Getting Started guide.

Please feel free to reach out to us on our Community Slack or create a Support ticket if you need guidance!

Start a free trial

If you would like to test this example out, you can create a SignalWire account and space here.

Related Articles