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
Subscription for new SMS, send to Slack
Tags: sms and text messaging, subscription
Mar 4, 2021 at 6:32pm   •   4 replies  •  0 likes
Michael Kim

Trying to figure out the best way to setup a RingCentral subscription for new inbound SMS messages. The new SMS messages would be parsed and then forwarded to a Slack channel (don't need help with this part).


The auth part and how to setup my app is confusing me a bit. I think I have my client configured fine, as I was able to send a test SMS message:

client = RingCentralSdk::REST::Client.new do |config|

config.server_url = RingCentralSdk::RC_SERVER_SANDBOX

config.app_key = ##############

config.app_secret = #############


config.username = #############

config.extension = ###

config.password = #############

end


But when I try to create a subscription, it returns an error:

subscription = client.create_subscription

subscription.subscribe(['/restapi/v1.0/account/+##########/extension/###/message-store'])

===>

Subscribe HTTP Request Error: undefined method `-' for nil:NilClass


To be clear, I do not need/want end-users doing anything with the app. I just want to set a subscription for new SMS messages, so I can then create a notification for it in Slack.

Thanks

4 Answers
answered on Nov 30, 2021 at 9:34am  

@Michael Kim you mentioned "The new SMS messages would be parsed and then forwarded to a Slack channel (don't need help with this part)." Since you have that part figured out I thought I'd ask you. That's EXACTLY what I'm trying to do. I've done it using Zapier but I don't really want to pay for yet another service if I have the ability to send received SMS messages right to Slack.



 0
answered on Mar 9, 2021 at 5:24pm  

Actually, I'm not sure if this is the correct approach for what I'm trying to achieve since I need this to be a WebHook subscription. Ex: new SMS comes in, which sends a POST request to one of our endpoints


 0
answered on Mar 6, 2021 at 2:22pm  

Hi Phong,


Thanks for answering! With this event filter, I won't need to use the MessagesRetriever, right? I was following the steps in these docs: https://ringcentral-sdk-ruby.readthedocs.io/en/latest/usage/notifications/Subscribe_for_New_SMS/#step-2-sms-retrieval

It seems like the update method in my Observer is receiving the message object, so I can just forward that to Slack. Or do you recommend still creating a @retriever with MessagesRetriever? If so, for my update method:

def update(message)

event = RingCentralSdk::REST::Event.new message

messages = @retriever.retrieve_for_event event, "direction": "Inbound"

messages.each do |msg|

####

end

end


The returned messages array is empty for me here, so when I send a test message, it doesn't get "retrieved" by retriever.retrieve_for_event.


Any thoughts on what'd work best?


Thanks!


 0
answered on Mar 4, 2021 at 9:20pm  

You have to use this event filter https://developers.ringcentral.com/api-reference/Instant-Message-Event

subscription.subscribe(['/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS'])



 0
on Mar 6, 2021 at 2:22pm   •  0 likes

Hi Phong,


Thanks for answering! With this event filter, I won't need to use the MessagesRetriever, right? I was following the steps in these docs: https://ringcentral-sdk-ruby.readthedocs.io/en/latest/usage/notifications/Subscribe_for_New_SMS/#step-2-sms-retrieval

It seems like the update method in my Observer is receiving the message object, so I can just forward that to Slack. Or do you recommend still creating a @retriever with MessagesRetriever? If so, for my update method:

def update(message)

event = RingCentralSdk::REST::Event.new message

messages = @retriever.retrieve_for_event event, "direction": "Inbound"

messages.each do |msg|

####

end

end


The returned messages array is empty for me here, so when I send a test message, it doesn't get "retrieved" by retriever.retrieve_for_event.


Any thoughts on what'd work best?


Thanks!



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