Salesforce: How do I get RingCentral extension number of receiver - salesforce

I've installed RingCentral app and want to create cases based on conditions on extension number of receiver.
A new task automatically gets created once you receive any call, I am going to write trigger to generate cases if receiver's extension matches my criteria.
Please let me know any workaround to get receiver extension number.
Thanks

I am not sure what you meant by saying that you have installed RingCentral app?
But if you somehow have the phone number (from an incoming call, in coming sms, call-log etc.) and you want to detect the extension number of that phone number. Then the first requirement is that, that phone number must belong to the same RingCentral account you are logged in. The second requirement is you must login with the main account number of with an extension that has the Super Admin role. Below is some code in node JS to get extension number.
var incallNumber = "+1234567890"
platform.get('/account/~/phone-number', {
usageType: 'DirectNumber'
})
.then(function(resp){
console.log(resp)
var json = resp.json()
for (var record of json.records){
//if (incallNumber == record.phoneNumber){
console.log('Phone number: ' + record.phoneNumber)
if (record.extension.hasOwnProperty('extensionNumber'))
console.log('Extension number: ' + record.extension.extensionNumber)
else
console.log('No extension number')
console.log('---')
//}
}
})
You can then replace the incallNumber with your number and uncomment the if condition to match them.
Hope this helps.

Related

How to get the user's phone number using react-google-login?

I'm actually using this React library (https://www.npmjs.com/package/react-google-login) to authenticate with Google.
As for the basic profile and email scopes, this works fine. On my client app on Google Cloud Platform, I've correctly enabled the People API (https://developers.google.com/people) and added the correct scope to the scope list, in React (https://www.googleapis.com/auth/user.phonenumbers.read). I've also ensured that my phone number on my Google Profile was made public even if I don't know if that could matter. After doing all this, the consent screen is working fine asking me to allow the app to access my phone number.
However after login, I can only see the data linked to profile and email scopes. In the library I can see that they made some object properties as shown in the code below inside the library itself :
function handleSigninSuccess(res) {
/*
offer renamed response keys to names that match use
*/
const basicProfile = res.getBasicProfile()
const authResponse = res.getAuthResponse(true)
res.googleId = basicProfile.getId()
res.tokenObj = authResponse
res.tokenId = authResponse.id_token
res.accessToken = authResponse.access_token
res.profileObj = {
googleId: basicProfile.getId(),
imageUrl: basicProfile.getImageUrl(),
email: basicProfile.getEmail(),
name: basicProfile.getName(),
givenName: basicProfile.getGivenName(),
familyName: basicProfile.getFamilyName()
}
onSuccess(res)
}
\
So the problem is that I don't know if I even receive the phone data or if I just can't read it because I don't know how to call the phone data inside the response, in terms of variables name in React. Anyone has an idea ?
The library you're using seems to be using Google Identity which does not include a method to obtain the user's phone number, just their basic profile.
You can get the user's phone number with the people api but this is not in the scope of this library. You'd have to make your own method to get the the authenticated user profile with the phoneNumbers field. Enabling the people api and requesting authorization are just the first steps.
https://developers.google.com/people/api/rest/v1/people/get

Avoid rate limit for changing voice channel name discord js 13

I'm trying to create a slash command using discord.js v13 to change the names of voice channels. I am using this code to do this :
module.exports = {
data: new SlashCommandBuilder()
.setName('name')
.setDescription('Set name for your voice channel')
.addStringOption(option => option.setName('name').setDescription('Enter your name').setRequired(true)),
async execute(interaction) {
const name = interaction.options.getString('name');
if (!interaction.member.voice.channel) await interaction.reply('Error not in a voice channel!');
else {
await interaction.member.voice.channel.setName(name);
await interaction.reply('Done!');
}
},
};
This code is fine and makes the job done. But as you know I can change the voice channel's name only 2 times per 10 minutes because of the limit rate. So if a user tries to change the voice channel's name for the third time, I won't get any error on the console, and discord js will queue this request for later and will do it after 10 minutes. But the user gets this error on discord: This interaction failed.
I want to check if there was a rate limit for my request, and if is, don't send the request and just reply to the user. Is this possible?
There is no inherent functionality that is able to handle the situation in the way you want it to, but the problem is soluble using regular old JavaScript. For example, you could use an integer to indicate how many times the command has been used and use setTimeout() to decrement it 10 minutes after the command was called. That way you can check if the int is equal to 2 in which case you skip the .setName().
There are undoubtedly other ways to implement the same or similar behavior, but, to answer your question, unfortunately the discordjs/voice library does not provide any simple way to do it.

