YourFirstSaflet

last edited byusericonthelimit on 13-Nov-2009

Creating Your First Saflet

After you have SafiWorkshop installed and configured for your Asterisk server(s); you're ready to make a Saflet.

A Saflet is program used by the SafiServer to control an Asterisk system. In this example we're going to create a Saflet that answers, plays an audio file, then hangs up the call.



1: Open SafiWorkshop and click on the New Project button
(or File/New/New Safi Project)

2: Fill in the Name and Path to your project:


3: You should see the your newly created project in the SafiWorkshop Navigator panel:


4: Click the "New Saflet" button
(or File/New/New Saflet)
New Saflet Dialog

Select the Project you want to create your Saflet in (in this case "First Project"). Then click Finish (you can change the name of the Saflet if you want, but in this example we'll use the default callflow1.saflet).

5: You should see your newly created Saflet (in this example: callfow1.saflet) in the workspace with the "Incoming Call" initiator in the upper left corner:


6: First we need to answer the call. Click on the "Palette" tab (to the left of the workspace).
Click Call Management and then click the Answer icon:


Then click on the workspace (the Saflet) were you want to place it:


Now we need to connect the two ActionSteps. Hover over the Incoming Call ActionStep's start exit path and you should see a handle:


Click and drag the connection handle to the "Answer" ActionStep and drop. The two ActionSteps should now be connected:


7: Next we need to add audio playback
Click on the Palette and click the StreamAudio ActionStep (under the Audio: Playback section)


Then click on the work-area (the area containing the callflow) and connect the "Answer" default exit path to the "StreamAudio" ActionStep


Now click on the StreamAudio ActionStep and look at the Properties panel (in the lower left-hand corner of the application. Under Filename enter the name of the recording you want to play (with out the file extension). In this example we're using the tt-monkeys; a prompt file include in the default Asterisk distribution:


8: Hanging up the call
Go back to the Call Management group in the palette and click the Hangup ActionStep. Click where you want to place it in the workarea and connect the default path from StreamAudio to the Hangup ActionStep. You should have now have something like this:


9: Save this Saflet by clicking on the Save button (or File/Save)

10: Start the SafiServer by pressing "Start SafiServer" button

11: The Saflet is now ready to start handling calls all we need to do now is configure extensions.conf to make the connection. For this example we're going to use the extension 1111.

For a quick setup, add the following to the [default] context:
NOTE: You may need to make corrections based on your Project/Saflet names and your IP address

exten = 1111,1,Agi(agi://192.168.0.10/safletEngine.agi?saflet=project/saflet)



extensions.conf syntax:
exten = [extension],1,Agi(agi://[IP or FQDN of SafiServer]/safletEngine.agi?saflet=[Project]/[Saflet])



Thats it! You should be able to dial up the extension you entered into extensions.conf and hear a bunch of screaming monkeys (assuming you used the tt-monkeys file).

 
Download in other Formats:
markup Markup | pdf PDF | swf SWF | html HTML | word Word