Question

Subscription for new SMS, send to Slack

  • 5 March 2021
  • 5 replies
  • 408 views

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


5 replies

Userlevel 1

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


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!

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!

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

@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.


Reply