With many people going into self-isolation for weeks or possibly even months at a time, we’re seeing a huge surge in use of video calling and video conferencing services as a means for people to both stay in touch with friends and family as well as working from home.
However, for some members of society including the elderly and most vulnerable, these high-tech solutions may not work because they rely on having Internet access, a decent computer/laptop/tablet/smartphone and a certain degree of knowledge and experience to be comfortable using it.
With yesterday’s announcement that all Sunday services at Churches around the country are to be stopped until further notice, we have – at my church – already started planning to produce a short video to be published on Facebook, YouTube etc. on Sunday mornings, as well as the usual sermon recording/podcast which I already produce each week. With the restrictions now in place, the weekly podcast will be more important than ever but it does, of course, rely on an Internet connection and a device such as computer, smartphone or smart speaker to listen.
How to Build A Telephone Number For Podcast Listening
To get round this problem and make the audio recordings as accessible as possible for everyone, I have built a simple app using Twilio, which is a cloud communications platform that lets you build telecoms apps in the cloud which can do all sorts of things. Don’t let that scare or overwhelm you; what we’re going to be building is very simple and easy to set up.
Video Tutorial Also Available!
If you’d prefer to watch me demonstrate this in a video rather than follow the written guide below, you can watch the YouTube video instead. Then, please give it a thumbs-up, subscribe to the channel and leave a comment – thank you!
Step 1: Sign up for a Twilio Account
Sign up using this link: http://www.twilio.com/referral/cTXU0Q for a free trial – it’ll give you and my church $10 free account credit, too – which will help us both out 🙂 [You don’t need to spend any money until it’s up and running and working… more on that later on.]
You’ll have to verify your Email address and a mobile phone number as part of this process.
Step 2: Set Up Your Account & Get a Phone Number
Once that’s done, you’ll see a wizard which asks you some basic questions to get started, the first of which is “Do you write code?”. You can say no to that if you don’t, and then select “Build something on Twilio myself“.
You’ll then be taken to your project Dashboard where you’ll see that you have a Trial Balance of credit to allow you to test and build your app. The first thing you’ll want to do is to click on Settings and give your project a name, like Dial-a-Sermon. Scroll to the bottom and click Save.
Then click back on your Dashboard and click the red “Get a Trial Number” button. You’ll be given a United States phone number to begin with, but if you’re elsewhere in the world and want folk to have a local number to call, click where it says “Don’t like this number?”
I’m based in Liverpool where the area code is 0151, so getting a phone number with a local area code with which people are familiar is probably a good idea. Select “Voice” under capabilities and then type the area code minus the leading 0 (if you want) in the Number box and press Search.
This will bring up a list of phone numbers that you can choose from, so pick one with a nice easy-to-remember sequence of digits, if possible, and click Buy. As you can see, the cost is $1 per month or just a smidgen over 75p in Great British Pounds. It’s not free, but it’s very low cost!
(Note – it actually is free until you upgrade your account to let people start using it.)
On the next screen you’ll confirm and then press Buy again. If you’ve not already added your address to your account, you’ll need to do that as one of the purchasing screens asks you which address on your account you want to associate the new number with. If there’s no address on your account, you can add one at that point.
Step 3: Write a Function to Play an MP3 File Down the Phone to Callers
Now you’ve got a number, you need to tell Twilio what you want to happen when people call it. Click the three dots to open the menu up for your Project and click on Functions, which is right down the bottom of the list under RUNTIME:
Click the red “Create a Function” button and then select the template called “Hello Voice” and click Create:
By default, this creates a function called Hello Voice which when called will play a synthesized voice which reads out whatever text you choose. In the initial example, it will say “Hello World” to the caller. You can change this to instead play any publicly available MP3 file.
If you already run a podcast for your church or other organisation, you’ll just need the full, public URL of the MP3 file you want to play (you can test it will definitely work by pasting it into your web browser’s address bar). If you host MP3 files directly on your website you can also use the full URL from there, or you could also host in something like Dropbox or Google Drive and make it publicly accessible.
Delete everything in the code section and instead paste in this slightly different code:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say("Welcome to Saint Anne's. This week's sermon will start shortly, please wait a moment.");
twiml.play("https://sermons.stannesaigburth.com/08Mar2020.mp3");
twiml.hangup();
callback(null, twiml);
};
The code first reads out any message you like, then plays an MP3 file (Line 4) and then I’m sure you can guess what Line 5 does! Reading out a short message at the start (Line 3) is optional, and you can remove that line altogether if you like, but it will play immediately and gives callers positive confirmation that they’ve got through to the right place, which can help as there’s sometimes a short delay whilst the MP3 is loaded before it starts playing.
On the fourth line, you’ll have to replace that URL with the URL of your own MP3, obviously. Be careful to keep the single quotes inside the brackets around the address, or it won’t work.
Note: you must make sure that the MP3 is publicly visible if you’re hosting it somewhere like Dropbox or Google Drive.
Dropbox Method:
For Dropbox to work you need to add the following to the end of the file’s public URL:
&raw=1&t=.mp3
This is in addition to the “?dl=0” that you should already have at the end of your Dropbox URL. Therefore, your complete Dropbox URL should look something like this:
https://www.dropbox.com/s/xxxxxxxxxx/sermon.mp3?dl=0&raw=1&t=.mp3
Google Drive Method:
For Google Drive, it’s slightly more complicated than just adding something to the end of the URL, like with Dropbox. However, it’s still easily done.
First, get your shareable public URL from Google Drive, which will look something like this:
https://drive.google.com/file/d/*****/view
The ***** above will correspond to the unique ID of your file – select JUST that ID (so between the /d/ and the /view portion of the URL) and combine it with the following new URL:
https://docs.google.com/uc?export=download&id=
Once you’ve done that, you’ll have a URL which looks a bit like this:
https://docs.google.com/uc?export=download&id=*****
(Again, the ***** above represents your file’s unique ID.)
Take that URL and paste it into the function code in your Twilio function, between the single quotes.
Moving on…
Next, enter a path (like /sermon) in the properties field above, and give the function a name you’ll recognise, like “Play latest sermon recording”. Once you’ve done that, you can press Save and your function will “deploy”!
Step 4: Configure your Phone Number to Run the Function from Step 3
Click the three dots on the left column again to bring up the menu, and select “Programmable voice”. This is where we will program your voice number to execute the function we’ve just written. Don’t worry – it’s literally just selecting the function from a drop-down menu!
Click the “Numbers” item in the submenu for Programmable Voice and then on the Phone Numbers screen click Manage Numbers.
You’ll see a list of all the phone numbers on your account (there’ll only be one) and as you can see, it’s currently configured to play a Twilio welcome message.
Click on the number itself to bring up its settings, and then scroll down to Voice & Fax.
Under the option entitled “A Call Comes In”, select the dropdown and change it from Webhook to Function. Then next to it, select your function (which we made in the previous step) from the list and then press Save down at the bottom of the page.
Step 5: Dial A Phone Number to Listen to Your Podcast!
If you now call that number, you should hear the following message:
You have a trial account. You can remove this message at any time by upgrading your account. Press any key to execute your code.
Twilio / How to Create a Phone Number to Call and Listen to Podcasts or Other Audio
Press any key and voilà! The MP3 file which you specified in the code above should start playing down the phone!
Note that if you’re still on a trial account and haven’t yet upgraded, the call length is limited to 10 minutes. This is so that you can test your app properly before launch, but stops people misusing the trial accounts for production projects!
Updating your Phone Number to Play Most Recent Podcast or Audio Recording
Each week, or whenever you want to change what audio file the phone number plays, just login to your Twilio account and edit the function with the URL of the new audio file to be played.
If you’re comfortable with code and want to expand this further to automatically grab the latest MP3 from your website or podcast’s RSS feed, Nick Holcombe has expanded upon my basic solution for any seasoned coders out there. You can see his post here: https://www.brightec.co.uk/blog/podcasting-to-those-without-internet-access
Now, Upgrade Your Account
To get rid of the demo message and 10 minute time limit and start using the app, you’ll just need to upgrade your account with some billing details. For me, that just meant topping up £20 which should last a good long while as the phone number costs just ~75p per month to keep and incoming calls to the number cost you, the operator of the number, only $0.01USD a minute which is about 0.84p!
A Note on Call Costs…
A few people have asked this so I thought it would be worth clarifying: If you choose a local, geographic phone number (eg. 0151 for Liverpool, 0121 for Birmingham, 020 for London etc.) then this will cost the person dialing the number exactly the same as what it would cost them to dial any other similar number. In other words, there’s no extra charge whatsoever. If they have “free minutes”, it will be included in those – so to all intents and purposes, for the majority of people, it will be free to call. You just need to keep your Twilio account topped up with credit to receive the calls. (see above)
In Conclusion…
I hope you’ve found this tutorial useful during this strange time of extra need, and I hope many elderly and more vulnerable people will really benefit and feel less cut off from the outside world and their church communities as a result of this.
If you build this, please let me know as I’d love to see how far and wide this gets used. Comment below or tweet me @paulfp.
And of course, if you have any problems – I’ll be happy to help as much as I can.
Best wishes and stay healthy.
Update, 1st May 2020: Comments Now Closed
Comments on this article are now closed, however I’m still very happy to help and advise anyone wanting to set this up! To ask me a question, please follow me on Twitter and then tweet me your question – I’ll respond as quickly as I can!
You can also watch the video version of this tutorial and comment on the YouTube video for help.
Join Our Facebook Group!
If you’d like a place to discuss this topic and expansions/extra development, I’d also encourage you to join the Switched on Network Facebook group: https://www.facebook.com/groups/SwitchedOnNetwork/
HELP! I followed the excellent illustrated steps, but the only thing I wasn’t sure about was using a Dropbox account. The problem may be because it isn’t publicly accessible (yet!).The protocol for sharing gives a link that enables anyone who has the link to access. It was (with me replacing some of the actual numbers with asterisks): https://www.dropbox.com/s/*******/wrestling%20with%20god.mp3?dl=0
I was slightly doubtful as to whether this would work, given that it didn’t end in just .mp3
However, I forged ahead: dialing the number was fine, I got the initial message, but then when I pressed ‘any key’, I got the message: “an application error has occurred”
Have you any suggestions? Is it because the Dropbox isn’t public?
This seems a brilliant piece of software, and your illustrated guide was brilliant for someone like me, and it would be GREAT to crack this one!!
Hi Corinne, glad you’ve nearly got it working! Yes, the MP3 will need to be publicly accessible from Dropbox in order to work. Also, you’ll need to add a tiny bit extra to the end of the URL that you get from dropbox.
It already ends with ?dl=0 at the end of the URL; you’ll need to add &raw=1&t=.mp3 so that the full URL looks something like this:
https://www.dropbox.com/s/xxxxxxxxxx/sermon.mp3?dl=0&raw=1&t=.mp3
I’ll update the article to mention that for MP3s hosted on Dropbox. Once you’ve made it public and added that to the URL in your function, it should work – let me know how you get on!
In an addition to the previous comment, a debugger on Twilio triggered when the phone didn’t play the message. I clicked on it (having gone to a Google Drive public .mp3 file, as it seemed that privacy might have been an issue with Dropbox, and they no longer supported public folders). The message I got was this:
Error – 11750
TwiML response body too large
In your response to Twilio’s request, the response body is larger than 64 kB.
Possible Causes
The TwiML that you are serving is larger than 64 kB
You are serving non-TwiML content in your response
Possible Solutions
Verify that you are serving TwiML in your response to Twilio’s request.
Verify that you are including this header in your TwiML response:
Limit your TwiML response to 64 kB or less.
Does your TwiML include the Play verb? Double-check the size of the MP3 file you include and ensure it is 64kb or less.
Check that your TwiML is formatted properly. To quickly verify your TwiML, you can copy and paste it into a new TwiML bin in the Twilio Console.
Check to see if your application is throwing errors. This may cause your application to send a large debug output as HTML back to Twilio instead of the expected TwiML.
If you are trying to send a 200 response in a status callback, use an empty TwiML response:
The thing that caught my attention (bear in mind that I barely know what I’m doing other than following instructions) was;
Does your TwiML include the Play verb? Double-check the size of the MP3 file you include and ensure it is 64kb or less.
An MP3 file of 64kb or less????? How’s that going to work for any sermon that’s in the MBs?!
Any guidance would be much appreciated, as you clearly seem to have made this work!!
Hmmm I’m not quite sure to be honest, the MP3s that I’ve got working are over 30MB. Try it again with Dropbox using the extra bit at the end of the URL, that should definitely work (I tried it before posting my last comment).
I think you must have just edited the page!! Brilliant! It works!! THANK YOU!!!!!! (my boss will hopefully be impressed and pleased) Thanks for quick response – ignore the Google Drive comment below (or delete it if I can’t!)
Thanks for serving the church in this way in these strange days!
Aaah, great – glad it’s working!
Sorted! 🙂 See comments below…
Just a quickie additional question (as people might want to know) – presumably usual network charges apply for the person making the call – is that right?
Yes that’s right – if you choose a local number for your region/city it’ll be the same cost as usual to call (so included in “free minutes” etc).
Thanks!
Hi Paul, absolutely loving this – and making good progress but get an error message when I press a key to listen to the recording… Can you help? I’m using Google Drive – this is the link:
https://drive.google.com/file/d/1M2Mgo8L_klMS_ND51L0qlNEi0BRpFXFo/view
It passes the URL test! Any advice?
Many thanks!
Mark
Hi Mark! I haven’t quite figured out how to get it to work with Google Drive yet… I’m trying though 🙂 If I manage to crack it, I’ll let you know and also update the article as well.
Article updated with how to make it work from Google Drive, too!
Hi Paul, thanks very much for these very clear instructions, I’ve just set it up and it seems to be working. I just wanted to check, is there a cost involved for the person making the call?
Hi Stuart, that depends on the type of number to you choose and the caller’s phone tariff. For example, I used a Liverpool 0151 number which is a geographic number and included in “free minutes”. Where it’s not (eg. From a Pay as you go mobile, or the most basic of landline packages for instance) then it’s just the same as calling your neighbour next door say.
Short answer: yeah it’s usually free for the caller 👍
Hi Paul,
This looks fab; thank you so much.
One question: can multiple people call in on the same number simultaneously, or will anyone other than the first get an engaged tone? Is there a limit to the number of concurrent listeners?
Thank you!
Hi Duncan, yes you can have multiple people calling at once and as far as I understand it, there’s no practical limit. More info: https://support.twilio.com/hc/en-us/articles/223180028-How-fast-can-I-place-or-receive-phone-calls-with-Twilio-
Hi Paul, this is fantastic, thanks so much for sharing this! I’m wondering – could this be used to make a live stream work? E.g. a facebook live?
Hi Pete, thanks – hope you find it useful 🙂 Do you mean to hear the live audio from the live stream in realtime, or are you thinking about playing the audio element of a live stream that’s ended but is replayable? Either way, I’m sure both are possible (I’ve not done it, but the documentation may provide answers).
To keep things simple you could record the audio from the livestream using an audio recorder on your PC like Audacity or Audition (tell it to record the Stereo Mix on Windows) and then save that as an MP3 in the same way.
Hope that helps!
Hi Paul
I’ve tried to build this but have been told that there is an error. When I look at the accepted content there seems to be a 5MB limit on audio content, and our sermons on MP3 come in considerably over that. Any thoughts on this? How did you get yours to play?
Thanks
Ash
I’ve seen a few people get similar errors, not sure what it’s triggered by (not had time to look into it properly) but I can confirm there’s definitely no problem with larger MP3 files – ours are 30-40MB at least. Can you let me know the exact URL you’re using and how you’re sharing it etc.?
HI Paul
Thanks for your willingness to help. The URL is: https://standrewskirkella.churchbuilder.org.uk/pjp/mediafile/mp3_player?fname=media-library%2F2020%2F03%2F2020-03-08-10-45–07ef4d996e22efc32b4916a622271f97.mp3
Which is a bit of a mouthful. I’m pretty sure this is available to the public.
Ash
Hi Ash, I’ve had a little dig around your website and I think this address might work:
https://standrewskirkella.churchbuilder.org.uk/pjp/mediafile/passfile?fname=media-library%2F2020%2F03%2F2020-03-08-10-45–07ef4d996e22efc32b4916a622271f97.mp3
[Basically change the /mp3_player? bit in your URL to /passfile? instead.]
If I click that, the MP3 file immediately downloads so it looks like it’s serving it in a way that Twilio will accept, but without actually trying it (or analysing further) I can’t be sure. Give that a go though and let me know how you get on!
Hi Paul
Very frustrating. I agree, I can click on your link there and download it. But having changed it I have tried to call the number and it doesn’t work. What’s next?
Ash
The easiest thing to do if that’s still not working would be to place the MP3 file on either Google Drive or Dropbox and then follow the steps in the article for whichever one you choose. Each week, or whenever you want to change which MP3 is played, just upload the new MP3 to Google Drive / Dropbox and then update your Twilio function.
Yup – that worked very nicely for me!
Is anyone else getting stuck at “Validation Error We could not validate your address. Make sure these details are correct and try again.” when asked to “Add Company Address” when upgrading?
Have you sorted it yet? If not, I’d give Twilio Support a try (Submit a Ticket in your account: https://www.twilio.com/console/support/tickets/create )
Alas no! Have tried so many permutations. But have a ticket open with them.
I had some fun adding a short menu, with options for “Today’s prayer topics” as well as the most recent sermon.
ah excellent! Yes there’s so much more you can also do – I kept this simple so as to be useful for the biggest number of people but it’s great you’re doing more! Hope you get the address issue sorted quickly.
Twilio support have been really good and this has now been sorted. Conversely, it now looks like we might be doing multiple MP3 sermons per week, so may need to build some sort of navigation…
Paul,
Thank you for this excellent tutorial which I have followed and almost achieved success. I dial my number (01766 800223) and get through and am invited to press any key to hear my mp3 file but then nothing when the message stops except for three bleeps.
I append my Function and the only area I can see where I may have gone wrong is in the URL.
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse( );
twiml.play (‘https//www.cricciethfamilychurch.org.uk/sermons/ephesians-3’);
twiml.hangup();
callbac(null, twiml);
};
The file I have listed is on my Church website and the URL I have entered in the function above brings the file up if entered into my browser just leaving me to click play. Can you suggest where I have gone wrong.
Many thanks.
Andrew Bradley
Criccieth Family Church.
You need the actual MP3 file in the URL bit, it’s no good being a webpage that brings up the file, the function can’t play that, it needs the actual audio file.
I’ve had a look at that page and it looks like you’re hosting your MP3 files on Amazon S3 (which is brilliant) and under the audio player there’s a download button which says “Audio”. That tells you the correct URL you’ll need to use, which for this example is: https://s3-eu-west-2.amazonaws.com/cfc-wp/wp-content/uploads/2020/03/Ephesians-3-1.mp3 (on Google Chrome, right-click that link and select “Copy Link Address”).
Quick two other points: you’ve lost a “k” from the “callback(….” line of code – make sure you copy and paste from my article (don’t type it all out). And also you’re missing the : from the https:// at the start of the URL – again, always make sure you copy & paste 🙂
Thank you Paul for this excellent (and clear) tutorial, its a real blessing to be able to keep our vulnerable (non-internet) friends connected in this trying time.
Glad it helped you!
Thank you Paul. I am very grateful for that response.
Thanks for this guide, it’s great. One thought is that you it might be easier to host your MP3s inside Twilio as assets, which saves the last step with google drive/dropbox:
I found this worked by:
– going to assets subsection, just below where the functions are the runtime section (https://www.twilio.com/console/assets)
– uploading the file from my computer (as a public asset)
– then copy the url link to the file once it uploads
– then you simply replace the dropbox/google doc link with the link to the “twiml asset”:
the line with twiml.play should look like:
twiml.play(‘https://.twil.io/assets/.mp3’);
Oh amazing, I didn’t even know you could do that! That’ll be really useful for people who aren’t already hosting mp3s publicly. Thanks!
Hi Paul, loving this. I got it all setup to play our uploaded mp3 files from out website, and calls were connecting. However looking through the call log it seems that they drop off after around 10 mins and this was confirmed when talking to those using the service. Could this be that the call is deemed inactive because it’s one way, and therefore the phone line automatically cuts outs? No problem connecting the call, but it would be great to get it to last for say 20/30 mins rather than just 10. Thanks so much again Paul this is a great initiative.
Hi Toby, glad you’ve found it useful 🙂 Not sure why it would cut off after 10mins, we’ve had some 16min calls for our first sermon which went on it yesterday. Sounds like it might be a fault as the documentation says it won’t drop the call until 40 minutes and suggests splitting the MP3 into smaller chunks of less than 40mins. I’m no expert though with Twilio, so I’d get in touch with their support if it keeps happening to you: https://www.twilio.com/console/support/tickets/create
Thanks Paul, can you clarify what you mean by smaller chunks? The mp3 i linked it to was I think 33 mins- guessing that should have worked? I may contact twilio too. Thanks again.
“smaller chunks” = of less than 40 minutes, or so the documentation says. So your 20/30 minutes should be fine, if the calls are dropping I’d guess it’s for another reason. Maybe it’s the provider that the caller’s going through which is dropping the call if it doesn’t hear the person who dialed speaking? I don’t know, I’m just guessing. Maybe try calling your number and make sure you say something every few minutes and see if that stops it dropping – I’d be interested to know 🙂
Hi Paul- one another question. Might you know how to change the function so that rather than playing a mp3 file, it connected to live streaming audio?
I don’t know if that’s possible, sorry. If you find any info on it, let me know!
Hi Paul, sorry to bombard you. I was looking at limitations of the free trial account which state for voice:
Programmable Voice
Outbound trial calls can only be placed to a validated phone number. Before attempting to place an outbound call, be sure to verify the number.
Some high cost and premium access numbers aren’t reachable by default; for help enabling calling to countries outside of the US and Canada, please see our Geographic Permissions article.
Calls to and from your free trial phone number will play a short trial message before your TwiML is executed.
Trial accounts can only use your account’s Twilio number, or a verified caller-ID, as the caller-ID (From number) when making outgoing calls.
Outbound trial calls are limited to 10 minutes.
Incoming calls on a trial account can’t be recorded unless they’re forwarded elsewhere with a TwiML command with the record attribute.
A maximum of 5 total inbound and/or outbound concurrent calls are possible. When 5 calls are active, any further requests will be rejected with Error 10004: Call concurrency limit exceeded for account.
Perhaps my issue was the outgoing 10 min call? Although I would have though they were incoming calls… that’s the only trend I can find so far!
Ah, if you’ve not upgraded your account yet then do that. Add £20 credit and if you signed up with the link in my article you should also get another 10 free
Thank you so much!!
I’ve found that if I just call the Google Drive file “Sermon.mp3”, when I drag and drop the new sermon in, the old is replaced, and that’s all I have to do! Twilio has the new file.
Thanks very much.
Thanks Paul ~ this great got it working! what is the cost for people calling the number i’ve setup?? Also does Twilio have a uk customer Service number??
Hi Simon, great – glad you got it working! The cost for calling the number is just whatever they’d pay to call a normal phone number, so it depends on their package with their landline or mobile provider. If you’ve chosen a “local” number (officially called “geographic number” these days I think) like 0151 for Liverpool or 0121 for Birmingham, then it’ll be just the same as phoning their next door neighbour – and of course, included in “free minutes”.
Regarding a phone number for customer service, I think telephone support is only available if you pay for a support package, otherwise you can raise a support ticket inside your account for email support.
Yep, I did that and it’s all groovy now!
I set this up today (Monday) to stream the sermon from yesterday (Sunday) to folks who don’t have computers to watch the live service. Because I had trouble with the Google Drive instructions, I loaded the .mp3 to my website and just named it “sermon.mp3”. Every week, I’ll copy over it with the current sermon. This way I can leave Twilio alone and it should always have the most current sermon.
I’m in Saskatchewan Canada and with the trial account, I get the voice telling me it’s a trial and when a key is pressed I get a couple of rings before the sermon starts. That wasn’t in your instructions and it caught me off-guard.
Great, glad you’ve got it working! Which bit wasn’t in my instructions?
Thanks Paul,
This is really excellent, I never thought I’d be able to set up a phone line with a recording of our service, but with your step by step instructions a non-technological individual like me has managed it!
I’ve just got a question about silence on the line when you first call it. We have about 23 seconds of silence before the audio begins. Our audio is 40 minutes long, I’ve tried it with a 20 minute file and the silence before it runs is 11 seconds – is this just time it takes for the file to load? I have moved the file to being a Twilio Asset as someone suggested above, I wondered if that would help, but audio doesn’t kick in any quicker.
We might just have to tell people it takes 20 seconds to load and suggest they take the time to quietly prepare themselves for what they are about to hear.
Thanks again, I am sure this will prove a blessing to a number of folk in our church and community.
Pete
Hi Peter, glad you got it working! Yes there’s a bit of a delay for me, too – although not always. It may be that Twilio cache the file for a while so the second (and third, fourth etc.) time it’s called it might load quicker, but I’ve not tested it enough to be able to say that with certainty. It makes sense that shorter audio files (which are therefore smaller in filesize) load more quickly. You could try ALSO using the synthesised voice to say “welcome, please wait…” instead of replacing it with the Play() function, if that helps to break the silence and keep people informed.
Hi again Paul, another question,
In one of the comments below someone suggested having some navigation at the beginning of the call which would enable more than one mp3 file to be selected. I’m guessing the idea is along the lines of what you get when you phone companies and you get number options, “Press one for…, press two for…” Is it possible to do this somehow?
This would give multiple possibilities, I would particularly like to be able to do the first one, such as:
1) Press 1 for the full service, press 2 to begin at the Bible reading, press 3 to begin at the children’s talk, press 4 to begin at the sermon…
2) Press 1 for the morning service, Press 2 for the evening service
3) Press 1 for this week’s service, Press 2 for last week’s service
What do you think?
Thanks,
Pete
Yes you can do that, look for IVR menu in the documentation
Great!
I inserted an extra line above the twiml.play(‘*****’); line.
The line I inserted is as follows:
twiml.say(‘Hello and welcome to Little Mill Church, it is great you can join us, the service will begin in about twenty seconds’);
Thank you.
Great!
I inserted an extra line above the twiml.play(‘*****’); line.
The line I inserted is as follows:
twiml.say(‘Hello and welcome to Little Mill Church, it is great you can join us, the service will begin in about twenty seconds’);
Thank you.
Great!
Thank you so much – this was the answer to exactly what we were looking for. We were faced with the challenge of getting the Sermons to dozen or so precious elderly church members with no IT solutions – this did it, thank you.
OK, so here’s roughly how I built a menu system. This is *not* a comprehensive walkthrough but more a “naming of parts”.
I have four “functions” set up. The “Main Menu” function (path: /menu) is the one invoked when a new call comes through. Its code is currently:
/**
* Simple Menu Template
*
* This Function builds a simple IVR menu. Learn more about at:
* https://www.twilio.com/docs/api/twiml/gather
*/
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
switch (event.Digits) {
case ‘1’:
twiml.redirect({
method: ‘POST’
}, ‘https://salmon-prawn-6390.twil.io/prayertopics’);
break;
case ‘2’:
twiml.redirect({
method: ‘POST’
}, ‘https://salmon-prawn-6390.twil.io/sermon’);
break;
case ‘3’:
twiml.redirect({
method: ‘POST’
}, ‘https://salmon-prawn-6390.twil.io/previous-sermon’);
break;
default:
twiml.gather({numDigits: 1})
.play(‘https://media.elmdonchurch.org/Dial-a-Sermon%20greeting%20v2.mp3’);
}
callback(null, twiml);
};
The greeting MP3 file plays the “Press 1 for prayer topics, press 2 for …” stuff.
You can see where it “redirects” the call to other functions. The paths in the twiml.redirect call needs to match the path of the other functions you have set up. For us, /sermon is essentially the function described in this blog post. /previous-sermon is the same but referring to a different MP3 file. /prayertopics is rather custom to our use.
Hope this is of some use.
That’s great, thanks for sharing 💪
I just tried this for our own church but it caused an error – can you confirm you entered this at line 3 of the code? Thanks.
So (Peter Hilder) does it look like this:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(‘Hello and welcome to Little Mill Church, it is great you can join us, the service will begin in about twenty seconds’);
twiml.play(‘https://www.buzzsprout.com/289410/2997925-singing-before-the-breakthrough.mp3’);
twiml.hangup();
callback(null, twiml);
};
Hi David Shutt,
Yes, that looks correct.
Hope it works for you too.
Out of interest I have now changed ours to “….the service will begin shortly.” as the timescale seems to vary.
On a separate point we have found that the sound quality is a lot better on a landline than a mobile phone.
Thank you so much
Paul – thanks so much for sharing this. It’s great to be able to offer a ‘telephone stream’ of our services alongside our Facebook stream for those who aren’t online.
I’ve tried everything, google drive, Dropbox, SoundCloud…I even used your info…still no go. I don’t get an error, when calling the number it only reads the info withIn the single quotations. HELPPppppppp
Hi Sylvia, can you post all the lines of code from your function?
Don’t forget to restrict the messages to one hour, in order to avoid charges!
Keeps asking me to make an address after buying phone number?
Why is it asking me for an address after i click buy phone number
Yes, that’s right – because you’re entering into a legal contact with them for a telecoms service (just like BT would need your address if you were getting a line fitted, or a new mobile phone contact from O2).
Doesn’t show uk in country list
make sure you’re not searching for “uk”, search for “United Kingdom”
I went with a slightly simpler version of the menu, using the simple menu example code. It needed more semi colons, basically at the end of everything, but works a treat. Now I’m just wondering if there’s any way to get it to reroute to the default at the end of playing – a kind of ‘would you like to listen to something else, please choose again or hang up…’
working code for simple menu is:
* This Function builds a simple IVR menu. Learn more about at:
* https://www.twilio.com/docs/api/twiml/gather
*/
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
switch (event.Digits) {
case ‘1’:
twiml.play(‘https://northernlightworship.s3.eu-west-2.amazonaws.com/voice+intro.mp3’);
break;
case ‘2’:
twiml.play(‘https://northernlightworship.s3.eu-west-2.amazonaws.com/dailyprayer/daily+prayer_27-3.mp3’);
break;
case ‘3’:
twiml.play(‘https://northernlightworship.s3.eu-west-2.amazonaws.com/sundayworship/Lent+4.mp3’);
break;
default:
twiml.gather({numDigits: 1})
.say(‘Welcome to a simple menu. Press 1 for introduction, 2 for daily prayer or 3 for sunday worship’);
}
callback(null, twiml);
};
Thanks again Paul 🙂
Can’t edit my original but it was really as simple as adding the gather line back in between the play and the break. Superb.
Thank you again – just helping Blaina Evangelical Church come on(dial)line with this! Brilliant – thank you.
Many thanks for this Paul. Just got St Mellons Baptist Church up and running to complement what we have on YouTube and SermonAudio for those without internet at home.
It looks like WordPress has “kindly” replaced the straight single-quotes in my code with pretty, curly ones – which don’t work in Twilio. Replace all ‘ and ’ in the code above with the straight equivalent.
Ah yes it will have done!
We’re getting cut off after about 30s. Any ideas?
Number is 01273 071140
Code as follows:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.play(‘https://hrbc.org.uk/wp-content/uploads/sermons/2020_03_22_AM.mp3’);
twiml.hangup();
callback(null, twiml);
};
We’ve paid the £20.
Hmmm not sure. Are the curly quotes around the URL just WordPress (this website) changing them, are they simple style in your code?
It could be your webserver not streaming it well as I see the MP3 file is on your web server. Try it on Google drive or Dropbox, or as a Twilio media asset and see if that helps?
Hi Paul, this is very cool! Just a quick note about Dropbox links. I’m pretty sure that if you have a file called “weekly-podcast.mp3” the link from Dropbox will go to that file. When you replace the file with next weeks MP3, you need to generate a new Dropbox link and change that in the Twilio code.
Hi Paul – excellent advice and worked well for us – you might like to alter the post to remind people that trial accounts limit the message length to 10 minutes
Not a bad idea – I’ll do that now, thanks! 🙂
source for 10 minutes limit comment is https://www.twilio.com/docs/usage/tutorials/how-to-use-your-free-trial-account#trial-account-restrictions-and-limitations
The curly quotes must be a wordpress thing. Dropbox worked for us – thank-you
Thank you very much for this article. Very, very helpful in setting up a valuable service for those in our church who do not have internet.
This looks excellent – exactly what the non internet section of o ur congregation needs. So excited to use it and have the techy stuff set up ok – I think! But i don’t seem able to buy a number??? (In Manage my numbers, there are no numbers listed – I had hoped there would have been the one I thought I had bought.) At one point I saw a message about there being a delay in getting numbers validated because of demand at the moment. Do you have any ideas?. Thank you!
Under Phone Numbers / Manage Numbers you should see a red circle with white + inside it, click to buy a new number, which will take you this page: https://www.twilio.com/console/phone-numbers/search
I’ve just tried and it allowed me to view a list of numbers available and I could have purchased one… so I’m not seeing any messages about demand. But best to check with them!
Hi Paul – thanks so much again for this. I’ve seen someone comment on the silence on the line before the recording starts. I’ve been talking with Twilio help – and they say the problem is at this end rather than their end. They say, there is an extra link inserted in the code.
If you emailed me I can forward their emails and hopefully it will make sense to you. Mu knowledge of all this is limited to this awesome web page!! My email is ***@btinternet.com
Thanks!
Iain
.
Thanks, I’ve emailed you! (And removed your email address from comment so you don’t get spammed!)
Paul this is article is great thank you very. We use soundcloud to host our podcasts which is also linked to our church suite account. I have put the sound cloud address first for the playlist – which gave an error message when I phoned the number – and then for an individual sermon but same error. Any thoughts or should I host it simply in dropbox? I just have a personal dropbox – is that any good?
thank you…
Hi Robert – you’ll need to get exact URL of the direct MP3, so the general soundcloud address won’t work as that’s for a web page containing all the various elements that you’d see on your screen (sound cloud logo, text, layout of page etc.) when it’s JUST the MP3 that you want. I believe you can enable RSS feed on your soundcloud account and then the direct MP3 URLs will be in there… failing that, yes using Dropbox will probably be easier (or just upload to Twilio as a media asset).
Hi Paul
I need your help..! I had it working using a dropbox link but that was my private account so I wanted to get on our Church’s Google drive 🙂 So it copied the mp3 file into a shared area and the shareable link is ‘https://drive.google.com/open?id=1u2rlUTFsHVnyYGbyMyoffT2j28YCGMGa’ but I didn’t understand for instructions ;( sorry. I tried the following line but it didn’t work 🙁 what I am doing wrong??
twiml.play(‘https://drive.google.com/open?id=1u2rlUTFsHVnyYGbyMyoffT2j28YCGMGa.mp3’);
Many thanks in advance 🙂
Simon
Thanks Tim ~ it works..! and I don’t have to worry about using Google drive or DropBox…! Brilliant 🙂 Take care & stay safe 🙂
Hi Paul. Thank you so much for your extremely helpful instructions. I have just managed to set this up for St James Church in Birkdale where we have an older congregation, many of whom do not have email or internet access to listen to our podcasts on line. So this will be a great help to them. One question – having now upgraded from the trial account how do we add a short Welcome message that gets played just before folk would listen to the podcast. The original trial introduction message has now gone and I want to replace it. Many thanks,
Chris
Hi Chris, that’s great that you’ve got it all set up 🙂
This is the line you’ll need:
twiml.say(“Welcome to Saint Anne’s. This week’s sermon will start shortly, please wait a moment.”);
(make sure those are standard double quotes and apostrophe – it may make them fancy ones here in the comments.)
In fact, I’m going to update the article to suggest leaving this in, as a lot of people (us included) have ended up doing so now!
Yes, we have too. It’s especially helpful if there’s a couple of seconds of silence at the start of your recording, that you don’t want to edit out.
Hi Peter, thanks for this addition. I copied your code above but it gave a function error so I raised a ticket and was advised that the quote has to be ‘ not ‘ like this:
twiml.say(‘Hello and welcome to Saint Jude and Saint Pauls Church, it is great you can join us, the service will begin shortly’);
People who aren’t familiar with Dropbox may find the following helpful.
First, you need to set up a Dropbox account. Go to https://www.dropbox.com, thenm on the middle left of the page (underneath “Try for free for 30 days now” and “Purchase now”) you’ll see “get Dropbox basic” – click on this and follow the simple instructions to set up an account.
Once you’ve done so:
1) Go to “upload files” on the right, and chose the mp3 audio file you’ve created.
2) Go to the file in Dropbox, and click on the three dots you’ll see on the right of that file.
3) Click “Share”
4) A box will pop up. Ignore most of this, just look to the bottom of the box where it says “Share a link instead” and click “Copy link” at the bottom right.
5) Now look to the left of your main Dropbox page and click on “Shared” (underneath “Home” and “Files”).
6) On the ‘Shared’ page, click on “Links”.
7) Click on the relevant file.
8 ) A new web-page / tab will open of that file. Copy the whole URL (the website address, starting https://www ) of that page.
9) THIS is what you paste into the the function that Paul gives in the excellent walk-through above.
i.e. – you copy and paste the function he gives into the code box, then where he has as an example (‘https://sermons.stannesaigburth.com/08Mar2020.mp3’)
you delete everything between the (‘ ‘), and copy in your Dropbox file link – not forgetting, once you’ve done so, to add &raw=1&t=.mp3 to the end of the file link, as the walk-through tells you to do.
Thanks so much Paul for posting this really thorough walk-through. My parishioners without internet access have really valued being able to ring and and hear Sunday’s sermon 🙂
Hi Paul,
This has been a huge blessing to us. Just a quick comment for if anyone else is having the same problem: there is a limit to the length of a recording that it’ll play at once of 40 minutes. If (like us) your service is longer than that, you simply need to split the mp3 into two, and do two lines beginning twiml.play(
There’s also a significant pause for us as it loads the file (even though we’re compressing quite significantly to get it as small as possible), so I’ve actually put an introductory recording (via a third twiml.play line) at the beginning welcoming people to the St Andrew’s service line and warning them of the pause, as a few were hanging up after 20s of silence.
Just thought I’d comment in case it helps someone else!
Duncan
Paul
Thank you for that. It worked great. As you correctly mentioned there is a need to make sure the double quotes are the correct type.
With a little further experiment I also discovered that we can add a separate MP3 Intro or Welcome voice file to precede the sermon by duplicating the twiml.play line. Maybe that’s stating the obvious to some.
Many thanks
Chris
Yes, it’s like building blocks so you can do whatever you like 👍👍
there was no buy now having chosen number just next. I clicked this and then got question who will use this number business or individual? As using it for church which do I pick?
I chose business. You’ll be asked for your address at the next step, and there’s a drop-down where you can select any addresses you’ve added to your account. If you need to add one, click the red +
Hi,
I think your walk through of this has been brilliant…BUT I’m not quite there yet…hopefully not too far off.
When I call the number it just gives me a message which is basically saying there is a problem and the URL isn’t correct. We have the MP3s on the church website but I guess it’s not quite right. Can you help please – I’ve been using this one on the account.
https://www.maxwellmearns.org.uk/Media/PlayMedia.aspx?download=file&media_id=245692&file_id=261499
Hi Martin, great that you’re nearly there 🙂 That “PlayMedia.aspx” script must do something along the lines of take the media_id and the file_id, do “something” on the backend of your website and then respond by telling the browser to download the MP3 file. That’s fine if you’re accessing it in a web browser, but as the Twilio system isn’t a web browser, it can’t speak web browser language so it won’t work because it needs the actual public URL of where the MP3 is sitting on your web server (assuming it’s in a public location!) I’ve inspected your website’s media player and it’s using a similar thing, so I can’t derive an actual unique URL for the MP3 files, and without access to the backend scripts I can’t see how it’s structured.
So, you’ve got some options….
1) If you can find out the public URL for the MP3 file, if there is one, use that.
2) Use Dropbox or Google Drive
3) Alternatively, upload the MP3 directly to Twilio (look for Assets under Runtime, underneath Functions in the menu)
Hope that helps!
Hi, I commented with a question earlier re the url not seeming to be correct, ie when i made the call thats where the issue is I think. I when placed the mp3 in Dropbox which I think going forward would be the best idea – but this didnt work either (and I added the part at the end of the code as you instructed). Any thoughts.
this is where I am at the moment using the drop box option.
any help appreciated – Martin
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Welcome to Maxwell Mearns Castle dial a sermon. This week’s sermon will start shortly, please wait a moment.”);
twiml.play(‘https://www.dropbox.com/s/1aan3qbrpcagf3n/Palm%20Sunday%205th%20April%202020.mp3?dl=0&raw=1&t=.mp3’);
twiml.hangup();
callback(null, twiml);
};
Make sure the URL on the play() line is in double quotes, not single. [I’m assuming the fancy double quotes in the say() line are WordPress’ doing] I’d remove spaces from the MP3’s file name, just in case (use dashes instead). The MP3 is definitely public as I’ve just successfully downloaded it – so try again with the double quotes and let me know 🙂
I noted your Asset comment – i think its too large. Keen to get the dropbox way of doing it working as that seems straightforward…although, here I am asking you for help with it 🙂
Hi Martin, I notice that you have some spaces in your filename. It might be worth removing those, and trying again.
Hi, thanks for your reply, and patience!
just to clarify it should be Say with a double apostrophe and then the message
and Play with single apostrophe and then the url with mp3??
here is where I am now – using drop box option but still getting the same message when i call.
martin
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Welcome to Maxwell Mearns Castle dial a sermon. This week’s sermon will start shortly, please wait a moment”);
twiml.play(‘https://www.dropbox.com/l/scl/AADh6lw6Ghnb6e6GpQL4b80HzQj7os6Z5ak&raw=1&t=.mp3’);
twiml.hangup();
callback(null, twiml);
};
Simple, double quotes on both
bummer…still getting the same message.
I am saving it and it says it’s deployed…not sure what to do now?
Martin
thanks for your comment – not sure where the spaces are you refer to.
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Welcome to Maxwell Mearns Castle dial a sermon. This week’s sermon will start shortly, please wait a moment”);
twiml.play(“https://www.dropbox.com/l/scl/AADh6lw6Ghnb6e6GpQL4b80HzQj7os6Z5ak&raw=1&t=.mp3’”;
twiml.hangup();
callback(null, twiml);
};
i now have this – I made both double “
Hi Martin, I’m not sure what you’ve done to your Dropbox URL as the filename of the MP3 has disappeared! It should be this:
https://www.dropbox.com/s/1aan3qbrpcagf3n/Palm%20Sunday%205th%20April%202020.mp3?dl=0&raw=1&t=.mp3
The spaces are in the actual filename of the MP3 file – changed automatically in what you’ve copied from Dropbox to %20 – a percent sign followed by a two digit code, 20. That’s computer-speak for a space, but best to avoid it altogether by renaming the file on dropbox to have no spaces, and then copy the share URL again (not forgetting to add the bits to the end).
In your most recent code you’ve posted, as well as the Dropbox link not working (you can always paste it into your web browser’s address bar in a new tab to test) you’ve also got a superfluous extra single quote before the double quote at the end, and the close bracket is missing before the semicolon which ends the line of code, so that will further confuse things.
So, your code should look like this:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say("Welcome to Maxwell Mearns Castle dial a sermon. This week’s sermon will start shortly, please wait a moment");
twiml.play("https://www.dropbox.com/s/1aan3qbrpcagf3n/Palm%20Sunday%205th%20April%202020.mp3?dl=0&raw=1&t=.mp3");
twiml.hangup();
callback(null, twiml);
};
(Edit – sorry, pasted wrong URL in code example!)
Brilliant! I’m not very techie, but I got it working with your code, then took a deep breath and went to Nick’s site. Still in Trial mode, but now picking up our Squarespace audio blog. Thank you so much for this.
This looks like a great tool – thanks for working this up!
I seem to be having trouble quite near the beginning – I’ve followed the steps exactly as laid out, but when I try to buy a phone number, I click on “buy” and nothing happens. I’ve refreshed, gone back and tried again, and the same thing keeps happening. Any advice?
No worries! Are you stuck on the screen where you have to assign the phone number you’re buying to an address on your account?
Wonderful, thank you! Is there any way to add a voice at the end – thank you for calling, or similar?
You can indeed! Just add another say() line (like the one before the play() one) at the end BEFORE hangup, and ‘say’ what you like! 🙂
hi again,
I’ve decided that not being too proud to ask for help again is good for my character building 🙂
But I really dont want to waste you time – I’m normally okay at working these things out and your instructions are good so it’s really frustrating.
I’m beginning to wonder if there another issue?
the message I get when I use my number is ‘configure your numbers voice url to change this message’ and then cuts out.
I’m using the below:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Welcome to Maxwells dial a sermon. This week’s sermon will start shortly, please wait a moment.”);
twiml.play(“https://www.dropbox.com/s/1aan3qbrpcagf3n/Palm%20Sunday%205th%20April%202020.mp3?dl=0&raw=1&t=.mp3”);
twiml.hangup();
callback(null, twiml);
};
haha no not at all don’t worry! 🙂 It sounds like you may not have completed Step 4 fully, have you been into Manage Numbers, and changed your number’s setting under the “when a call comes in…” heading and told it to execute a function, and then the function you’ve created with that code?
Hi Martin, I think your quotes are still a bit odd, try copying and pasting the code here: https://gist.github.com/snim2/12773229a83ac9dc36cd1084b64641d9
Hi – did anyone get any feedback from Twilio about the silence before a larger size file is triggered? I can find the query in the thread but not the answer. OR is there no fix and folks will just have to get used to it. Apart from that, the menu system and everything else is working fine – thanks again Paul.
As far as I can ascertain this is just the loading time, so there’s not a simple, one-size-fits-all guaranteed “answer”, as it were… it’s just like trying to make your website load more quickly.
Things I’d suggest to keep the loading time to a minimum;
– Keep the filesize low.
— Make sure it’s MONO as the phoneline is mono anyway, so stereo would needlessly increase filesize (and therefore loading time)
— Make sure it’s exported at an absolute maximum of 128kbps – even that is much, much higher quality than needed as it’s converted by Twilio to a lower bitrate for playing down a telephone line.
– Make sure you’re hosting it somewhere fast, ie. where it’ll load quickly from. I host my files on Amazon CloudFront which provides fast-loading storage and geolocation so it’ll load from geographically closer to the source
– Dropbox and Google Drive will work, but they’re not geared towards fast loading
– If you’re hosting the MP3s directly on your website, alongside all the other assets that make up your web pages, then don’t. Lots of people on your website at once will make the MP3s load more slowly in that moment.
– Try hosting the file as a Twilio Asset (look down the Runtime list a couple of options past Functions) and see if it loads faster from there.
I hope those tips are helpful. TL;DR – keep the filesize as small as possible and host it somewhere geographically close to Twilio and with fast hosting!
that’s great – I assumed that it’s just down to file size but tips on faster loading times is much appreciated. I’m setting this up for various churches so am trying to find a balance for drag and drop/copy and paste files each week without a church have to enter Twilio plus faster loading BUT either way it all works well. Thanks again
Hope you can help! I followed your excellent instructions and everything was working ok, then I decided to play around and see if I could merge 2 mp3 files, so that people could listen to the sermon and music for example. Now I can’t get it to work, even using the original file! When I dial the number to check all ok, I get the ‘trial account’ message followed by a long pause and then a tone (like number unobtainable). Any ideas? My link is https://www.dropbox.com/s/b8i5g8cntk68uvk/Welcome%20Palm%20Sunday%20.mp3?dl=0&raw=1&t=.mp3
‘Weeping may endure for a night, but joy cometh in the morning’
It worked…It was probably the managing of the numbers AND the code. Thanks again.
Just completed the project and it worked a treat (we use the amazon aws server), thank you so much, this will really help some of the more disconnected people in our congregation, I’m already looking to see what extras we can do as we have a morning and evening service including a thought for the day.
Hi Paul,
Have just discovered this amazing facility. The race is on! Can I get things set up before Easter Sunday for our church in Rayleigh, Essex?!
Certainly your notes are incredibly clear – thank you. I’m anbout to start.
One question: Does the audio file have to be specifically in .mp3 format or is it possible to use and .m4a file? (I’m sure that means something to those that know – sadly ‘way above my intellectual payscale’! Many thanks. Keith
Hi Keith, great stuff! Yes you’ll be up and running in no time, the instructions should only take a few minutes for even novices! I don’t know off the top of my head, without looking it up, if Twilio will support an m4a file so if it doesn’t work, just convert it to MP3 or save/export again as MP3 from whatever you’ve edited the service/sermon in. Failing that, use a free online converter.
A note about quality: since it’s being played down a phone line and re-encoded for that by Twilio, don’t waste filesize on super high quality audio, it’ll just make it take longer to start playing for the caller. Likewise, don’t bother with stereo!
Many thanks for that. I’ve successfully converted to a 128kbps file. I seem to have hit a bit of a blank! At Step 4, when I click on ‘Manage Numbers’ (despite the fact that earlier it showed me I’d bought a number) no number shows – just three headings : Get Started/Tutorial Docs/Learn More. If I click Get Started, it implies I need to ‘get my firstnumber’ – but I’ve already got it! Any thoughts? Thanks
Hi Paul, Really helpful post. Wanted a way to help our older, and less technically adapt members engage with Sunday services. your notes were really clear and we have now got dial up access. Bless you for sharing
Hi Paul
Thanks again for highlighting this excellent tool 🙂 it has already blessed many people with our church family who don’t have access to the Internet. It has been featured in our latest Diocesan eNews, see: https://www.dioceseofnorwich.org/news/dial-a-sermon-being-church-wherever-we-are
I have one final question… is it possible to reduce the pause between MP3 being played?? We have a brief welcome message followed by the latest sermon with a closing message at end. All 3 files are on seperate lines of code.
Any ideas??
Many thanks in advance 😉
Cheers Simon
Ah great article! It would be great if it could link to this page as well, so others can see my instructions 👍 regarding the pause, ensure that there MP3 filesize is as small as possible (low bitrate and mono, as it’s only being played down a low quality phone line) and host it somewhere geographically close to Twilio and which is designed for fast media asset hosting for lowest possible latency. We use CloudFront (aws) but you can also just host the files with Twilio themselves – look under assets. Lower filesize and faster hosting will mean faster load times, just like for a webpage 👍
Hi Paul, I am not IT literate but trying to set up a Dial-a-Sermon link. I have got to setting up the code, I get the welcome message OK as typed in, but keep getting ‘”application error” messages when it goes to playing the mp3 file from Google Drive at line 4. The URL I have in is – https://docs.google.com/uc?export=download&id=1rQ5cm5ID2mGLBxPQhyNWyHnS7D0Qfpxr What am I missing?
I will be grateful for your help. Fraser
Can I see the rest of you code, too?
Hi, my macbook recordings come out as .mp4 files. Do I have to convert them to .mp3 or is there a way to play the .mp4 please? It would eliminate a step for me. Thanks.
MP3 audio only 👍
Hi Paul,
Just a brief note to say, please don’t waste any time on my second query from 12:51pm on 10th April . After many attempts of trying to recover, I think the technology must have swallowed up the number somewhere and hidden it, so I started from scratch on a second number, feel smug at having added a farewell message and now everything working very smoothly. Brilliant! This is in no small way to your excellent, thorough and very clear guidance.. Many thanks pAul – you are helping many folk in the process. Take care : stay safe.
Keith
Great, glad you got it sorted! It’s easy to lose a number you’re halfway though buying if you don’t already have an address on the account so that may have happened 👍
Hi Paul,
Is thsi what you mean by “..the rest of my code.”
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Hello Welcome to Cadder”);
twiml.play(“https://docs.google.com/uc?export=download&id=1m07cfBhV4JtDZQhlKQC-S4Tael_POZH”);
twiml.hangup();
callback(null, twiml);
Thanks for your help.
Fraser
Hi Paul, is there any way of giving people an option to listen to one of a number of options? Like, “press 1 for…”, or “press 2 for…”? Currently I’ve set up 3 separate phone numbers but it would be great to have it on the one number and then give people options?
Yes there is! I didn’t include anything fancy in the article as I wanted it to be as simple as possible for everyone, non techies included, but you can do all sorts of things! I think one of the comments here even has some sample code, otherwise check the Twilio documentation 👍
Paul, thank you so much for this very clear blog and walk through. It worked a treat and will be an invaluable asset to our ministry at our church in Shropshire. We use Amazon AWS S3 and that worked very easily. I have even managed to move on further into Studio Flow and we now have 3 options on our 1 number so listeners can press options for Morning & Evening Service and even a daily thought for the day. I am happy to help in anyway to guide through the creation of menus. The studio flow is a great application which makes it so simple for non coders like me. Any way thanks once again, our congregation are already benefiting greatly.
That’s great to hear! I’ve been absolutely blown away by the response to this, I’m so glad that so many people have been finding it useful and that even more are benefiting from it! Take care 🙂
Hi Paul,
Is thsi what you mean by “..the rest of my code.”
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Hello Welcome to Cadder”);
twiml.play(“https://docs.google.com/uc?export=download&id=1m07cfBhV4JtDZQhlKQC-S4Tael_POZH”);
twiml.hangup();
callback(null, twiml);
Thanks for your help.
Fraser
Hi Paul, I did say I wasn’t IT literate! I have been doing a bit more work and I think you were asking for the code of the file I was trying to play. This is it https://drive.google.com/file/d/1rn07cfBhV4JtDZQhlKQC-S4TaeI_POZH/view?usp=drivesdk
This is only a sample ‘welcome’ until I can get it working and then I can replace it with the mp3 of the service.
Hi Paul,
Many thanks for the step by step guide.
I EVENTUALLY, got there.
I had two main problems to overcome;
1) I couldn’t get it to work with Google Drive, so eventually downloaded Dropbox which made things a lot easier and I thought I had ‘cracked it’.
2) However the next problem was the format and size of the Easter Sunday video on YouTube. It took me some time to get it changed to mp3 format which reduced the size, so now working.
Many thanks.
Fraser
Many thanks for this , Paul – wouldn’t have known this was a relatively easy thing to set up. Great instructions. Having an MP3 of the service available for people who aren’t really online is an important thing to be able to provide.
hi,
we have just gone live having upgraded and started paying.
I was looking for an idea of what the costs will be – I know it says there is round about 80p per month but what are the additional costs assuming say, 10 or 20 people use it. (leaving aside any costs that the individual might incur from their own telephone charges)
You’re charged 1 cent per minute (less than a penny) from your account credit each time someone calls. So if two people call and both listen to an entire half-hour sermon that would be 30c x 2 = 60c or 48p at today’s exchange rate (for example).
Help! I’ve followed the instructions but it is no longer connecting. When I first tried it a few days ago the number rang through to the automated message. Ive upgraded today, but now it is no longer ringing through. I’m getting error codes 11200 retrieval failure and 82002error on function response. No idea what I need to do to solve this.
Retrieval failure will refer to where it’s loading your MP3 from – where are you hosting it and how’s it being shared?
I would like to break up the silence before the audio kicks in. I don’t understand this answer… “using the synthesised voice to say “welcome, please wait…” instead of replacing it with the Play() function” instead of replacing what? I have three twiml.say lines (helps me as I only need to edit one each time) followed by a twiml.play call, what are you suggesting? Thank you.
To reduce the silence (ie., loading time) before the audio starts playing, make sure it’s as small a filesize as possible (mono; no more than 128kbps, less is better) and host it somewhere with fast storage and low latency to Twilio. In layman’s terms, that means host it on a good host, Dropbox and Google Drive aren’t the best but do work. You could upload them to Twilio itself for best results (look at Assets in the menu)
Hey folks – just sharing my menu options that I’ve finalised for summer term for churches now that easter one off’s are over. Structure is dial, 15sec welcome message with menu option 1 for Sunday, option 2 for Wednesday plus note there’s a short delay. Then option 1 plays Sunday or option 2 plays Wednesday and after each message finishes there is a 20sec ending message with how to get int touch details, AND THEN it loops back to the welcome menu so that people can listen again or listen to another message without the line just hanging up. I hope the code makes sense then – you can add as many options as you want so just replicate each bit of code e.g. case ‘3’ … break; case ‘4’ ….break; and so on so that after every option and end message plays it loops back to a welcome menu. There are several different ways of doing this in what is said or synthesised but the structure works in the same way. Hope this helps (p.s. no curly quotes! & folks aren’t bothered by the short delay as it means they get comfy!):
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
switch (event.Digits) {
case ‘1’:
twiml.play(‘https://docs.google.com/uc?export=download&id=1lQuewsIsZLKaPM2vCkvyN9Bt_OUdBpLH’);
twiml.play(‘https://docs.google.com/uc?export=download&id=164T_1Sdxd_w9QMvTsh_9fHa2BVCmgjBD’);
twiml.gather({numDigits: 1})
.play(‘https://docs.google.com/uc?export=download&id=1kXU7X1BcpU43PORfhZ2f-FTB57uVXF2y’);
break;
case ‘2’:
twiml.play(‘https://docs.google.com/uc?export=download&id=1-ksqPSRVF8VpwVkBuD9t1zC-4rs4m3BY’);
twiml.play(‘https://docs.google.com/uc?export=download&id=164T_1Sdxd_w9QMvTsh_9fHa2BVCmgjBD’);
twiml.gather({numDigits: 1})
.play(‘https://docs.google.com/uc?export=download&id=1kXU7X1BcpU43PORfhZ2f-FTB57uVXF2y’);
break;
default:
twiml.gather({numDigits: 1})
.play(‘https://docs.google.com/uc?export=download&id=1kXU7X1BcpU43PORfhZ2f-FTB57uVXF2y’);
}
callback(null, twiml);
};
I’m using my Dropbox. I don’t understand the rest of your question. Not done this sort of thing before.
This it what the error code says.
{
“message”: “twim is not defined”,
“name”: “ReferenceError”,
“stack”: “ReferenceError: twim is not defined\n at Object.exports.handler (/var/task/handlers/ZFf431e6e1f679805043f1fe503b1e4856.js:5:2)\n at Object.exports.handler (/var/task/node_modules/enigma-lambda/index.js:310:10)\n at Runtime.exports.handler (/var/task/enigma.js:17:9)\n at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)”
}
Ah you might have a typo in your code, can you post that?
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Welcome to Rev Jo’s sermon for this week. This week’s sermon will start shortly, please wait a moment.”);
twiml.play(“https://www.dropbox.com/s/jvo17jq6wketujz/Sermon.mp3?dl=0&raw=1&t=.mp3”);
twim.hangup();
callback(null, twiml);
};
HI Joanna – your typo is on the hangup line – it says “twim” rather than “twiml” – missing the L. If you correct that, it should work 🙂
(Did you type it out or copy and paste from the article?)
Fab. Working now. Thanks.
Great! 🥳
I’m also trying to deal with the silence, about 20 seconds between my synthesized intro and when the mp3 starts. I use .say() followed by .play() any suggestion? Thank you
Cloudlinker can help reformat GDrive links https://www.technorange.com/cloudlinker-direct-link-generator-for-dropboxgoogle-driveone-drive-copy-com/
I recorded a welcome message which I play first. I make it last about 16-18 seconds. This seems to fill the time while the main file loads. As part of the welcome message I ask people to wait a few seconds for the recording to start. This is working much better than the automated message I used initially.
Many thanks for your help 😉
Paul – thank you so much. Really excited to get this up and running (not quite on my first attempt but not because of your instructions!) Sadly, signed up using your link but did not get a $10 credit – hope you got yours though. Thanks again
That’s great Sue, glad you’re up and running! Have you upgraded your account yet and added credit yourself yet? It’s at that point that you should get another £10 free. Feel free to pass on your own referral code to others, as we have quite enough credit on our account now thanks to so many people signing up!
Can you please give a more detailed look at the fee structure for all this? If possible, US dollars would be helpful. Thank you!
Hi Laura, sure – the best place to go for pricing info is here: https://www.twilio.com/pricing
Essentially it’s a dollar a month to rent the phone number that you get people to call, and a cent a minute each time someone calls in. That’s all there is to it 🙂
Thank you for your excellent tutorial. I think I’m close to getting it right. My file is located in dropbox and here’s my code:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say(“Welcome to Brant Regional Ministries. This week’s service will start shortly, please wait a moment”);
twiml.play(“https://www.dropbox.com/s/yjh6j0vysohashk/audio_only_3.mp3?dl=0&raw=1&t=.m3p”);
twiml.hangup();
callback(null, twiml);
};
I call the number and get the intro recording but then get the message that “an application error has occurred.” I also notice when I save the code it asks me “Are you sure you want to save your Function without a path? Functions without a path will not be publicly addressable.”
What have I done wrong?
Give the function a path 👍😂
Hi Kendall, apart from the path issue, your Dropbox file should end in t=.mp3, not t=.m3p – HTH.
Good point, I missed that! That’ll teach me to reply to comments before my morning coffee 😂
Thanks. Dumb error.
Hi Paul,
Thanks for this!
I’ve built something that uses a combination of Zoom and Twilio to route people through to a live service on YouTube audio stream.
https://eastleightonstone.com/blog/54532
Hi Paul,
Thanks for this!
I’ve built something that uses a combination of Zoom and Twilio to route people through to a live service on YouTube / Facebook Live etc.
https://eastleightonstone.com/blog/54532
Hope that helps someone!
Many thanks Paul – another church now has a working SermonPhone! Our congregation members without internet – or possibly local insomniacs – will be very grateful for your excellent step by step guide.
Hi Thanks, managed to get everything up and running. Took me a while, but got there using google drive and converting my files through iTunes. Question re telephone number, I bought a mobile number, is this more expensive than a landline number?
It’s the same price for you to receive a call, ie. $0.01 (a cent) per minute. For folk calling, it should be included in their free minutes but will probably be more expensive if they don’t have free minutes. The monthly fee for you to rent the mobile number for people to call seems to be roughly the same, it’s coming up as 80.6p per month which is the same price as 01 numbers (but dependent on exchange rate, as it’s all in dollars….)
Super, thank you so much for this!
Hi Paul. I’ve use freeconferencecall.co.uk which is easy to set up, doesn’t use Dropbox, which I find to have a mind of its own and is only the cost of the phone call if any according to the owner’s contract. We have been using it in North Norfolk fro 4 weeks now and our folk are thrilled that it is so easy to get on line. Our only issue was that we tried it at 11.00am, our usual time for worship and the lines were so busy that several people couldn’t connect. We changed the service time to 4.30pm which was convenient to everyone, and had no more issues. I do highly commend it.
Yes I’d recommend using something far better than Dropbox (Twilio itself, if the mp3s are being produced exclusively for this purpose) or if not, a proper CDN like CloudFront etc.
Hi Paul, This is brilliant, just what we need! Thanks. I’ve got it working with Google Drive, but we mainly use Microsoft Sharepoints in our church. Any chance we can get it working with that? I’ve got to the mp3 file here:
https://sjlh.sharepoint.com/sites/WorshipSharepoint/Shared%20Documents/Dial-up-Worship/Current.mp3?App=OneDriveWebVideo
but still not working. Any ideas?
You’ll need to ensure that the MP3 is publicly accessible/shared so that no login or user permissions come into play. I’ve never used Sharepoint myself but I think you need to make an Asset Library and make sure it’s public… try that and see how you get on 🙂
I think I’ve fixed it, actually. Looks like all you need to do is add
&download=1
to the end of the normal public share link. Works brilliantly. Thank you!
Thank you for this very helpful advice and for your generosity in tackling the various questions that people are asking. Mine is to wonder whether and how it might be possible to use a Facebook live stream as a source that callers could access?
Hi Paul, have been working through the options for coding a menu. Probably trying to get too complex, but maybe you can see what I am aiming for and what I am doing wrong? Thanks in advance!
The code is:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
switch (event.Digits) {
case ‘1’:
twiml.say(“Welcome to the Sunday service from Brightons Parish Church on the 26th April 2020. The recording will start in about thirty seconds, please stay on the line.”);
twiml.play(‘https://www.dropbox.com/s/tgbvk0fw4p3irq4/20-04-26%20Cut%20service%20audio.mp3?dl=0&raw=1&t=.mp3’);
twiml.say(“If would like to go back to the main menu, please stay on the line. Otherwise, you can now hang up the phone. God bless.”);
twiml.gather({numDigits: 1})
.say(“Welcome to Brightons Parish Church recordings. Press 1 for the latest Sunday service, 2 for the latest Tuesday sermon or 3 for sunday worship, 3 for the Good Friday service”);
break;
case ‘2’:
twiml.say(“Welcome to the Tuesday Evening Sermon from Brightons Parish Church on the 7th April 2020. The recording will start in about thirty seconds, please stay on the line.”);
twiml.play(‘https://www.dropbox.com/s/r9tniujfhcxzzji/20-04-07%20Tuesday%20Evening%20Sermon.mp3?dl=0&raw=1&t=.mp3’);
twiml.say(“If would like to go back to the main menu, please stay on the line. Otherwise, you can now hang up the phone. God bless.”);
twiml.gather({numDigits: 1})
.say(“Welcome to Brightons Parish Church recordings. Press 1 for the latest Sunday service, 2 for the latest Tuesday sermon or 3 for sunday worship, 3 for the Good Friday service”);
break;
case ‘3’:
twiml.say(“Welcome to the Good Friday service from Brightons Parish Church on the 10th April 2020. The recording will start in about thirty seconds, please stay on the line.”);
twiml.play(‘https://www.dropbox.com/s/dp77xrzuprac80b/20-04-10%20Good%20Friday%20Service.mp3?dl=0&raw=1&t=.mp3’);
twiml.say(“If would like to go back to the main menu, please stay on the line. Otherwise, you can now hang up the phone. God bless.”);
twiml.gather({numDigits: 1})
.say(“Welcome to Brightons Parish Church recordings. Press 1 for the latest Sunday service, 2 for the latest Tuesday sermon or 3 for sunday worship, 3 for the Good Friday service”);
break;
default:
twiml.gather({numDigits: 1})
.say(“Welcome to Brightons Parish Church recordings. Press 1 for the latest Sunday service, 2 for the latest Tuesday sermon or 3 for sunday worship, 3 for the Good Friday service”);
}
callback(null, twiml);
};
But I am being told that an “application error occurred” when I call the number. In the logs, I get this message:
{“message”:”Invalid or unexpected token”,”name”:”SyntaxError”,”stack”:”/var/task/handlers/ZF0d823e5b575feed0a09b2af3ee3c42e9.js:4\ncase ‘1’:\n ^\n\nSyntaxError: Invalid or unexpected token\n at Module._compile (internal/modules/cjs/loader.js:723:23)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\n at Module.load (internal/modules/cjs/loader.js:653:32)\n at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n at Function.Module._load (internal/…
If you want to make a menu system, I’d take a look at the Studio and create a flow; much easier to see it all visually and use their drag-and-drop interface than wade through code 🙂
Hi Paul,
I’ve opened a free account with Buzzsprout to host my Anchor podcasts. When I call my number, it says the welcome message but then tells me that an application error has occurred. Any advice gratefully received!
If you follow me on Twitter (@paulfp) and send me a screenshot of your code and the URL of your podcast MP3 file, I’ll take a look!
Thank you Paul! I can’t believe I’ve managed to do this – thank you! Your instructions are very clear and a big thank you. It will mean a lot to those who have no online access – can’t thank you enough.
Great stuff, glad you could get it up and running! 🙂
Richard, I am trying to set up a short menu with say three options such as sermon; prayer for the sick; prayer for yourself. I have been wading through the Twilio stuff but it all seems to facilitate connecting to different phone numbers. I want to connect to different Mp3’s on Google drive. Would you mind helping me out, please.
Hey Paul, I followed your article and created a Dial-a-Sermon here in Harrington, Delaware for my three United Methodist Churches. It has been embraced by a few of my people with great appreciation. I have also taught a fellow pastor in our District how to build this. And I created a YouTube video explaining how I did it https://youtu.be/MuFKOeFTKR0 thanks to you. I appreciate your article very much!!!!! Thanks! Larry Jameson larryjameson@gmail.com
Just wondering more about the cost of things. How much will I actually be charged for local calls if I upgrade? Say for a 40 minute sermon and 20 people calling in?
If all 20 people listen to the whole 40 minutes, then it’s just simple maths:
($0.01 x 40) x 20 = $8 = £6.37 at today’s exchange rate.
Paul, thank you so much for all this information. I kept putting off setting it up, because it looked so complicated, I gave it a go last night and your instructions were so clear that it worked great. Next step is to set up a menu. What a great service, Thank you so much.