02-07-2020 11:55 AM
Hi,
How can macro editor be used to retrieve a number of a phonebook entry (Maybe by xcommand SearchPhonebook)?
I need to be able to get a number of a contact by it's "Name" and use to for calling.
something like:
function findNumber(cName) {
xapi.command('Phonebook Search',
{PhonebookType: "Corporate", SearchString: cName, SearchFilter: "People", ContactType: "Contact"});
}
Thanks,
Solved! Go to Solution.
03-03-2020 04:21 PM
You can do console.log like what tomas has provided example.
The output will show on your macro editor log window.
From there, you'll need to figure out how to extract the number and map it to a new function/variable.
02-28-2020 12:26 PM
So I assume this is not possible.....!
03-02-2020 10:07 PM
it is possible. its just a little tricky how to get the results from the commands. This is something there could have been more examples of.
const xapi = require('xapi'); function callSomeDude(contact){ console.log(contact); } xapi.command('Phonebook Search', {PhonebookType: "Local", SearchString: "dude", SearchFilter: "People", ContactType: "Contact"}).then(callSomeDude);
03-02-2020 07:09 PM
I'm curious why are you doing this?
Will this macro be used on a Cisco Touch 10 device because contact searching is built-in on the Touch 10 and you don't need to create your own macro for this.
I don't see why it's not possible to use macro to achieve this other than maybe a syntax error to your function.
Do you get errors from running this function?
03-02-2020 08:05 PM
03-02-2020 08:41 PM
Can you post the error/output from executing that function?
i'll be honest, i'm too lazy to setup a new macro to test so i just ran the xCommand via SSH to test.
The output I'm getting is in the form of:
xCommand Phonebook Search PhonebookId: "Corporate" PhonebookType: "Corporate" SearchString: "FirstName" SearchFilter: "People" ContactType: "Contact" OK *r PhonebookSearchResult (status=OK): *r PhonebookSearchResult ResultInfo Offset: 0 *r PhonebookSearchResult ResultInfo Limit: 50 *r PhonebookSearchResult ResultInfo TotalRows: 1 *r PhonebookSearchResult Contact 1 Name: "FirstName LastName" *r PhonebookSearchResult Contact 1 ContactId: "s_212" *r PhonebookSearchResult Contact 1 FirstName: "FirstName" *r PhonebookSearchResult Contact 1 LastName: "LastName" *r PhonebookSearchResult Contact 1 ContactMethod 1 ContactMethodId: "1" *r PhonebookSearchResult Contact 1 ContactMethod 1 Number: "XXXXXX" *r PhonebookSearchResult Contact 1 ContactMethod 2 ContactMethodId: "2" *r PhonebookSearchResult Contact 1 ContactMethod 2 Number: "XXXXXXXXXX@lync.zoom.us" ** end
And I think what you are trying to achieve is to extract only the number from the results.
I'm not great with XAPI but it looks like you need to modify your function to extract just the number from the full output as above.
Seems like a lot of work, the more conventional method is just setup your PABX to redirect the call to whoever is supposed to receive the call at the point of time.
03-03-2020 03:52 AM
03-03-2020 04:21 PM
You can do console.log like what tomas has provided example.
The output will show on your macro editor log window.
From there, you'll need to figure out how to extract the number and map it to a new function/variable.
02-14-2024 03:22 PM
@MohammadHadizadeh60767 wrote:
Instead of hard coding the number inside the Macro I was going to store the number as a local favourite number so in case the support number changes in future we don’t have to update all the macros on all the codecs.
So, instead of updating a macro on each endpoint, you will instead need to update a local phonebook entry on each of those endpoints... this doesn't seem like it would save much time or effort.
Updating the macros on an endpoint is really simple if you use a tool like CE-Deploy. (And similar with local phonebook entries if you must do it that way - so you don't need to wait for someone else to update it for you).
Please remember to mark helpful responses and to set your question as answered if appropriate.
02-12-2024 07:11 PM
Ever get the full macro working? I am able to pull the contact information but I am unable to find the missing piece of DIALING the number found for the contact -
Issue to solve: Zoom API constantly changes the SIP number each time the unit disconnects and reconnects to the API. In order for the speed dial to work the unit MUST dial in using the assigned SIP address so it's recognized as a CRC license unit for any meeting.
--------------macro-------
02-21-2024 12:39 PM
HERE IS MY FULL WORKING SCRIPT
Create a speed dial on the home screen for a contact in the CE address book.
Issue - Zoom API constantly changes the uri for the Zoom contact it places in the "Favorites" directory. We wanted to create a speed dial on the home screen for calling zoom with the uri set by the Zoom API. Why? Because if you dial zoom using the uri in the Favorites contact, then zoom recognizes you are calling in from a CRC licensed account and now it does not matter if the host has a zoom crc license or not. A speed dial on the home screen is wanted so special instructions are not need for users to join a zoom meeting with CRC support and a normal speed dial would not work as the uri changes frequently.
Solution: Create a macro that searches the phonebook for a "SearchString" matching part of the contact name, find the contact, extract the uri and then dials the uri.
I hope someone finds this useful as I search high and low and banged my head against the wall until I finally got it to work properly. Enjoy!
----begin code----
const xapi = require('xapi');
function callZoom(contact) {
console.log("Zoom contact found:", contact); // Log the Zoom contact details
// Extract the the contact details
const sipUri = contact.Contact[0].ContactMethod[0].Number;
if (sipUri && sipUri[1]) {
const phoneNumber = sipUri[1];
console.log("Zoom phone number:", sipUri ); // Log the extracted phone number
// Use the extracted phone number to initiate a dial command
xapi.command('dial', { Number: phoneNumber, Protocol: 'Sip'});
} else {
console.log("No Zoom phone number found.");
// Handle the case where the Zoom phone number is not found or does not match the expected pattern
}
}
// Only run when the home-screen panel-icon called Zoom-Call is clicked
xapi.event.on('UserInterface Extensions Panel Clicked', (event) => {
if (event.PanelId === 'Zoom-Call') {
//Run a search against the Phone book - SearchString is most important here
xapi.command('Phonebook Search',
{PhonebookType: "Local", SearchString: "Zoom", SearchFilter: "People", ContactType: "Contact"}).then(callZoom);
}});
------END OF CODE---------------
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide