Open vieridipaola opened 4 years ago
You may have missed an update about that, check the index.html file - the CRM hooks are all there, so you can build anything around that.
<script type="text/javascript">
var web_hook_on_register = function(ua){
console.warn("web_hook_on_register", ua);
}
var web_hook_on_registrationFailed = function(e){
console.warn("web_hook_on_registrationFailed", e);
}
var web_hook_on_unregistered = function(){
console.warn("web_hook_on_unregistered");
}
var web_hook_on_invite = function(session){
console.warn("web_hook_on_invite", session);
}
var web_hook_on_message = function(message){
console.warn("web_hook_on_message", message);
}
var web_hook_on_modify = function(action, session){
console.warn("web_hook_on_modify", action, session);
}
var web_hook_on_dtmf = function(item, session){
console.warn("web_hook_on_dtmf", item, session);
}
var web_hook_on_terminate = function(session){
console.warn("web_hook_on_terminate", session);
}
</script>
you would use the "web_hook_on_invite", and then look in the session object for all the things you need.
session.data
is quite simple and easy to use.
OK, I looked into the web hook stuff again, and now I can get the caller's number with this code example:
var web_hook_on_invite = function(session) {
console.warn("DID ", session.remoteIdentity.uri.user);
}
session.data doesn't show me the caller's number, but there's the buddy ID that I can use too.
Anyway, what would be the best approach to actually do what I suggested in the first post? I guess I can try to change the incoming call window with innerHTML or the likes from the web_hook_on_invite function.
I think I can do it with something like this:
var web_hook_on_invite = function(session) {
var buddyObj = FindBuddyByDid(session.remoteIdentity.uri.user);
$("#contact-" + buddyObj.identity + "-msg").append(" <a href='https://mycrm/?num=" + session.remoteIdentity.uri.user + "'>CRM</a>");
}
Any better ideas?
I'm thinking that it would be nice to have the link to the CRM from several places even when there's no active call. For instance, if I click on the "buddy" after the call is over, I can click on the name to get a popup window showing the caller ID name and number. It would be nice to have the CRM link here also in order to link to another web page by passing the DID.
Actually, in my case, it's not really a CRM but a HIS (hospital patient database). The reason I'm asking all this is that often users receive calls from one landline number or cell phone, but the HIS db yields more than one patient. That's because there can be several family members associated with that same number.
Having a "permanent" link to the HIS as a button within every "buddy contact sheet" would be useful as users could quickly check back on their earlier calls at their earliest convenience in order to add/edit the right phone numbers to each patient found in the HIS. It might not be as straightforward as that because instead of a simple GET, the HIS might require a POST, but that's another story...
Anyway, it seems to be more complex because a button with the HIS link would have to be built from the buddy data, not from the web hook.
Well, let's see... Firstly you need to decide if you want to fire CRM calls "automatically", and then would it be "behind the scenes" (like with AJAX) or as a new tab (window.open).
All this you would construct your self in the pre script or something.
var web_hook_on_invite = function(session) {
var buddyObj = FindBuddyByIdentity(session.data.buddyId);
var callDirection = session.data.calldirection;
if(callDirection == "outbound"){
// Doctor is making a call to a patient
}
else {
// Patient is calling the Doctor
// You need to keep a database for mapping buddy ID to patient ID (or, populate you buddy list from known patient id's... not sure if this is wise)
// automatically fire CRM events
window.open("https://mycrm/?buddy-to-patient-id="+ session.data.buddyId);
or
$.ajax({
type: "POST",
url: "https://mycrm/?log-hit=1&buddy-to-patient-id="+ session.data.buddyId,
success: function(){
console.log("Hit logged")
}
});
// Prompt Doctor to take action.
// This option could look nice:
var html = "Would you like to open the patient file?";
OpenWindow(html, "Open patient File?", 150, 360, false, false, "Yes", function(){
// Take Yes action
window.open("https://mycrm/?buddy-to-patient-id="+ session.data.buddyId);
}, "No", function(){
// Cancel
CloseWindow();
}, function(){
// Do OnLoad...
// Here you could even load patient data from your own CRM database
$.ajax({
type: "POST",
url: "https://mycrm/?action=get-patient-data&buddy-to-patient-id="+ session.data.buddyId,
success: function(){
// Display patient Data
}
});
}, null);
}
}
(pseudo code)
Play around with that.
If you want to access after the call, like from the message stream, then the CRM options would need to be added to the CDR item dropdown... Ill see if I can get a web hook into that, so it populates the menu dropdown
If you want to access after the call, like from the message stream, then the CRM options would need to be added to the CDR item dropdown... Ill see if I can get a web hook into that, so it populates the menu dropdown
That would be great! BTW, I'd like to ask a generic javascript/HTML question. If I want to open the HIS page in another tab or browser window (and a new one for each incoming call)then I can use target=_blank. However, if I wanted to open the HIS page in another tab/window but always the same one and for every incoming call (eg. if "call waiting" is disabled so the user avoids losing information due to overlapping calls), how could I do that (if possible)? I'm not using frames so I can't use target=framename. I can't use an overlay window either to display the HIS page as it would be awkward for the user (not enough screen space).
Anyway, big thanks for the pseudo code above.
OK, never mind my last comment. I guess my test wasn't working because I didn't refresh/reload my web page, but target=windowname works fine now.
Now I just need to find out if the user has Call Waiting on or off from within web_hook_on_invite.
Got it: if(CallWaitingEnabled == false || CallWaitingEnabled == "disabled")
Sorry for the noise.
If I remember correctly it should always be a Boolean, so true or false should be fine.
Hi,
I don't know if what I'm saying could be useful to others, or if there's a better approach to this.
When there's an incoming call and the calling number is non-empty, could there be a button which points to a custom URL with the caller's number as a parameter?
Example:
The idea is that the user can then decide to lookup the caller in a custom database or not. It is usually done before answering the call, but it would be nice to have the same button/link within the ongoing call window, maybe as one of the first icons before the "keypad".
Just a thought.