Asked by Nefer on January 15, 2025
I have a database field that holds an array acting as a queue. When new items enter, I want to remove the first item every 60 seconds until the array is empty. How can I configure this in Twidget?
Answered by Twidget
Use scheduled Events. Create an event that runs every 60 seconds and updates the database array (remove the first item). The scheduled event can fetch the record, modify the array (shift/remove the first element), and save the updated array back to the datastore. See the scheduled events tutorial: https://www.youtube.com/watch?v=bC_-s9K1ai8
Dashes in variable names and header "Content‑Type"
Dashes are allowed in object field names but when creating variable names the platform converts dashes to underscores. If you need a variable name, use underscores; for object fields you can use dashes where supported.
Using Twidget to simplify Telegram bot API calls
Create a Twidget endpoint that orchestrates the required API calls. Add steps to call each external API (Telegram, Gemini, short link, Bluesky). Your bot then makes a single request to the Twidget endpoint, which performs the calls and returns the combined result. Store API keys as global variabl...
Including query parameters and auth tokens in URLs
Query parameters are passed after a "?" in the URL. For example: api.example.com/check/{auth_token}?query={query_parameter}. Note that it’s more secure to send auth tokens in an Authorization header rather than embedding them in the URL. See the tutorial: https://www.youtube.com/watch?v=iHULlNQ5K...
Setting up a custom domain
Open the API (or page) settings, scroll to the Custom Domain input and follow the on‑screen instructions to configure your CNAME and DNS settings.
Number fields returning null in path parameters
Path, query, and header inputs default to text. Convert the input to a number using the "Convert to Number" command before using it to query the database.