incoming-call-pickup subscription works in sandbox but not production

  • 1
  • Problem
  • Updated 4 weeks ago
so I have used the ringcentral python sdk example to make a subscription to the incoming call event. it works great using the sandbox credentials. the app was approved for production. however, when i use the production url and credentials for a valid extension(my desk phone) it does not work.. no error, nothing.. i confirmed the login credentials are correct but it acts as tho no call is coming in when there is a call coming in because my phone is ringing.
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb

Posted 1 month ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 4,486 Points 4k badge 2x thumb
Hi Kevin,

Can you post the complete filter you registered for notification?

Something like this "/restapi/v1.0/account/{accountId}/extension/{extensionId}/incoming-call-pickup"

I am afraid that in your sandbox, you login with the admin role and you can get notification for all extensions. And in your production, you might login with a standard user so make sure the incoming call is for that extension only. But this is just my guess. So please post some code and maybe print the log to see if some error happenned.

+ Phong
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
Hi Phong,

You are correct, thats the exact and complete "filter" i am using.

Yes, in the production I am logging into my own phone with my own credentials to get calls just for my own extension. The incoming call is from an outside line calling into my direct line. I did not try calling into the main line and dialing my extension, I surely would hope its not limited to just extensions dials and not direct line dials.

BTW, my user is a super admin over the entire system which should weed out any permission problems?

thank you for your prompt reply!

Kevin

Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
I just tried dialing my line from an internal phone using just the extension and it also did not call the event. there are no errors
Photo of Phong Vu

Phong Vu, Devangelist

  • 4,296 Points 4k badge 2x thumb
That's weird, I just try my code and it works well with my production extension.

In your case, do you use PubNub or WebHook type? Any error/exception or just nothing happens?

Give my your  email address so I can send you my test code.

+ Phong
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
using pubnub:
---------------------------------
    def pubnub():
        try:
            s = sdk.create_subscription()     
            s.add_events(['/account/~/extension/~/incoming-call-pickup'])
            s.on(Events.notification, on_message)
            s.register()
----------------------------------
kevinnading@teamsdp.com

no error, just nothing happens as if no call comes in

thank you!
(Edited)
Photo of Phong Vu

Phong Vu, Devangelist

  • 4,486 Points 4k badge 2x thumb
Actually let me post the entire code here. It is not long though.

Put this in your .env file and complete with your credentials:

ENVIRONMENT_MODE=production
CLIENT_ID_SB=
CLIENT_SECRET_SB=

USERNAME_SB=
PASSWORD_SB=

CLIENT_ID_PROD=
CLIENT_SECRET_PROD=

USERNAME_PROD=
PASSWORD_PROD= 
Then here is the .py code:

from multiprocessing import Process
from time import sleep
from ringcentral.subscription import Events
from ringcentral import SDK

import os
from dotenv import Dotenv
dotenv = Dotenv(".env")
os.environ.update(dotenv)


def main():
    if os.getenv("ENVIRONMENT_MODE") == "sandbox":
        sdk = SDK(os.getenv("CLIENT_ID_SB"), os.getenv("CLIENT_SECRET_SB"), 'https://platform.devtest.ringcentral.com')
        platform = sdk.platform()
        fromNumber = os.getenv("USERNAME_SB")
        platform.login(os.getenv("USERNAME_SB"), '', os.getenv("PASSWORD_SB"))
    else:
        sdk = SDK(os.getenv("CLIENT_ID_PROD"), os.getenv("CLIENT_SECRET_PROD"), 'https://platform.ringcentral.com')
        platform = sdk.platform()
        fromNumber = os.getenv("USERNAME_PROD")
        platform.login(os.getenv("USERNAME_PROD"), '', os.getenv("PASSWORD_PROD"))

    def on_message(msg):
        print (msg)
        print(msg['uuid'])

    def pubnub():
        try:
            s = sdk.create_subscription()
            #s.add_events(['/account/~/extension/~/message-store/instant?type=SMS'])
            #s.add_events(['/restapi/v1.0/account/~/presence'])
            s.add_events(['/restapi/v1.0/account/~/extension/~/incoming-call-pickup'])
            s.on(Events.notification, on_message)
            res = s.register()
            try:
                f = open("subid.txt", "w")
                print (res.json().id)
                f.write(res.json().id)
                f.close()
            except Exception as e:
                print (e)
            while True:
                sleep(0.1)

        except KeyboardInterrupt:
            print("Pubnub listener stopped...")

    def unregister():
        try:
            f = open("subid.txt", "r")
            subId = f.read()
            f.close()
            if (len(subId)):
                response = platform.delete('/restapi/v1.0/subscription/%s' % (subId))
                print ("Cancelled old subscription.")
            else:
                print ("empty")
        except Exception as e:
            print (e)

    p = Process(target=pubnub)

    try:
        unregister()
        p.start()
    except KeyboardInterrupt:
        p.terminate()
        print("Stopped by User")

    print("Wait for notification...")


