Small tricks: Utilize Temporary Storage under Twilio Functions
Time to read: 1 minute
When working with Twilio Functions, you might need to create resources you'd like to store locally for one-off activities. For example, you might like to create a file with user-provided data and send it onto the next step in a flow based on your business needs.
In Functions, anything that you create on-the-fly gets stored in the temporary
folder, which may not be obvious at first.
In this quick tutorial, I'll show you how to access and utilize the temporary storage under Functions for your purposes. Let's get started.
Temporary Storage in a Twilio Function
If you try to perform operations anywhere other than the temporary folder in the underlying OS filesystem you will see something like:
Below I show a Twilio Function writing to and retrieving from the relevant temp folder:
That should be enough to get you started reading and writing to a temporary file in Functions. You should be able to adapt from there for your business needs.
Also: Find it on Twilio Labs GitHub and Serverless (Twilio CLI)
You can check out this Function template on the Twilio Labs GitHub page here. There you'll find even more useful function templates to get you started with Twilio Functions
If you wish to use it from the Twilio CLI, you can accomplish that by running the following command inside a project that was created with the Serverless Toolkit:
twilio serverless:init example --template=temp-storage
Evangelos Resvanis is a Solutions Engineer at Twilio. He is currently working on his favorite topics, Autopilot and Twilio Functions, exploring and expanding the possibilities offered by these tools. He can be reached at eresvanis [at] twilio.com and on Twitter at @eresvanis.
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.