function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Megha SachaniaMegha Sachania 

Do any one have idea regarding Open CTI?

SwethaSwetha (Salesforce Developers) 
HI Megha,
CTI, or computer telephony integration, is a fancy term to describe connecting your telephone systems and computers. It describes two types of function:

Desktop-based interactions which are designed to help users be more efficient
Server-based functionality such as automatic call routing
Computer telephony integration is particularly beneficial in the world of inside sales and the customer service call center.

You can begin with
https://developer.salesforce.com/docs/atlas.en-us.api_cti.meta/api_cti/sforce_api_cti_intro.htm

Trailhead module to understand the call center terminology
ttps://trailhead.salesforce.com/content/learn/modules/service_call/service_call_intro

Let me know if you are looking for anything specific about Open CTI. I am happy to answer.

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Megha SachaniaMegha Sachania

Thanks.. I am facing issue while using runApex Open CTI Method.. Below Is the code : 

OpenCTIComp.cmp :- 

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <ltng:require scripts="https://elision-dev-ed.lightning.force.com/support/api/50.0/lightning/opencti_min.js"/>
    <ltng:require scripts="https://elision-dev-ed.lightning.force.com/support/api/49.0/interaction.js"/>
    
    <lightning:button variant="brand" class="slds-col slds-size_3-of-12 button-color"
                    label="Call RunApex" onclick="{!c.callingApex}"/>
    
    <lightning:button variant="brand" class="slds-col slds-size_3-of-12 button-color"
                    label="Soft Phone Panel" onclick="{!c.callingSoftPanel}"/>
     
    <lightning:button variant="brand" class="slds-col slds-size_3-of-12 button-color"
                    label="Open Call Centre Setting" onclick="{!c.openCallSetting}"/>
    
</aura:component>

OpenCTIComp.controller :- 

 callingApex : function(component, event, helper) {
        debugger;
        console.log('in onInit');
        
        var callback = function(response) {
            debugger;
            if (response.success) {
                console.log('API method call executed successfully! returnValue:', response.returnValue);
            } else {
                console.error('Something went wrong! Errors:', response.errors);
            }
        };
        
        var param = {apexClass: 'DialShreeApi', methodName: 'fetchLead', methodParams: 'phoneNumber=+919428808249'};
        param.callback = callback;
        //Invokes API method
        sforce.opencti.runApex(param);
        
        sforce.opencti.runApex({
            apexClass : 'DialShreeApi',
            methodName : 'fetchLead',
            methodParams : 'phoneNumber=+919428808249',
            callback : function(result) {
                debugger
                if (result.success) {
                    alert('setSoftphonePanelHeight is successfully executed.');
                    var retVal = result.returnValue;
                    
                    var returnJSON = JSON.parse(retVal); // parse the string into an object
                    console.log(returnJSON);
                    
                    if ( returnJSON.status == "ringing")
                    {
                        console.log('This is taking the retun value as ringing');
                        //set the label to Dialing and dont start the time!
                    }
                    
                } else {
                    alert('setSoftphonePanelHeight is successfully executed.');
                    throw new Error('Unable to make a call. Contact your admin.');
                }
            }
        });
    }

Apex Class :- 
    @AuraEnabled
    public static String fetchLead(String phoneNumber) {         
        
        List<contact> conList = New List<contact>();
        List<Lead> leadList = New List<Lead>();
        Set<Id> leadConIdSet = new Set<ID>();
        System.debug('**phoneNumber***'+phoneNumber);
        if(phoneNumber.length() > 2){
            String status = 'Closed - Converted';
            String searchQuery = 'FIND \'' + phoneNumber + '\' IN ALL FIELDS RETURNING  Lead(Id,Phone where status != \'' +status+ '\'), Contact(Id,Phone)';
            system.debug(searchQuery);
            List<List <sObject>> searchList = search.query(searchQuery);
            System.debug('@@searchList=='+ searchList);
            leadList = ((List<Lead>)searchList[0]);
            conList  = ((List<contact>)searchList[1]);
            System.debug('***searchList***'+searchList.size());
            System.debug('***leadList***'+leadList);
            System.debug('***conList***'+conList);
            
            if(conList.size() != 0) {
                for(Contact con : conList) {
                    leadConIdSet.add(con.Id);
                }
            }else if(leadList.size() !=0){
                for(Lead ld : leadList) {
                    leadConIdSet.add(ld.Id);
                }
            }
            else {
                leadConIdSet = new Set<ID>();
            }
        }
        System.debug('JSON:--'+leadConIdSet);  
        return JSON.serialize(leadConIdSet);
    }

I am facing issue that i am not able to get response in callback function used for runApex method. And even after apex method runs successfully i am not able to get console in front end.

SwethaSwetha (Salesforce Developers) 
I have tried the simplified version of your above code from https://developer.salesforce.com/docs/atlas.en-us.api_cti.meta/api_cti/sforce_api_cti_runapex.htm and see the same issue.
It looks like the apex class is not able to give response to be passed to the OpenCTIComp.controller . I will update this thread as I have more information. Thanks
Megha SachaniaMegha Sachania
Yes It will be helpful if you could provide the solution
SwethaSwetha (Salesforce Developers) 
HI Megha,
The runapex() would only function in the softphone and not when opened in a VF page. Can you confirm you have added your code to the softphone(After you create the HTML page, have you added the URL to the call center definition file)?

See https://developer.salesforce.com/docs/atlas.en-us.api_cti.meta/api_cti/sforce_api_cti_sample_js.htm for more information on how HTML Page in a Lightning Experience App would look like when added to call center definition file (https://developer.salesforce.com/docs/atlas.en-us.api_cti.meta/api_cti/sforce_api_cti_call_def_file.htm).

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Megha SachaniaMegha Sachania
Thanks, for your help
 
Megha SachaniaMegha Sachania

Hi swetha,

Also could you help me out how can i make live call from this open cti softphone?Do we require any third party library such as twilio or we can do it with any other third party apis
 

Megha SachaniaMegha Sachania
Hi sweta, Also could you help me out how can i make live call from this open cti softphone?Do we require any third party library such as twilio or we can do it with any other third party apis ? I have posted same to community also. I will wait for your reply. Thank you
SwethaSwetha (Salesforce Developers) 
HI Megha, Can you share the new question link so I can share elaborate details?

Open CTI Demo adapter that salesforce provides is only a softphone panel.It acts as a mediator between salesforce and any 3rd part service which provides all call center functionality like call, message, chat etc. With the help of open CTI, you can only make changes in your softphone panel

To make live phone calls you have to integrate your org with service providers like twilio (https://www.twilio.com/docs/salesforce), InGenius etc

Check the appexchange for more phone integration apps https://appexchange.salesforce.com/results?keywords=cti

Thank you
Megha SachaniaMegha Sachania
Ok Thanks Swetha
 
 
Megha SachaniaMegha Sachania

Hi Swetha,

I have one question regarding open cti if you could help me out.

We are using 3rd party tool (Dialshree) and they have auto dialing feature which continuously dialing the phone numbers which is in their campaign. So they want to check status of an agent due to this reason using an API at every 2-3 sec. Since we have limitation of API call outs , is it feasible in openCTI ? Below is the Dialshree view which we have implemented in our org.

 

Megha SachaniaMegha Sachania
User-added image
Megha SachaniaMegha Sachania
API Which we are using : https://sfdc.elisiontec.com/elision-salesforcedialshree/elision-api/main.php?source=test&action=agent_status&stage=csv&header=YES&agent_user=1020
Megha SachaniaMegha Sachania

Hi swetha,

Do you have idea regarding how to deploy lwc (heroku app) in developer org or our org?