I'm working on a CRON or some other external event triggered action which is supposed to make a call and play a sound file using FreeSwitch. I suppose I have to use Inbound event socket mode for that.
When using Outbound mode (triggerd by incoming calls), I can play a file since all DialPlanTools are available. For Inbound mode, only a limited number of commands called, mod_socket is available, and playback
is not one of them . I also intend to use say
, record
, read
and maybe others.
I use Outbound socket mode in a separate server to handle the incoming calls, and it doesn't seem to be an easy task to pass the context over. I cannot use Outbound socket, as it is not persistent and FreeSwitch immediately drops connection once the call is over.
Freeswitch is tricky. Stanislav Sinyagin has advised uuid_broadcast
, but it didn't work alone. You need to add another command (uuid_phone_event
) immediately for it to work. The overall code is as follows:
originate sofia/external/sip:+<phone_number_here>@<freeswitch_ip_here> &park
# wait for remote side to pick up the call
uuid_broadcast <uuid_from_originate> speak::cepstral|david|'Some text in single quotes here' aleg
uuid_phone_event <uuid_from_originate>
uuid_broadcast <uuid_from_originate> playback::'<absolute_path_to_mp3_or_wav>' aleg
uuid_phone_event <uuid_from_originate>
sched_hangup +1 <uuid_from_originate>
There a bit less than none documentation on the uuid_phone_event
command in FS wiki, and I have accidently spotted it in fs_cli
.
And yes, you need another Inbound socket connection to monitor the events (at least no Ruby library supports for listening for server-generated events and issuing commands on the same socket connection).