Jump to content

[C#] 3CX Windows Plugin to Open Ticket in PSA


Recommended Posts

Not sure how many people use 3CX for their phone systems, but our company utilizes the system and have recently adopted Pulseway as well. As a result, I have developed a plugin for 3CX Windows Client that opens a ticket as you pick up the phone from an incoming call. I have included the source code for reference if anyone else has a need for it.

Instructions:

  1. Create a new project. Select C# Language and create a new “Windows Class Library” project.
  2. Ensure that the project targets .NET Framework 4.5.1
  3. Add a reference to the library “MyPhoneCRMIntegration.dll” installed with 3CXPhone for Windows (usually C:\ProgramData\3CXPhone for Windows\PhoneApp).
  4. Rename Class1.cs to PulsewayTicketPlugin.cs and replace the code with the following:
using System;
using System.IO;

namespace _PulsewayTicketPlugin
{
    [MyPhonePlugins.CRMPluginLoader]
    public class PulsewayTicketPlugin
    {
        // Initialization of Variables
        private static PulsewayTicketPlugin instance = null;                                        // Holds the instance
        private MyPhonePlugins.IMyPhoneCallHandler callHandler = null;                              // Holds the handler
        private static MyPhonePlugins.CallState lastStatus = MyPhonePlugins.CallState.Undefined;    // Holds the last relevant phone status

        // Called upon loading 3CX Client
        [MyPhonePlugins.CRMPluginInitializer]
        public static void Loader(MyPhonePlugins.IMyPhoneCallHandler callHandler)
        {
            // Create a new instance of the plugin
            instance = new PulsewayTicketPlugin(callHandler);
        }

        // Constructor for plugin, to add event handler
        private PulsewayTicketPlugin(MyPhonePlugins.IMyPhoneCallHandler callHandler) {
            this.callHandler = callHandler;

            // As the status of the call changes, process the changes
            callHandler.OnCallStatusChanged += new MyPhonePlugins.CallInfoHandler(callHandler_OnCallStatusChanged);
        }

        // Processes the status of the call
        private void callHandler_OnCallStatusChanged(object sender, MyPhonePlugins.CallStatus callInfo)
        {
            // Process the current state
            //   - If it is ringing, a call is incoming, so we want to monitor it
            //   - If it has ended, no longer need to monitor it (happens when we end it or someone else picks it up)
            //   - Don't process other cases, not necessary
            switch (callInfo.State)
            {
                case MyPhonePlugins.CallState.Ended: { lastStatus = MyPhonePlugins.CallState.Undefined; break; };
                case MyPhonePlugins.CallState.Ringing: { lastStatus = MyPhonePlugins.CallState.Ringing; break; };
                default: { break; };
            }

            // If the phone was ringing and we picked it up, open a new ticket
            if (lastStatus == MyPhonePlugins.CallState.Ringing && callInfo.State == MyPhonePlugins.CallState.Connected)
            {
                // Windows will automatically use the default application used to open URL's
                System.Diagnostics.Process.Start("https://psa.pulseway.com/MSP/TicketEdit.aspx");
            }
        }
    }
}
  1. Build the DLL and place it into the 3CX Phone Directory (C:\ProgramData\3CXPhone for Windows\PhoneApp).
  2. Edit the 3CX Phone Configuration file (C:\ProgramData\3CXPhone for Windows\PhoneApp\3CXWin8Phone.user.config) and add the following:
<add key="CRMPlugin" value="CallNotifier,3CXPhoneTapiPlugin,PulsewayTicketPlugin"/>
  1. Reload your 3CX Windows Client and it should work with the next incoming call!
Link to post
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Jamie Taylor
      You can now trigger workflow executions from Performance Counter notifications and evaluate Name, Category and Instance in conditions to build even more customizable workflows for your IT processes.
    • By Jamie Taylor
      You can now create interactive, conditional troubleshooters that can be used to ask questions, provide answers, and run self remediation scripts and tasks based on user input. Pulseway's Client Portal can be used to standardize IT processes, empower end-users and reduce the workload on your support team.

       

       
    • By crakpot
      I would really like to see an outlook add-in that can be pushed through office 365 to all users that would allow them to submit tickets with drop down menus for ticket type, sub-type, priority and description. 
       
    • By Carl T
      A number of folks have requested the ability to manage bitlocker with Pulseway, so I thought I would share how I am doing this with Powershell scripts and Pulseway's custom fields feature. 
      First, you will need to create a custom fields in Pulseway (Automation Tab --> Custom Fields). This fields should be a text variable that has the system context. I personally have 3, BitlockerKey, Protection Status (On/Off), and BitLockerVolumeStatus. BitlockerKey is probably the one most people will care about. . 

      After Configuring the Custom fields, you will then need to create your PowerShell script. Notice you have inputs and outputs. You will want to click New for output. Name it what you wish, ensure it is a text variable type, and then turn on "set Custom Field Value"

      Now we toggle the flag for it being a windows powershell script. You should see in the top that it has created a comment #outputs with your defined output variable assigned the default value you gave it. 
      Now we have our script: Update as of 4/18/2021, script now tracks 3 custom fields and will account for if a drive is encrypted but protection is off and no protectors have been added yet.
      # Outputs $ProtectionStatus = "na" $recoveryKey = "na" $VolumeStatus = "na" #region functions function Start-BitlockerEnable { Enable-BitLocker -MountPoint c: -EncryptionMethod XtsAes128 -UsedSpaceOnly -TpmProtector $today = Get-Date $scheduledtime = $today.Date.AddHours(23) [int]$SecondsToMidnight = ($scheduledtime - $today).TotalSeconds shutdown /r /t $SecondsToMidnight msg.exe * "Bitlocker Encryption has been enabled. A reboot is needed before the encryption will apply and has been scheduled for $scheduledtime local time. You can reboot before this if you prefer." #start-sleep 90 #msg.exe * "This Computer will reboot in 30 seconds to bitlocker Encryption" #start-sleep 30 #Restart-computer -force } #endregion functions #region execution $BitLockerStatus = Get-BitLockerVolume -MountPoint c: if ((Get-Tpm).tpmpresent -eq $true) { #If Volume is in the process of encrypting or decrypting the Volume status will not say fully. Don't make changes when it changes if (($BitLockerStatus.ProtectionStatus -match 'off') -and ($bitlockerstatus.VolumeStatus -notmatch 'progress')) { #NoBitlocker is enabled so run it. if ($BitLockerStatus.VolumeStatus -eq 'FullyDecrypted') { $recoverykey = $BitLockerStatus.KeyProtector | Select-Object -ExpandProperty recoverypassword if(!($recoveryKey)){ Add-BitLockerKeyProtector -MountPoint c: -RecoveryPasswordProtector } $newStatus = Get-BitLockerVolume -MountPoint c: $recoverykey = $newStatus.KeyProtector | Select-Object -ExpandProperty recoverypassword Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable recoverykey ""$recoverykey""") -Wait if ($newStatus.KeyProtector -match 'Recovery') { Start-BitlockerEnable } } #Bitlocker must be Partially enabled where drive is fully encrypted, but protection is off and no protectors exist. #Typically this is using xtsAES128 so you may wish to disable-bitlocker, then re-enable it with your protectors and prefered encryption level. else{ Disable-BitLocker -MountPoint 'c:' $decryptInProgress = $true While($decryptInProgress -eq $true){ $decryptstatus = Get-BitLockerVolume -MountPoint 'c:' if($decryptstatus.VolumeStatus -match 'progress'){ Start-Sleep 2 } else{ $decryptInProgress = $false } } Add-BitLockerKeyProtector -MountPoint c: -RecoveryPasswordProtector $newStatus = Get-BitLockerVolume -MountPoint c: $recoverykey = $newStatus.KeyProtector | Select-Object -ExpandProperty recoverypassword Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable recoverykey ""$recoverykey""") -Wait if ($newStatus.KeyProtector -match 'Recovery') { Start-BitlockerEnable } } } #BitLocker should already be enabled so log keys, volume status etc. else { $recoverykey = $BitLockerStatus.KeyProtector | Select-Object -ExpandProperty recoverypassword $ProtectionStatus = $BitLockerStatus.ProtectionStatus $VolumeStatus = $BitLockerStatus.VolumeStatus Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable recoverykey ""$recoverykey""") -Wait Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable ProtectionStatus ""$ProtectionStatus""") -Wait Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable VolumeStatus ""$VolumeStatus""") -Wait } } else { $recoverykey = 'NoTpm' Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable recoveryKey ""$recoveryKey""") -Wait } #endregion execution You can modify the above script as you wish. I personally have gone with a bit of a cautious approach where it will not skip the hardware check which will reboot the pc, but for me I prefer this approach to having it encrypt the drive without checking tpm is all good which could then result in the drive being encrypted and locking out the end user. 
       
      At the end of all this, you now should be able to Both Enable bitlocker encryption as well as pull your recovery keys from pulseway like so :

       
    • By OnsiteITservices
      Using USB external hard drive as backup devices and each drive can be recognized if manually added to the notifications/storage screen but I need to know if there is a way to set this to be automatic when the drive is replaced either daily or weekly.  Also, where would this be set globally for are servers being monitored. Currently have 8.6.8.
       
      Thank you,
      Todd Kollars
      Onsite IT Services
×
×
  • Create New...