3CX CallTriggerCMDPlugin Customization

Status
Not open for further replies.

bocasa

Joined
Jun 9, 2016
Messages
4
Reaction score
0
Hello,

I am trying to customize 3CX CallTriggerCmdPlugin to register incoming calls and to open myApp.exe with caller information.
I have managed to do this with CallTriggerCMD.exe, but I have to execute a command in order for this to work.

Is there a way to open my application upon incoming call directly from plugin? (from CallTriggerCmdPlugin)

PS: Actually I want to make a listener that registers incoming calls and stores data from caller...
 
HI there,
Yes you can do so in this part of the code:

private void callHandler_OnCallStatusChanged(object sender, MyPhonePlugins.CallStatus callInfo)
{

Then add something like this and do the action of your choice with callInfo.OtherPartyNumber on incoming calls:
if (callInfo.State.ToString() == "Ringing")
{
string number = "";
number = callInfo.OtherPartyNumber;
...
 
I already tried that, but it seems that this method isn't even getting executed. I am trying to write the caller info into the log file but it isn't logging anything.
 
If I am right, I can make a plugin with the piece of code that is described here: http://www.3cx.com/blog/docs/3cxphone-for-windows-api/

And I can edit the OnCallStatusChanged method and that will work?

If that all is correct, then I must be missing something because I cannot get it working. I am not getting inside OnCallStatusChanged method at all... not in my custom plugin and not even in CallTriggerCmdPlugin...

This is my code:

Code:
namespace _3cxCRMPlugin
{
    [MyPhonePlugins.CRMPluginLoader]
    public class MyPhonePlugin
    {
        private static MyPhonePlugin instance = null;
        private IMyPhoneCallHandler callHandler = null;
        IExtensionInfo extensionInfo;
        //ServiceHost _serviceHost;

        [MyPhonePlugins.CRMPluginInitializer]
        public static void Loader(MyPhonePlugins.IMyPhoneCallHandler callHandler)
        {
            instance = new MyPhonePlugin(callHandler);
        }

        private MyPhonePlugin(MyPhonePlugins.IMyPhoneCallHandler callHandler)
        {
            this.callHandler = callHandler;
            callHandler.OnCallStatusChanged += callHandler_OnCallStatusChanged;
            callHandler.OnMyPhoneStatusChanged += callHandler_OnMyPhoneStatusChanged;
            Write (callHandler.Status.ToString()) ;
            Write(callHandler.ActiveCalls.Length.ToString());
        }

        private void callHandler_OnMyPhoneStatusChanged(object sender, MyPhonePlugins.MyPhoneStatus status)
        {
            if (status == MyPhonePlugins.MyPhoneStatus.LoggedIn)
                this.extensionInfo = sender as MyPhonePlugins.IExtensionInfo;
            Write(extensionInfo.Number);
        }

        private void callHandler_OnCallStatusChanged(object sender, MyPhonePlugins.CallStatus callInfo)
        {
            Write(callInfo.CallID);
        }

        public static void Write(String text)
        {
            String _path = @"C:\3cxPlugin" + DateTime.Now.ToString("yyyy.MM.dd") + ".txt";

            if ((_path != null) && (_path != ""))
            {
                StreamWriter writer = null;
                if (File.Exists(_path))
                {
                    writer = File.AppendText(_path);
                }
                else
                {
                    try
                    {
                        writer = File.CreateText(_path);
                    }
                    catch
                    {
                        return;
                    }
                }
                writer.WriteLine(DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss") + " - " + text);
                writer.Flush();
                writer.Close();
            }
        }
    }
}

and the log file looks like this:
Code:
13.06.2016 09:51:23 - LoggedOut
13.06.2016 09:51:23 - 0
 
Hi there,
Are you activated on a Pro license?
And do you see presence informations on your 3CXPhone?
 
Hello,

We are on a Pro Demo licence, but will be having the pro licence soon.
And yes, I see the presence information...

Are you saying that Pro licence is needed in order for this to work?

Thanks for the help!
 
hi,

what is the callback for hold,resume, mute and unmute that is sent from 3CX to sample plugin(CallTriggerCMD).

I got API to hold and resume(i.e. callHandler.Hold(callId, hold On)) which can be used to send event to softphone.
but which event(or callback) will I receive on holding call from 3CX softphone itself.
 
Hi there,

I experience a similar problem with my API. Don't know if it's the same or related. When run in a windows 10 OS, my OnCallStatusChanged event won't fire for incoming calls. Not sure why. Event's fire normally on win 7 machines.

http://www.3cx.com/forums/post183196.html#p183196

Any way I didn't bother further troubleshooting as I'm the only user on Win 10.
 
Status
Not open for further replies.