-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caller id match #156
Merged
+158
−19
Merged
Caller id match #156
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
87cf72d
Add events for caller id matching
esme 9194701
Remove console logs
esme 3ee317f
Add caller id match payload
esme bfd0568
Drop callId from the payload
esme 6bb43d2
Add debugMessageType argument to logging
esme c58fe05
Add incomingCall event handler to README
esme b328699
Log last sync event
esme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,12 @@ import { errorType, callEndStatus } from "../../src/Constants"; | |
// import CallingExtensions, { Constants } from "@hubspot/calling-extensions-sdk"; | ||
// const { errorType, callEndStatus } = Constants; | ||
|
||
const state = { | ||
export const state = { | ||
engagementId: 0, | ||
phoneNumber: "+1234", | ||
toNumber: "+1234", | ||
fromNumber: "+123456", | ||
userAvailable: false, | ||
incomingContactName: "", | ||
}; | ||
|
||
const sizeInfo = { | ||
|
@@ -53,7 +55,7 @@ const cti = new CallingExtensions({ | |
}, | ||
onDialNumber: (data, rawEvent) => { | ||
const { phoneNumber } = data; | ||
state.phoneNumber = phoneNumber; | ||
state.toNumber = phoneNumber; | ||
}, | ||
onEngagementCreated: (data, rawEvent) => { | ||
const { engagementId } = data; | ||
|
@@ -75,6 +77,32 @@ const cti = new CallingExtensions({ | |
state.engagementId = engagementId; | ||
}, | ||
onUpdateEngagementFailed: (data, rawEvent) => {}, | ||
onCallerIdMatchSucceeded: (data, rawEvent) => { | ||
const { callerIdMatches } = data; | ||
if (callerIdMatches.length) { | ||
const firstCallerIdMatch = callerIdMatches[0]; | ||
if (firstCallerIdMatch.callerIdType === "CONTACT") { | ||
state.incomingContactName = `${firstCallerIdMatch.firstName} ${firstCallerIdMatch.lastName}`; | ||
} else if (firstCallerIdMatch.callerIdType === "COMPANY") { | ||
state.incomingContactName = firstCallerIdMatch.name; | ||
} | ||
cti.logDebugMessage({ | ||
message: `Incoming call from ${state.incomingContactName} ${state.fromNumber}`, | ||
type: `${callerIdMatches.length} Caller ID Matches`, | ||
}); | ||
return; | ||
} | ||
cti.logDebugMessage({ | ||
message: `Incoming call from ${state.fromNumber}`, | ||
type: "No Caller ID Matches", | ||
}); | ||
}, | ||
onCallerIdMatchFailed: (data, rawEvent) => { | ||
cti.logDebugMessage({ | ||
message: `Incoming call from ${state.fromNumber}`, | ||
type: "Caller ID Match Failed", | ||
}); | ||
Comment on lines
+89
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hemang-thakkar Added an argument to log messages with a custom |
||
}, | ||
}, | ||
}); | ||
|
||
|
@@ -131,9 +159,9 @@ export function userUnavailable() { | |
export function incomingCall() { | ||
window.setTimeout(() => { | ||
cti.incomingCall({ | ||
createEngagement: "true", | ||
fromNumber: "+123", | ||
toNumber: state.phoneNumber, | ||
createEngagement: true, | ||
fromNumber: state.fromNumber, | ||
toNumber: state.toNumber, | ||
}); | ||
}, 500); | ||
disableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]); | ||
|
@@ -143,8 +171,8 @@ export function incomingCall() { | |
export function outgoingCall() { | ||
window.setTimeout(() => { | ||
cti.outgoingCall({ | ||
createEngagement: "true", | ||
phoneNumber: state.phoneNumber, | ||
createEngagement: true, | ||
phoneNumber: state.toNumber, | ||
}); | ||
}, 500); | ||
disableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose state to the window object so that we can change any of the properties such as
fromNumber
before sending an event in the Demo Widget. For our acceptance tests, we should create an engagement state and call state to display in the UI like how we are doing so in the Mock UI.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would export it with a more definitive name. state is too generic. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, do you have any suggestions for the name - maybe engagementState? This is only exported in the
demo-minimal-js
iframe so we won't be seeing a conflict with any variables in the parent windowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also implement getters and setters here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the scope is minimal, i am fine. But, are we making updates to state properties? If yes, then it would be better if we have function to return initial state. So, we dont have accidental leaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's a minimal scope right now. Since we're not persisting the state across mounts, any changes to state properties would only affect the demo minimal js widget until we unmount the component.