Articles on: Workflow Builder

Workflow Builder: Autoresponder based on day of the week

This automation responds to new WhatsApp messages based on the day of the week when the message was received.


Example usage: If message is received on Sunday, automation sends text "We are not available on weekends. Please leave your request and we will get back to you first thing Monday morning" in response.


  1. Open TimelinesAI Workflow Builder https://app.timelines.ai/albato/automations and click New Automation
  2. Click Add Trigger

  1. Set up a trigger:
  • App where your data will come from: TimelinesAI
  • Event to trigger the automation: New incoming message
  • Connection token: leave as is.


  1. Click Add action:

  1. Add an action
  • App where your data will come from: TimelinesAI
  • Action to perform: Send message in existing Chat
  • Connection token: leave as is.

  1. Map fields for the action and click Save:
  • Chat ID: click the field. New window with data from previous steps will appear. Unfold the fields from Step1 and find Chat ID. On click, value will will be inserted into "Chat ID" field.
  • Message: type desired message text. Example: "We are not available on weekends. Please leave your request and we will get back to you first thing Monday morning"

  1. Click the "+" icon after the Step1 and select Сode


  1. Select JavaScript
  2. Add JavaScript code:
  • Input data: dateString , type= String, value = click the field. New window with data from Step1 will appear. Find Date and time the message was sent. On click, value will will be inserted into field.
  • Code: add code
function getWeekdayName(dateString) {
// Checking timezone offset
if (!/[+-]\d{4}$/.test(dateString)) {
dateString += " +0000";
}

// Checking format
const match = dateString.match(/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) ([+-]\d{4})$/);
if (!match) return 'Invalid format';

const [_, datePart, timePart, offset] = match;

// Working with formats
const formattedOffset = offset.slice(0, 3) + ":" + offset.slice(3);
const isoString = `${datePart}T${timePart}${formattedOffset}`;

const date = new Date(isoString);
if (isNaN(date.getTime())) return 'Invalid date';

// Returning results
return new Intl.DateTimeFormat('en-US', { weekday: 'long' }).format(date);
}

const weekday = getWeekdayName(dateString);
weekday;
  • Output data: weekday, type= String

  1. Save the JavaScript.
  2. Click the "+" icon after the Step2 ( JavaScript) and select Tool

  1. Select Stop automation on condition tool and set it up:
  • Condition: Continue automation
  • Condition1: IF value = click the field. New window with data from previous steps will appear. Unfold the JavaScript ste and find weekday. On click, value will will be inserted into field. Condition value = contains. Value = type "Saturday"

  1. Optional: click "Add condition to the group" and configure additional conditions in similar way. For example: to include "Sunday" or other desired days of the week.

  1. Click "Start" to launch the flow



Additional recommendations ( optional)


  1. Add error handler to each action step and choose what to do when errors occur:
  • Stop the automation
  • Continue the automation
  • Move on to the selected step below




Updated on: 29/07/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!