This article is part one in a month-long series aimed at learning and exercising the RingCentral APIs in Python as part of their new Game Changers challenge. Feel free to follow along, leave a comment, or even participate in the challenge yourself!

Thus far, we've learned how to configure an automated voice message system, transcribe voice messages, and leverage AI to categorize those messages. The next step in our journey is to actually act on the categorization of those messages. What should happen when a voicemail comes in? Should we immediately page a first responder by text? Should we send an email to a support team? Should we create a work ticket? The actual actions we can take are as diverse as the messages that could come in.

For the purposes of this walkthrough, we merely want to send a text notification that there's a pending voice message.[ref]When we pull everything together later, we'll want to also categorize theĀ urgency of the message and only send a text if the message itself is urgent.[/ref]

API Integration

As we've already set up our RingCentral account, today we just want to exercise it to send a message. Like our examples before, the first thing we need to do is install the Python SDK:

pip install ringcentral

Before we can send a message, though, we need to create an application through the RingCentral console. Logging in and clicking "Create App" will let us set things up and wire in the appropriate credentials. If/when we're ready to graduate our app to production for use with real phone numbers, we can do so from the same screen.

[caption id="attachment_8134" align="aligncenter" width="1060"]Sample App Sample app in the RingCentral console.[/caption]

Now we want to actually send our text message. The recipient below is going to be my cell number. The other credentials all come from my RingCentral account directly:

from ringcentral import SDK

RECIPIENT = '<ENTER PHONE NUMBER>'

RINGCENTRAL_CLIENTID = '<ENTER CLIENT ID>'
RINGCENTRAL_CLIENTSECRET = '<ENTER CLIENT SECRET>'
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'

RINGCENTRAL_USERNAME = '<YOUR ACCOUNT PHONE NUMBER>'
RINGCENTRAL_PASSWORD = '<YOUR ACCOUNT PASSWORD>'
RINGCENTRAL_EXTENSION = '<YOUR EXTENSION, PROBABLY "101">'

rcsdk = SDK( RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER)
platform = rcsdk.platform()
platform.login(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD)

platform.post('/restapi/v1.0/account/~/extension/~/sms',
{
  'from' : { 'phoneNumber': RINGCENTRAL_USERNAME },
  'to' : [ {'phoneNumber': RECIPIENT} ],
  'text' : 'You have an urgent voicemail pending...'
})

Entering the appropriate credentials and running the code above successfully dispatches a message to my cell:

[caption id="attachment_8136" align="aligncenter" width="1080"]Test SMS Test SMS message from our virtual assistant.[/caption]

Next Steps

The final step for our next post will be to wire everything together - from receiving the voice message to broadcasting a text alerting us of its urgency. Stay tuned!