You can get the results with AGI.
You need to setup FastAGI with Asternet and then you can get the results to save to you DB.
To setup FastAGI you need to set the script to the specific class where you will handle the call and start the FastAGI service from you programs Main method in program.cs
static void Main(string[] args)
{
AsteriskFastAGI agi = new AsteriskFastAGI();
agi.MappingStrategy = new GeneralMappingStrategy(new List<ScriptMapping>()
{
new ScriptMapping() {
ScriptClass = "MyNamespace.GetResult",
ScriptName = "getresult"
}
});
agi.Start();
}
and create a class GetResult which inherits AGIScript where you will handle the call inside the Service method and use the GetVariable function to get the variable content
namespace MyNamespace
{
class GetResult : AGIScript
{
public override void Service(AGIRequest request, AGIChannel channel)
{
try
{
string result = GetVariable("result")
//save to DB
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
and you need to enter the agi from your dialplan. If the c# program is running on the same server as asterisk you can do localhost same => n,agi(agi://localhost/getresult) or put your server's local ip address same => n,agi(agi://xxx.xxx.x.x/getresult) and if the c# program is running on a remote server put the remote server ip address same => n,agi(agi://xxx.xxx.xx.xxx/getresult) and make sure that your asterisk server public ip is open in the remote server's firewall.
exten => test,1, NoOp(************ test ****************);
same => n,Answer();
same => n,Playback(hellow-world);
same => n,set(result=123456);
same => n,agi(agi://yourserverip/getresult)
same => n,Hangup();