[ASTERISK] How to have a talking clock

It all started when I remembered the service offered by the Romanian landline/PSTN provider Romtelecom back in the 80s and 90s.

You used to call the number 058, later 958 and get a lady saying: “At the next signal, the time will be exactly <time>”

OK, so I though, how can I implement this in my VoIP setup.

So, here goes:

Requirements:

  • An already existing PBX where we will create the extension 958 that we can call
  • A Linux machine running Asterisk

Here are the configs, supposing that you already have the Linux machine up and running. In this setup I used Ubuntu 26.04 on ARM:

Install Asterisk

sudo apt update
sudo apt install -y asterisk asterisk-modules asterisk-config

Enable and start Asterisk

sudo systemctl enable –now asterisk
sudo systemctl status asterisk

and verify Asterisk CLI is running: sudo asterisk -rvvvvv

Connected to Asterisk 22.5.2~dfsg+~cs6.15.60671435-1 currently running on asterisk-time (pid = 3022)

Connect to your PBX extension

sudo nano /etc/asterisk/pjsip.conf 

RELOAD ASTERISK

sudo asterisk -rx “pjsip reload”
sudo asterisk -rx “pjsip send register yeastar-reg”
sudo asterisk -rx “pjsip show registrations”

The registration should look like:

<Registration/ServerURI…………………………> <Auth………………..> <Status…….>
==========================================================================================

yeastar-reg/sip:PBXIP:5060 yeastar-auth Registered (exp. 558s)

Objects found: 1

 

EDIT THE EXTENSIONS (basically the “person” who will speak the time”)

sudo nano /etc/asterisk/extensions.conf

 

[from-yeastar]
exten => 958,1,Answer()
same => n,Wait(1)
same => n(loop),Playback(at-tone-time-exactly)
same => n,Wait(1)
same => n,PlayTones(1000/250)
same => n,Wait(1)
same => n,StopPlayTones()
same => n,SayUnixTime(,Europe/Bucharest,H)
same => n,Wait(0.3)
same => n,SayUnixTime(,Europe/Bucharest,M)
same => n,Playback(minutes)
same => n,SayUnixTime(,Europe/Bucharest,S)
same => n,Playback(seconds)
same => n,Wait(3)
same => n,Goto(loop)

exten => s,1,Goto(958,1)

 

then reload the dialplan:

sudo asterisk -rx “dialplan reload”

 

There you go! Now just dial 958 from any phone on the PBX and enjoy the old times 🙂