question

Michael Kim avatar image
Michael Kim asked Jodi Barthold 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 |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 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 |3000

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

Michael Kim avatar image Michael Kim commented ·

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 |3000

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

Jodi Barthold avatar image
Jodi Barthold answered

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


1 |3000

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

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