SMS Workflow using Twilio and Script block

Looking at this issue regarding sending ‘single’ message using scriptiing block which was resolved by @Mike_Pennisi i was wondering if we could also be able to using script block/ Twilio to calculate how much it will cost to send a certain SMS to a number of users? Also a way to get the budget per group or assigned group.
And lastly using script block calculate the total cost and and enable/disable the sending according to the actual budget.
Has anyone worked on something similar ? or found a hack around this…

Twilio’s REST API includes resources for estimating pricing, so this definitely seems possible! I’d start by reviewing Twilio’s API documentation:

@Lubem_Mtile if the “Send SMS” block estimated the cost of sending the messages and if it displayed that estimate when prompting you to confirm the operation, would that address your needs?

Your request is specifically in terms of the Scripting Block–are there specific things you are trying to achieve that are only possible in the Scripting Block?

@Mike_Pennisi Sure that would very much address my needs!

Yes, Considering that we are looking into moving away from a third party SMS platform, this is the best approach for now having everything in airtable, among other reasons…

Hi @Mike_Pennisi did you want to share some pointers here with me ?

@Lubem_Mtile Interesting challenge. I haven’t actually got into the scripting block yet, but just finished doing some work with Twilio automations. Pricing wise, should be fairly easy to estimate.

$0.75 per text (under 160 characters). Over 160 characters, you can take the length of the message, divide by 153 and round up, then multiply by $0.75 for cost. (Twilio breaks longer messages up into 153 character segments, the 7 lost characters are used for data to connect the messages together on the other end).

So with the length of the messages and the number of recipients, you should be able to estimate the price fairly easily. You could have a column in your table for ‘budget’ and compare the estimate to the budgets for that.

You may have already figured this all out, just thought I’d share. After I have some experience working on airtable scripts, I’ll check back and see if I can offer some code samples =)

1 Like

Thanks @Kris pretty much set up but not perfect! Would explore automations as well for just estimation.