question

Michael Kim avatar image
Michael Kim asked Michael Kim answered

Subscription for new SMS, send to Slack

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

sms and text messagingsubscription
1 |1500 characters needed characters left characters exceeded

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 Michael Kim commented

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'])


1 comment
1 |1500 characters needed characters left characters exceeded

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

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 Likes 0 ·
Michael Kim avatar image
Michael Kim answered

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

1 |1500 characters needed characters left characters exceeded

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

Customer Spaces

Work together.
From anywhere.

Team messaging, video meetings
and phone - all in one app.


Get the new RingCentral app