Securing system-generated nodes in firebase

I've been going through the rules guide but haven't found an answer to this.
App users are able to submit "scores" of different types, which are then processed in JS and written to a "ranking" node. I have it set up so that every time a new score is submitted, the rankings are automatically recalculated and a new child is written if the user doesn't exist or updated if the user exists.
My question is how to secure this "ranking" node. Everyone should be able to read it, nobody except the system should be able to write it. This would prevent people from submitting their own rankings and aggregate scores.
EDIT
This is the operation:
Ref.child('rankings').child(uid).once('value', function (snapshot) {
if (snapshot.exists()) {
snapshot.ref().update(user); //user object created upstream
} else {
var payload = {};
payload[uid] = user;
snapshot.ref().parent().update(payload);
}
});
How would I add custom authentication to this call? Also, since I'm using AngularJS, is there any way to hide this custom token or would I have to route it through a backend server?
The key part of your problem definition is:
only the system should be able to write it.
This requires that you are able to recognize "the system" in your security rules. Since Firebase security is user-based, you'll have to make your "system" into a user. You can do this by either recording the uid from a regular user account or by minting a custom token for your "system".
Once you have that, the security for your ranking node becomes:
".read": true,
".write": "auth.uid == 'thesystem'"
In the above I assume you mint a custom token and specify thesystem as the uid.

How to re-run the test with different data using TestNG

Currently we are re-running the test when a Test Fails using TestNG iRetryAnalyzer.
Problem that we are facing is:
We have a Test to 'Add a user'. For the first time after adding a user, in the process of checking the success message exception occurred (Timeout/NosuchElement) etc But the user is added in the database.
Now again when we re-run the test with same data, the Test Fails as user is already Added.
How can i overcome this??
As here the Data, the user email id unique field. Atleast I should be able to change the Email Id when im re-running it for the second time.
Please help me.
If you just need to create a unique, fake email address that you don't need to actually use, you can always append a date/time stamp to some base email you get from your DataProvider:
#Test(dataProvider = "dp")
public void emailTest(String userName, String emailShortname) {
//Get the current time
long time = System.currentTimeMillis();
//append it to the email from your DataProvider
StringBuilder emailBuilder= new StringBuilder();
emailBuilder.append(emailShortname).append("_").append(time).append("#gmail.com");
//do user creation code below using emailBuilder result...
I would say that if you are going to do these sorts of tests using Selenium, you're going to fill up your database with junk test IDs, so I'd suggest your team create a mechanism to clean these out either as part of the test run or after it.
Ideally, if there is a way to delete a user. You should use that in the #aftertest method and remove that user.
This way the next time you will be again able to use the same email id irrespective of the test is successful or not.
If not and if the email id is never verified ( I mean like some confirmation email which you use to confirm the user) you can create fake email id on the fly like xyz123#gmail.com. If the email id is verified then i guess you are in trouble.

Google Custom Search and Passing along Querystring Variables

I am working on a web app project that has been in development for long time. The app has two sides, the majority of the site is publicly accessible. However, there are sections that require the user to be logged in before they can access certain content.
When the user logs in they get a sessionid (GUID) which is stored in a table in the database which tracks all sort for data about the user and their activity.
Every page of the app was written to look if this session id variable exists or not in the querystring. If a user tries to access one of these protected areas, the app checks to see if this sessiond variable is in the querystring. If i is not, they are redirected to the login screen.
The flow of the site moves has the user moving seamlessly from secured areas to non-secured areas, back and forth, etc.
So we did a test run with the Google Custom Search and it does an awesome job picking up all our dynamic content in these public areas. However, we have not been able to figure out how to pass the sessionid along with the search results IF the user is logged in already.
Is it possible to pas querystring variables that already exist in the url along with the search results?
As far as I know, this is not possible. Google doesn't give you the possibilty to modify the URL's of the Search Results in their Custom Search.
A possible solution would be to store your Session-Key to a Cookie, rather than passing it with every URL.
Use the parseQueryFromUrl function
function parseQueryFromUrl () {
var queryParamName = "q";
var search = window.location.search.substr(1);
var parts = search.split('&');
for (var i = 0; i < parts.length; i++) {
var keyvaluepair = parts[i].split('=');
if (decodeURIComponent(keyvaluepair[0]) == queryParamName) {
return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' '));
}
}
return '';
}
Select RESULTS ONLY option in the Look & Feel and it will provide you with the code.
www.google.com/cse/

Resources