Learning something new is usually most effective with a hands on approach rather than only reading documentation. But hands on may be tricky in a developer’s context as you don’t always have all resources at hand. In this tutorial, we’ll learn a quick trick to understand the basics of RCML testing without the need for having application servers up and running.
Content of this article
Access to development resources
In the “Getting Started with Applications” section of the Proximus FlexIO documentation, we have learned that developers may need to leverage 3 elements in order to integrate flexible communications in their applications:
- FlexIO APIs: to reserve and release numbers, trigger outbound calls, send SMSes or manipulate ongoing calls
- RCML: a XML data structure that gives instructions to Proximus FlexIO about what to do with calls
- Web endpoints: exposed by your application and answering to Proximus FlexIO queries by returning RCML instructions
That documentation includes typical example flows for inbound and outbound calls. Sometimes however it’s better to try for yourself, but what if you don’t want to spin up an app server and have rapid development environment such as Node Red at hand ?
Beeceptor allows to build a mock Rest API mocking in seconds, without coding required. The web site allows to create a named endpoint, then to define rules for how the endpoint will answer based on POST/GET/OPTIONS/… conditions.
Mind that Beeceptor, in its free usage, creates public endpoints. You should NOT send sensitive data in your requests.
Testing your RCML response
Book a new number
The first thing is to have a phone number available on the FlexIO platform. You can use our number management APIs, or just use the microsite. For the latter, once logged on API Solutions, open a new browser tab to the Proximus FlexIO Number Management microsite and register a new phone number to your account.
Prepare your Beeceptor endpoint
Go to beeceptor.com, sign in with your Google account or create a new account. Create a new endpoint giving it whatever name you want – for instance “flexiorcml”. Your endpoint is now live:
Prepare your RCML response
The REST Communications Markup Language represents a set of instructions you can use to tell Proximus FlexIO what to do when you receive an incoming call. Calls from a Proximus FlexIO number to an outside number are also controlled using RCML, in the same manner as incoming calls.
For example, the following will say a short message, and then record the caller’s voice:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Say voice="woman">Please leave a message after the tone.</Say> <Record maxLength="20" /> </Response>
You can read more about RCML and all the available verbs or actions you can use on the Proximus FlexIO documentation site.
Let’s assume we want to test the following simple RCML instruction set:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Say language="google.en-US-Wavenet-B" voice="woman">Hey there, this is a test on Proximus FlexIO. What a wonderful day</Say> <Hangup/> </Response>
On the Beeceptor endpoint page above, click on “Mocking Rules”, then “Create a new rule” : when a POST (A) request is done on our endpoint flexiorcml.free.beeceptor.com/helloworld (B), Beeceptor will answer with a status 200 OK, specify the answer is of time text/xml (C) and paste the RCML from above in D:
Let’s save and proceed.
Link your phone number to our endpoint
Go to the Proximus FlexIO Console, in the “Numbers” section. Click any of your available phone numbers, not already associated to any other application. Select “RCML URL” for the voice request, then type in the URL of your Beeceptor endpoint together with the “/helloworld” you just created:
Save the settings, then call your number. That’s it !
Back on your Beeceptor endpoint page, you will find a log for all incoming requests. Click on any of them to see additional information, including information that was transmitted from FlexIO to “your application” as well as the RCML response that was sent back to FlexIO. Interesting to see which type of data is received by an application for any new call! (obviously sensitive data has been masked in this example).