Announcement

Collapse

Welcome to ShoreTelForums.com

Welcome to ShoreTelForums.com!

This site was created as a place to share stories, tips, and troubleshooting help with ShoreTel/Mitel systems. ShoreTel/Mitel is obviously the MOST exciting VoiP platform on the market right now, and we realized there was no centralized place to discuss this platform, but now there is. Please feel free to join and share your experiences.

Please Note: This site IS NOT owned, funded, or managed by ShoreTel/Mitel, Inc. although you may find ShoreTel/Mitel employees sharing there experiences and expertise. If you would like more information on ShoreTel/Mitel systems, contact BTX at [email protected]

As always please support the advertisers that help support our site.

Thank You,
BTX
See more
See less
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use TAPI to make a call programatically using vbscript

    Use TAPI to make a call programatically using vb script

    Hope someone finds it useful. Its a vb script I threw together to make calls via TAPI.

    Interestingly enough on a Terminal Server any user can make use of any of the TAPI addresses registered on the server unless they are specifically linked to a user. You can do this via tapimgmt.msc

    Save the below in a txt file and rename it to dial.vbs
    Code:
    Option Explicit
    
    Dim strFilter, strNumber
    strFilter = ""
    
    If (Wscript.Arguments.Count < 1) Then  
      	Wscript.Echo "Make a call via TAPI" & vbcrlf & vbcrlf & "dial.vbs Number StringToSearchForInTapi"
      	Wscript.Quit  
    Else
    	' Retrieve the first argument (index 0).  
    	strNumber = Wscript.Arguments(0)
    	If Wscript.Arguments.Count > 1 Then
    		' Retrieve the second argument.  
    		strFilter = Wscript.Arguments(1)  
    	End If
    End If
    
    
    If Wscript.Arguments(0) = "-list" Then
    	Call ListTAPI()
    Else
    	Call MakeCall(strNumber, strFilter)
    End If
    
    
    Sub MakeCall(strNumber, strFilter)
    	Dim lAddressType, objTapi, objCollAddresses, objCrtAddress, lLoop, NewCall, gobjAddress
    
    	Const LINEADDRESSTYPE_PHONENUMBER = 1
    	Const LINEMEDIAMODE_INTERACTIVEVOICE = 4
    	
    	lAddressType = LINEADDRESSTYPE_PHONENUMBER
    	Set objTapi = CreateObject("TAPI.TAPI.1")
    	objTapi.Initialize
    	Set objCollAddresses  = objTapi.Addresses
    
    	For lLoop = 1 To objCollAddresses.Count
    		Set objCrtAddress = objCollAddresses.Item(lLoop) 
    		If Instr(objCrtAddress.AddressName, "IP Phone:") > 0 Then
    				If Instr(objCrtAddress.AddressName, strFilter) Then
    					Set gobjAddress = objCrtAddress
    					Exit For
    				End If
    		End If
    		If lLoop = objCollAddresses.Count Then
    			Msgbox "TAPI Provider Not Found"
    			WScript.quit(-1)
    		End If
    	Next
    
    	Set NewCall = gobjAddress.CreateCall(strNumber, lAddressType, LINEMEDIAMODE_INTERACTIVEVOICE) ',lMediaTypes)'Set
    	NewCall.connect(False)
    
    End Sub
    
    Sub ListTAPI()
    	Dim strAddressList, lAddressType, objTapi, objCollAddresses, objCrtAddress, lLoop
    	
    	Const LINEADDRESSTYPE_PHONENUMBER = 1
    
    	lAddressType = LINEADDRESSTYPE_PHONENUMBER
    	Set objTapi = CreateObject("TAPI.TAPI.1")
    	objTapi.Initialize
    	Set objCollAddresses  = objTapi.Addresses
    
    	For lLoop = 1 To objCollAddresses.Count
    		Set objCrtAddress = objCollAddresses.Item(lLoop) 
    		strAddressList = strAddressList & objCrtAddress.AddressName & vbCrLf
    	Next
    	Wscript.echo strAddressList
    End Sub

  • #2
    can you explain how this works?

    crimson.falconer:

    I wrote a nice phonebook web application for a previous employer that used teloquent (every PC had a teloquent client loaded on it) - I was able to alow users to enter a phone number, then save it and allow them to click a button to dial the number.

    That would be a killer app here at my new company.

    I need exactly what you're specifying here - a vbscript that dials a number using the shoretel phone on your desk.

    You're using TAPI to dial the number - do you have to install some sort of TAPI driver on your PC to get this to work?

    I copied your code to a file dial.vbs on my PC and ran it like this:

    > dial.vbs 8175551212
    I saw this error pop up:

    Script: \path\to\dial.vbs
    Line: 52
    Char: 2
    Error: Catastrophic failure
    Code: 8000FFFF
    Source: (null)
    Line 52 is:

    Set NewCall = gobjAddress.CreateCall(strNumber, lAddressType, LINEMEDIAMODE_INTERACTIVEVOICE) ',lMediaTypes)'Set

    I'm sure this is because I don't have TAPI installed.

    Tanks in advance,
    Chewmanfoo

    Comment


    • #3
      TAPI support requires having ShoreTel Call Manager installed on the machine. Have you looked at Call Manager? This already has built-in speed dial support, dial by name, importing of Outlook contacts, etc.

      Comment


      • #4
        Yes, I have the Shoretel PCM installed.

        Comment


        • #5
          Originally posted by crimson.falconer View Post
          Interestingly enough on a Terminal Server any user can make use of any of the TAPI addresses registered on the server unless they are specifically linked to a user. You can do this via tapimgmt.msc
          This may be a solution to a problem I am having with users logging in via terminal services coming up with the wrong user in the call manager intermittantly.

          Any thoughts on nailing the CM instance to the TS client?

          Comment


          • #6
            Shoretel Communicator

            Can calling by a embedded script/link with end users using Commuicator be achieved?

            Comment


            • #7
              Originally posted by Unregistered View Post
              Can calling by a embedded script/link with end users using Commuicator be achieved?
              Can you please clarify your question? I don't understand what you are aiming to achieve. I will however take a guess.

              I think what you want to do is have a button in ShoreTel Communicator that will run the script?

              I'm not sure why you would want to do this as you can already initiate a call from a ShoreTel toolbar button using the Telephone -> Dial a Number (speed dial) function.

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