if __name__ == '__main__':
    main()

Remember to create an empty subid.txt file!
Let me know,
+ Phong
(Edited)
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
thanks i will try yours out and let you know.
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
ok so i got yours to work after i removed the dotenv stuff that got me locked out of my account. however its the same result.. acts like no calls are coming thru
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
i found out the problem with the dotenv is my password has a # in it so i had to enclose it in quotes. so now i have yours working with the dotenv and still no go.. its not recognizing when a call comes in. could it be because the extension has an actual physical phone connected to it?
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
i just tried unplugging my physical phone, still no go
Photo of Phong Vu

Phong Vu, Devangelist

  • 4,486 Points 4k badge 2x thumb
So sandbox is still working for you right? Can you try with the presence filter to see if you get notification at all?
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
yes sandbox works fine. i just tried commenting out the line for incoming call and uncommented the line for presence. to test i had some coworkers call each other.. they are listed in my presence buttons. nothing came thru.. i am going to try with the 101 admin ext on the production system to see if it works
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
do i have to be an ISV to use this feature??
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
ok so i tried using the 101 extension and that users credentials and it worked fine which means it only works for the 101 ext. is there something special to get it to work for the other extensions??
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
i just tried changing the extension manually in the rest url(/account/~/extension/305/incoming-call-pickup) and i get this: "Not allowed subscribe for incoming calls of another extension"


Photo of Phong Vu

Phong Vu, Devangelist

  • 4,486 Points 4k badge 2x thumb
305 is not a valid extension id. It is probably your extension number. extension id is an internal id with 9 digits.

Can you try to make call to the main company number then when prompted for an extension, enter the extension number e.g. 305.

If you call from the RC soft phone, dial the company number followed by  * and the extension number e.g. *101 
(Edited)
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
tried going thru the main line and dialing extension didnt work. i have now gathered the extension id and tried that, still no go: /account/62712845007/extension/62431137006/incoming-call-pickup

it only seems to work with extension 101 and no other extensions. am i missing something?

Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
i am even gathering the extension id by calling
res = platform.get('/account/~/extension/~')
which works fine and returns all info about my extension. its just the hook will not connect to any other extension other than 101. i must be missing something!
Photo of Phong Vu

Phong Vu, Devangelist

  • 4,486 Points 4k badge 2x thumb
The "/account/~/extension/~/incoming-call-pickup" event filter is at the extension level only. Using the tilde sign means the account and the extension you are currently logging in.

If you want to get incoming call pickup event for all extensions under the account, you have to read account extensions' info, get all the extension ids and add each of them to the filter array

[
'/restapi/v1.0/account/~/extension/aaaaaaaaa/incoming-call-pickup',
'/restapi/v1.0/account/~/extension/bbbbbbbbb/incoming-call-pickup',
'/restapi/v1.0/account/~/extension/cccccccccc/incoming-call-pickup',
...
'/restapi/v1.0/account/~/extension/xxxxxxxx/incoming-call-pickup'
]
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
yes i am aware of the tilde meaning currently logged in user as i am also aware of this notification being for a single extension which is what im trying to do. it is not allowing me to get notification on any other extensions other than 101. i am able to login under another extension and put down info but subscribe wont work. does anyone know how to get in touch with a ringcentral developer? i have emailed them to no avail after exhausting all contact numbers only to be told there are no direct lines to the developer team. i was hoping this forum would allow me to contact the developers as this is definately a backend issue of some sort on the ring central side. I do appreciate your help Phong, thank you
Photo of Igor Bebin

Igor Bebin, Official Rep

  • 840 Points 500 badge 2x thumb
Hi Kevin, 

Please ensure that Users have "Notify my Soft Clients" setting enabled. If you an admin, then go to Service Web -> Users -> User -> Call Handling & Forwarding ->  User Hours -> My Desktop & Mobile Apps toggle. 

Also, we have another API for User's Telephony state changes, did you try Presence API and notifications? It allows to subscribe on account Presence changes within single event filter. 

Thanks,
Igor
Photo of Kevin Nading

Kevin Nading

  • 174 Points 100 badge 2x thumb
Thank you Igor, that was exactly the problem. I enabled the "desktop and mobile apps" on that extension and now it works. Sure hope you add that into the documentation so the next guy doesnt spend 2 weeks trying to figure it out. thanks again, and thank you Phong also!