question

teresa-b13989 avatar image
teresa-b13989 asked Phong Vu commented

Python subscribing to presence with detailedTelephonyState

Hi,


I am working in my sandboax environment to subscribe to incoming call to my extension. Since I later want to graduate this to looking at multiple extensions in the company I am looking at this event filter for my subscription:


/restapi/v1.0/account/~/extension/[extension_id]/presence


but since I am wanting to pull in detailed information about each individual call (specifically the session id) I am needing to scribe to the event with this filter:


/restapi/v1.0/account/~/extension/[extension_id]/presence?detailedTelephonyState=true



I can get the subscription to work when I don't filter to get the detailed information, but when I provide the detailedTelephonyState=true I get an error when receiving the notification. The error I get is "ValueError: Extra data:..."


How can I get my subscription to work and get the detailed telephony state?




The code I am using is:



def on_message(msg):
    print(msg)
    #PowerBI(msg)

def pubnub():
    s = sdk.create_subscription()
    s.add_events(['/restapi/v1.0/account/~/extension/[extension_id]/presence?detailedTelephonyState=true'])
    s.on(Events.notification, on_message)
    s.register()
    print(s.subscription())
    while True:
        sleep(0.1)

try:
    try:
        import Pubnub
        t = Thread(target=pubnub)
        t.start()
    except ImportError as e:
        print("No Pubnub SDK, skipping Pubnub test")

except KeyboardInterrupt:
    pass
pubnub()
sdk
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered
Hi Teresa,

It should work with the code you provide. While I am not sure what else could cause the problem, but I want you to double check if the extension_id is correct. Where did you get the extension id? Remember that it is the internal id, NOT the 101, 102 etc.

Also, as you want to receive notification for all extensions under your account, can you do a quick test to replace the filter with this. Just make sure to login with an admin extension.

s.add_events(['/restapi/v1.0/account/~/presence?detailedTelephonyState=true'])
I don't have Python code but this blog includes a demo app in Node JS, which implements presence monitor feature.

https://medium.com/ringcentral-developers/api-spotlight-presence-e9a725f2afa6

Let me know,
+ Phong

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

teresa-b13989 avatar image
teresa-b13989 answered teresa-b13989 commented
Thanks Phong for your quick reply. I tried looking at presence at the account level with the code you provided and I get the same error: "ValueError: Extra data: line 1 column 847 - line 1 column 849 (char 846 - 848)"

It works when I subscribe to the event /restapi/v1.0/account/~/extension/[extension_id]/presence
without the detailed filter. It seems like the SDK isn't handling the larger JSON structure that is returned with the detailed request? But I am not sure how to resolve this...
3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

teresa-b13989 avatar image teresa-b13989 commented ·
Thank you Tyler. I will check out your SDK.
0 Likes 0 ·
teresa-b13989 avatar image teresa-b13989 commented ·
I have tested out the ringcentral_client SDK and this worked with the subscription event I was using. Thank you again Tyler.
0 Likes 0 ·
teresa-b13989 avatar image
teresa-b13989 answered teresa-b13989 commented
Hi Phong, I can send you my Pubnub log if that will help. Can I send them over to you privately?

I have read over the article that you provided and I have followed the same steps but with Python.
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·
Hi Teresa,

I implement a quick python code to test pubnub notification and I can confirm with you that for that particular event filter, I got similar error as you got. It works well for some other filters though.

I will check with the engineering team and see how can we fix that bug.

Meanwhile, either you should use Tyler's SDK or try using Webhook for notification.

Thanks for reporting such a significant issue!
+ Phong
0 Likes 0 ·
teresa-b13989 avatar image teresa-b13989 commented ·
Thank you Phong for taking the time to test out the Python SDK. That is good to hear that I wasn't do anything wrong on my part, but not good to hear that there is a problem with the SDK. I have implemented Tyler's SDK and it is working good for me.

Thank you.
0 Likes 0 ·
Phong Vu avatar image
Phong Vu answered Phong Vu commented
Hi Teresa,

I found a problem from the SDK and fixed it. Can you run pip uninstall ringcentral and reinstall the SDK with pip install ringcentral and try your app again.

Let me know if you still have problem.

+ Phong
7 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

teresa-b13989 avatar image teresa-b13989 commented ·
I didn't see your second message at first. Okay, I will uninstall and reinstall the SDK and let you know.
0 Likes 0 ·
teresa-b13989 avatar image teresa-b13989 commented ·
I have uninstalled and reinstalled the SDK and I am getting the same error.
0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·
Can you double check by opening the subscription.py file and look at line 197 to see if it has this line of code?

message = decrypted.strip('\x07\x08')

0 Likes 0 ·
teresa-b13989 avatar image teresa-b13989 commented ·
I do not see that line in the subscription.py file.
0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·
Which means you uninstall and reinstall somehow did not work.

Can you double check by uninstall then run your app to see if it complains about ringcentral SDK is missing. If it does complain, install the SDK again and run.

If that still does not install the latest SDK, you can temporarily copy the whole ringcentral folder from your python lib and paste it under your app folder and run.

Let me know,
+ Phong
0 Likes 0 ·
Show more comments

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys