developerforce / open-cti-demo-adapter

Other
91 stars 95 forks source link

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

Open araveticharan opened 4 years ago

araveticharan commented 4 years ago

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 commented 4 years ago

You may use lightning message service, which will GA soon (currently it's a developer preview).

With it, you can publish a message from the softphone and handle it in lightning, and vice versa.

https://developer.salesforce.com/blogs/2019/10/lightning-message-service-developer-preview.html

On Mon, Feb 17, 2020, 6:16 AM araveticharan notifications@github.com wrote:

Hi @dlouvton https://github.com/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 configuration in 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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/developerforce/open-cti-demo-adapter/issues/37?email_source=notifications&email_token=ABSWICQY2DLR4OGBNGLJAEDRDKL3FA5CNFSM4KWSRA3KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IOBPJFA, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSWICVMZHNMWWN7352YJT3RDKL3FANCNFSM4KWSRA3A .

araveticharan commented 4 years ago

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 commented 4 years ago

Why don't you use clickToDial() and onClickToDial()? With clickToDial() you can send a payload and with onClickToDial() process the payload.

On Tue, Feb 18, 2020, 8:19 AM araveticharan notifications@github.com wrote:

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.

[image: Capture] I truly appreciate your your time regarding this matter. Thank you! Charan — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or unsubscribe .
araveticharan commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Hey Charan any Luck ? can you please share solution

araveticharan commented 4 years ago

Hey,

Actually, I found 2 solutions:

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.

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 commented 4 years ago

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 commented 4 years ago

Hey @warnakuw , So what is your question?

warnakuw commented 4 years ago

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 commented 4 years ago

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 commented 9 months ago

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