Texts each new Airtable enquiry your Cal.com booking link in your texting hours, sends one reminder if they have not booked, then stops.
Uses
Airtable
Cal.com
Twilio
Text new enquiries a booking link, then chase once
airtableBaseId to blank.Set airtableBaseId to blank.airtableTableName to blank.Set airtableTableName to blank.bookingLink to blank.Set bookingLink to blank.twilioFromNumber to blank.Set twilioFromNumber to blank.businessName to blank.Set businessName to blank.phoneRegion to US.Set phoneRegion to US.daysToWaitBeforeReminder to 3.Set daysToWaitBeforeReminder to 3.maxTextsPerRun to 12.Set maxTextsPerRun to 12.calcomEventTypeId to blank.Set calcomEventTypeId to blank.enquiriesToCheck to 100.Set enquiriesToCheck to 100.textingHoursStart to 9.Set textingHoursStart to 9.textingHoursEnd to 19.Set textingHoursEnd to 19.onlyTextEnquiriesFromLastDays to 3.Set onlyTextEnquiriesFromLastDays to 3.today.Get today's date and save it as today.rightNow.Get the current date and time and save it as rightNow.rightNow and save it as hourNow.Get the hour of rightNow and save it as hourNow.withinTextingHours to false.Set withinTextingHours to false.hourNow is greater than or equal to textingHoursStart multiplied by 1 and…If hourNow is greater than or equal to textingHoursStart multiplied by 1 and…Yes
withinTextingHours to true.Change withinTextingHours to true.No
No steps
invitesSent to 0.Set invitesSent to 0.remindersSent to 0.Set remindersSent to 0.alreadyBooked to 0.Set alreadyBooked to 0.stillWaiting to 0.Set stillWaiting to 0.skippedNoPhone to 0.Set skippedNoPhone to 0.skippedNoEmail to 0.Set skippedNoEmail to 0.skippedProblem to 0.Set skippedProblem to 0.textsSent to 0.Set textsSent to 0.hitTextLimit to false.Set hitTextLimit to false.waitingForTextingHours to 0.Set waitingForTextingHours to 0.textsTried to 0.Set textsTried to 0.refusedIds to an empty list.Set refusedIds to an empty list.notes to an empty list.Set notes to an empty list.airtableTableName. Save it as enquiryPage.List records in airtableTableName. Save it as enquiryPage.enquiries to enquiryPage.records.Set enquiries to enquiryPage.records.enquiry in enquiries:For each enquiry in enquiries:textsTried is greater than or equal to maxTextsPerRun multiplied by 1If textsTried is greater than or equal to maxTextsPerRun multiplied by 1Yes
hitTextLimit to true.Change hitTextLimit to true.No
No steps
fields to enquiry.fields.Set fields to enquiry.fields.followUpStatus to blank.Set followUpStatus to blank.statusUnreadableIf a step below fails, save the error as statusUnreadableTry
fields["Follow-up Status"] and save it as followUpStatus.Trim fields["Follow-up Status"] and save it as followUpStatus.On error
followUpStatus to blank.Change followUpStatus to blank.followUpStatus isn't blank and followUpStatus is not Link sentIf followUpStatus isn't blank and followUpStatus is not Link sentYes
No
No steps
personName to there.Set personName to there.nameUnreadableIf a step below fails, save the error as nameUnreadableTry
fields.Name and save it as personName.Trim fields.Name and save it as personName.On error
personName to there.Change personName to there.personName is emptyIf personName is emptyYes
personName to there.Change personName to there.No
No steps
personName by a space and save it as nameParts.Split personName by a space and save it as nameParts.mobile to blank.Set mobile to blank.mobileUsable to false.Set mobileUsable to false.mobileUnreadableIf a step below fails, save the error as mobileUnreadableTry
fields.Phone and save it as mobile.Trim fields.Phone and save it as mobile.mobile is a valid phone number and save it as mobileUsable.Check whether mobile is a valid phone number and save it as mobileUsable.On error
mobileUsable to false.Change mobileUsable to false.emailAddress to blank.Set emailAddress to blank.emailUsable to false.Set emailUsable to false.emailUnreadableIf a step below fails, save the error as emailUnreadableTry
fields.Email and save it as emailAddress.Trim fields.Email and save it as emailAddress.emailAddress is a valid email address and save it as emailUsable.Check whether emailAddress is a valid email address and save it as emailUsable.On error
emailUsable to false.Change emailUsable to false.unusableReason to blank.Set unusableReason to blank.mobileUsable is noIf mobileUsable is noYes
skippedNoPhone.Add 1 to skippedNoPhone.unusableReason to no usable mobile number.Change unusableReason to no usable mobile number.Else if @emailUsable is no
skippedNoEmail.Add 1 to skippedNoEmail.unusableReason to no usable email address.Change unusableReason to no usable email address.Otherwise
No steps
unusableReason isn't blankIf unusableReason isn't blankYes
markProblemIf a step below fails, save the error as markProblemTry
enquiry in airtableTableName.Update enquiry in airtableTableName.personName - unusableReason to the end of notes and save it as notes.Add Marked 'Needs attention': personName - unusableReason to the end of notes and save it as notes.On error
skippedProblem.Add 1 to skippedProblem.personName 'Needs attention' (unusableReason): markProblem.message to the end of notes and save it as notes.Add Could not mark personName 'Needs attention' (unusableReason): markProblem.message to the end of notes and save it as notes.No
No steps
mobile and save it as textTo.Format the phone number mobile and save it as textTo.Hi @nameParts[0], and save it as greeting.Build the text Hi @nameParts[0], and save it as greeting.inviteOpening to greetingthanks for getting in touch with businessName.Set inviteOpening to greetingthanks for getting in touch with businessName.inviteText to inviteOpening. Pick a time that suits you here: bookingLink Reply STOP to opt out.Set inviteText to inviteOpening. Pick a time that suits you here: bookingLink Reply STOP to opt out.reminderOpening to greetingwe have not got you booked in at businessName.Set reminderOpening to greetingwe have not got you booked in at businessName.reminderText to reminderOpening yet. Here is the link again: bookingLink Reply STOP to opt out.Set reminderText to reminderOpening yet. Here is the link again: bookingLink Reply STOP to opt out.textToSend to blank.Set textToSend to blank.statusAfterText to blank.Set statusAfterText to blank.enquiryProblemIf a step below fails, save the error as enquiryProblemTry
bookingLookup.List bookings. Save it as bookingLookup.bookingLookup.bookings isn't emptyIf bookingLookup.bookings isn't emptyYes
alreadyBooked.Add 1 to alreadyBooked.enquiry in airtableTableName.Update enquiry in airtableTableName.Else if @followUpStatus is "Link sent"
fields["Follow-up Date"] and save it as linkSentOn.Trim fields["Follow-up Date"] and save it as linkSentOn.linkSentOn to today and save it as daysWaited.Count the days from linkSentOn to today and save it as daysWaited.daysWaited is greater than or equal to daysToWaitBeforeReminder multiplied by…If daysWaited is greater than or equal to daysToWaitBeforeReminder multiplied by…Yes
textToSend to reminderText.Change textToSend to reminderText.statusAfterText to Reminded.Change statusAfterText to Reminded.No
stillWaiting.Add 1 to stillWaiting.Otherwise
textToSend to inviteText.Change textToSend to inviteText.statusAfterText to Link sent.Change statusAfterText to Link sent.On error
skippedProblem.Add 1 to skippedProblem.personName - enquiryProblem.message to the end of notes and save it as notes.Add Not checked, tried again next run: personName - enquiryProblem.message to the end of notes and save it as notes.textToSend is blankIf textToSend is blankYes
No
No steps
withinTextingHours is noIf withinTextingHours is noYes
waitingForTextingHours.Add 1 to waitingForTextingHours.No
No steps
textsTried.Add 1 to textsTried.textWentOut to false.Set textWentOut to false.sendProblemIf a step below fails, save the error as sendProblemTry
textTo. Save it as sentText.Send a text message to textTo. Save it as sentText.textToSendtextWentOut to true.Change textWentOut to true.On error
enquiry.id to the end of refusedIds and save it as refusedIds.Add enquiry.id to the end of refusedIds and save it as refusedIds.personName (textTo): sendProblem.message to the end of notes and save it as notes.Add Twilio refused the text to personName (textTo): sendProblem.message to the end of notes and save it as notes.textWentOut is noIf textWentOut is noYes
No
No steps
textsSent.Add 1 to textsSent.statusAfterText is RemindedIf statusAfterText is RemindedYes
remindersSent.Add 1 to remindersSent.No
invitesSent.Add 1 to invitesSent.recordProblemIf a step below fails, save the error as recordProblemTry
enquiry in airtableTableName.Update enquiry in airtableTableName.On error
personName (textTo) but could not mark their row '@statusAfterText' in Airtable: recordProblem.message. Set their Follow-up Status to '@statusAfterText' by hand before the next run, or they will be texted again. Stopped here so nobody else is texted without a record.Stop and report a problem: Texted personName (textTo) but could not mark their row '@statusAfterText' in Airtable: recordProblem.message. Set their Follow-up Status to '@statusAfterText' by hand before the next run, or they will be texted again. Stopped here so nobody else is texted without a record.refusedNote to blank.Set refusedNote to blank.refusedIds isn't emptyIf refusedIds isn't emptyYes
textsSent is greater than 0If textsSent is greater than 0Yes
refusedId in refusedIds:For each refusedId in refusedIds:refusedMarkProblem If a step below fails, save the error as refusedMarkProblemTry
refusedId in airtableTableName.Update refusedId in airtableTableName.On error
refusedMarkProblem.message to the end of notes and save it as notes.Add Could not mark a refused text 'Needs attention': refusedMarkProblem.message to the end of notes and save it as notes.refusedNote to:Change refusedNote to:Other texts went out, so each refused number is marked 'Needs attention' - usually a landline, or someone who replied STOP. Fix the row and set Follow-up Status back to empty (or 'Link sent' for a reminder) to try again.No
refusedNote to:Change refusedNote to:No text went out this run, which usually means a problem with your Twilio account or the 'twilioFromNumber' step. Nothing was marked, so the next run tries again.No
No steps
summaryLines to [Booking links texted: invitesSent, Reminders texted: remindersSent, Already booked, marked Booked: alreadyBooked, Still inside the waiting period: stillWaiting, Due a text, held until texting hours: waitingForTextingHours, Marked 'Needs attention', no usable mobile number: skippedNoPhone, Marked 'Needs attention', no usable email address: skippedNoEmail, Texts Twilio refused: the length of refusedIds, Could not be checked: skippedProblem].Set summaryLines to [Booking links texted: invitesSent, Reminders texted: remindersSent, Already booked, marked Booked: alreadyBooked, Still inside the waiting period: stillWaiting, Due a text, held until texting hours: waitingForTextingHours, Marked 'Needs attention', no usable mobile number: skippedNoPhone, Marked 'Needs attention', no usable email address: skippedNoEmail, Texts Twilio refused: the length of refusedIds, Could not be checked: skippedProblem].summaryLines with a new line and save it as summary.Join summaryLines with a new line and save it as summary.limitNote to blank.Set limitNote to blank.hitTextLimit is yesIf hitTextLimit is yesYes
limitNote to Change limitNote to
Stopped early at this run's limit of maxTextsPerRun texts. The rest are picked up next run.No
No steps
notes with a new line and save it as noteList.Join notes with a new line and save it as noteList.Enquiry follow-up finished. @summary@limitNote @noteList@refusedNote and save it as report.Build the text Enquiry follow-up finished. @summary@limitNote @noteList@refusedNote and save it as report.refusedIds isn't empty or skippedProblem is greater than 0If refusedIds isn't empty or skippedProblem is greater than 0Yes
report.Stop and report a problem: report.No
No steps
report.Show in the output: report.