Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

What is the equivalent Lightning method sendCTIMessage() to make an outbound call? #37

Open
araveticharan opened this issue Feb 17, 2020 · 12 comments

Comments

@araveticharan
Copy link

araveticharan commented Feb 17, 2020

Hi @dlouvton , You may help with this. We are using twilio flex as a vendor for our open CTI. In classic we have a method sendCTIMessage() which talks to call center setup(twilio flex) and making a call to the customer. However, this is not the case with Lightning. Seems like we need special arrangments in the code in order to make a programmatic outbound call.

I have posted this question in multiple places with no luck:

https://salesforce.stackexchange.com/questions/294758/what-is-the-equivalent-lightning-method-sendctimessage-to-make-an-outbound-cal

https://success.salesforce.com/answers?id=9063A000000q1yBQAQ

Any help is greatly appreciated.

Thank you!
Charan

@dlouvton
Copy link
Contributor

dlouvton commented Feb 18, 2020 via email

@araveticharan
Copy link
Author

araveticharan commented Feb 18, 2020

Thanks for the response.

We just using Twilio Flex agent console as softphone in one of our Lightning app that uses Open CTI. So I don't think we will be having any control over the vendor's softphones which are in Salesforce.

There should be something like sendCTIMessage() in Lightning as well to initiate the call and Salesforce will take care the rest.

To test this in classic, I have created a simple VF page(below is the code) with a button which is calling sendCTIMessage(). So when I click that button, my Twilio Flex softphone console popup and will show that I am in call with XXXXXXXX and will show some call controls like hangup, transfer.

<apex:page standardController="Lead">
     <script type="text/javascript">
        function makeACall(){
         console.log('sendCTIMessage: '+sendCTIMessage);
          sendCTIMessage('/CLICK_TO_DIAL?DN=XXXXXXXXXXX&ID=00QXXXXXXXXXX&ENTITY_NAME=Lead&OBJECT_NAME=testing');
        }
     </script>
    <input type="button" name="call" value="call" onClick="makeACall();"/>
</apex:page>

Capture

I truly appreciate your time regarding this matter.

Thank you!
Charan

@dlouvton
Copy link
Contributor

dlouvton commented Feb 18, 2020 via email

@araveticharan
Copy link
Author

araveticharan commented Feb 18, 2020

I never came across clickToDial() method. I know there are aura/LWC tags lightning:clickToDial/lightning-click-to-dial for user to click and give a call to the number.

I am referring https://developer.salesforce.com/docs/atlas.en-us.api_cti.meta/api_cti/sforce_api_cti_intro.htm.

I am pretty sure I am missing something but I understand we don't have sendCTIMessage() equivalent Lightning method.

@araveticharan
Copy link
Author

araveticharan commented Feb 20, 2020

Hey, Is there any way that I can make use of clickToDial()? I see opencti:clickToDial event is been fired when I click a phone number in Lighting in the console.

So is there any way that I can fire this from my aura controller $A.getEvt("markup://opencti:clickToDial").setParams(a).fire()?

image

@VirendraNaruka
Copy link

Hey Charan any Luck ? can you please share solution

@araveticharan
Copy link
Author

araveticharan commented Mar 5, 2020

Hey,

Actually, I found 2 solutions:

  • A hack, to mimic the $A.getEvt("markup://opencti:clickToDial").setParams(a).fire() in my aura component . See below snippet.
var openCtiEvent  = $A.get("e.opencti:clickToDial");
openCtiEvent.setParams({
        "number" 	: 'XXXXXXXXXXXXXX', 
         "recordId"	: 'ZZZZZZZZZZZZZZ'
});
openCtiEvent.fire();

Note: We have to be careful about this, as Salesforce is not documented this event.

  • As dlouvton mentioned another solution is LMS(Lightning Message Service). So in my case, the the Salesforce aura component is going to Publish the message.

Publisher :

Component:
<lightning:messageChannel type="MessageChannelName__c" aura:id="OpenCtiLMC"/>

Controller:
component.find("OpenCtiLMC").publish(payload); //payload is your data of type 'MessageChannelName__c' which can be passed to message channel.

Subscriber:
And my 3rd party vendor(Twilio-flex) softphone is in react.js. Here, I have an option to add a listener(react.js code) so that this code will Subscribe to the message (above payload) we have published in the message channe MessageChannelName__c. Below are the steps at Subscriber side:

Add openCti library to your subscriber component/code
https://.salesforce.com/support/api/48.0/lightning/opencti_min.js

window.sforce.opencti.subscribe({"channelName": "MessageChannelName__c", "listener": <listener methid>, "callback": <call back methid>});

@warnakuw
Copy link

warnakuw commented Jun 4, 2020

Hi @araveticharan,
I'm exploring the possibility to open up Twilio Flex component within lightning experience, when a user clicks on a record detail page button. The intention is to try and pass the context in to the component, and trigger some custom logic at Twilio end.

The difference is, I'm trying this for Twilio Programmable Chat (not Calls). Wondering if you can shed some light here. Thanks in advance 👍

@araveticharan
Copy link
Author

Hey @warnakuw , So what is your question?

@warnakuw
Copy link

Hey @warnakuw , So what is your question?

@araveticharan I was interested to know more about your second option.
I do already have a LMC setup which publishes a message with context information which I would like to pass in to the Twilio Flex component. Since I'm no Twilio expert myself, now I'm stuck at the subscription bit.

It would greatly help if you could share how you modified the OOTB Twilio Flex component. And, if you were referring to a customised component (in your example), how did you customise it ?

@araveticharan
Copy link
Author

Hey,

Apologies for the delayed response. I think I can help you with that.

Ultimately, what you have to do is, you have to modify your salesforce Twilio flex console. Below are sequence of steps that will help you to do so.

Updating Twilio Flex Salesforce Console react component:
As you already have a publisher code which I guess AURA/LWC, your subscriber is going to be Twilio Flex Console which is implemented on React platform. So you have to create a plugin and install it in your Twilio Account. Please watch these short videos. This helps you to make changes with your Twilio Flex console component which executes in Salesforce Lightning Experience.

Subscriber(React) changes you have to make:
As mentioned in salesforce LMS OpenCTI documentation, your subscriber has to make use of Salesforce provided OpenCTI JS library. which looks like

//Load Salesforce OpenCTI JS library in react component 
let oprnCtiUrl = "https://<domain>.my.salesforce.com/support/api/48.0/lightning/opencti_min.js";
await loadScript(oprnCtiUrl);

// Define LMS channel in React component
const OpenCtiLMC = "LightningOpenCtiMessageChannel__c";

//Use OopenCTI function subscribe in React Component
window.sforce.opencti.subscribe({"channelName": OpenCtiLMC, "listener": openCtiFlexListener, "callback": openCtiFlexCallback});

//Take care of your chat stuff with your context data

let openCtiFlexListener = function(message){
    console.log('Flex Payload(Received): '+JSON.stringify(message));
    actionEngine(message);
};

Yes, you heard it correct, you are going to make use of Salesforce provided OpenCTI JS library in REACT plugin and install the same in Flex Console.

Let me know if you need any other help.

@ashishsubedi10
Copy link

@araveticharan could you provide details on how to use opencti library features like clickToDial() features using react js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants