News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Python subscribing to presence with detailedTelephonyState
Tags: sdk
Feb 11, 2019 at 3:36pm   •   4 replies  •  0 likes
teresa-b

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()
4 Answers
answered on Feb 12, 2019 at 4:04pm  
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

 1
answered on Feb 11, 2019 at 4:57pm  
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.

 0
answered on Feb 11, 2019 at 4:13pm  
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...

 0
answered on Feb 11, 2019 at 4:04pm  
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


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us