Getting the caller phone number using winforms c#

Hi,
I am new to Mitel. we use mitle 9.3 as call center on local server and I am a developer who develop the main application for the company and I need to integrate my winforms c# application with Mitle to get the info from Mitle like the phone number for the client who calling the extension.
can you please tell me how to do that or even if you have any sample code for c#
many thanks

Welcome to the community @hdamis! Can you elaborate on which Mitel product you’re referring to? It sounds like maybe MiContact Center Business? In this case it doesn’t matter too much, only that you’re using a CloudLink connected PBX (listed here) since you’ll get the data from the phone system and not MiCC B.

There’s a good tutorial here for getting inbound caller data for a particular extension (or range of extensions) - Tutorials.

There’s also some sample code for this scenario, however it’s only currently available in JS - Downloads & Sample Code.

Thank budd.renaud for your quick response.
I walk through the Tutorials you mentioned but
: An unexpected error has occurred (mitel.io)
is not working it gives me An unexpected error has occurred.
also https://webhook.site/ is also not working .

so how to get the following
notify_url
applicationId
deviceId
transport
webhook
topic
ubjectFilter
publicationFilter
I have Only the IP address of the server and the username and password.
thanks if you can help me finish this taks.

You’re right, it looks like the webhooks tool that we linked to no longer exists. Thank you for pointing that out, we will remove it from the documentation. For testing purposes, you should be able to use any application or tool that’s capable of receiving webhooks.

To answer your question around creating a Subscription, I recommend checking out the Notification API Guide that explains the relevant properties.

In order to use the CloudLink APIs to do what you’re trying to do, you’ll need a few things to get started:

  • A CloudLink account (and it’s AccountId)
  • A username and password for a user on that account, preferably one with an ACCOUNT_ADMIN role

If you don’t have the above, then you’ll need to reach out to your Mitel Authorized Partner. It’s worth pointing out that you cannot deploy your own custom applications or integrations to production. You will need to have your Mitel Partner coordinate that with me as it requires action on their part.

Once you have that information, there are two possible ways to go about what you’re attempting to build:

Server Application
If your application is collecting incoming caller information for several extensions and only running in one location, you will need to:

  1. Obtain a valid bearer token for your user using the Authentication API:
POST /token 
{
'grant_type'='password',
'account_id'='{{accountId}',
'username'='{{CloudLinkUsername}}',
'password'='{{CloudLinkPassword}}'
}
  1. Use the bearer token to create a Client using the Admin API. This should be a manual, one-time setup action.

  2. Obtain a valid bearer token for the Client using the Authentication API:

POST /token
{
'grant_type'='client_credentials',
'account_id'='{{accountId}',
'client_id'='{{clientIdFromStep2}}',
'client_secret'='{{clientSecretFromStep2}}'
}

This will be what your integration code should be doing, and it will need to be refreshed periodically (grant_type=refresh_token).

  1. Use the Client bearer token to create a subscription using the Notification API, receiving the data as a webhook (see the aforementioned tutorial). You can setup your subscription to monitor a range of extensions. The subscription will need to be refreshed as it does eventually expire, information on which is included in the response body when you create the subscription.

Client Application
If your application will be deployed on user workstations and each instance collects data for that user’s specific extension, you will instead need to take a slightly different approach:

  1. Have the user enter their CloudLink credentials through the OpenID Connect Flow. More information this is available in the Authentication API Guide.

Important - During development you will need to use the same authentication method as described in the first step of the “Server Application” steps I outlined above, as the OpenID Connect Flow requires a unique application identifier called a ‘clientId’ that is only issued when your application has been submitted for review to Mitel by your Mitel Partner.

  1. Have your application create a websocket connection. Useful information is in the Notification API Guide and in this topic.

  2. Use the user bearer token to create a subscription using the Notification API, receiving the data through the open websocket connection (see the aforementioned tutorial). You will setup the subscription to only monitor that user’s extension, which you can obtain with the Admin API. The subscription will need to be refreshed as it does eventually expire, information on which is included in the response body when you create the subscription.

I hope this information helps, there’s quite a bit of background information that you might need in terms of deployment architecture which you can get through the Developer Portal and also through your Mitel Partner. If your Mitel Partner isn’t familiar with the Developer API Program here at Mitel (it’s fairly new), they can reach out to us directly for all the information they need.