Send SMS by CodeBlock

Hello everyone,
I trying to develop some flows, in the begin is very easy but now I would like to improve the difficulty.
I would like to write a VoiceFlow where I can send an SMS. I cannot use IFTTT because does not work.
I get an account in Nexmo where you can start to send some SMS for free. I tried to send SMS by command line and it’s OK.
The code supplied by Nexmo for command line is:

curl -X “POST” “https://rest.nexmo.com/sms/json
-d “from=3937030#####”
-d “text=Hello world from Nexmo.”
-d “to=3934876#####”
-d “api_key=8da#####”
-d “api_secret=C2Dh59jAJbk#####”

This mode works perfectly.

Now I would like to try with a code block in VoiceFlow.

The code supplied by Nexmo for Javascript is:

The library to install
compile ‘com.nexmo:client:4.+’

The code

NexmoClient client = new NexmoClient.Builder()
.apiKey(“8da#####”)
.apiSecret(“C2Dh59jAJbk#####”)
.build();

String messageText = “Hello world from Nexmo.”;
TextMessage message = new TextMessage(“3937030#####”, “3934876#####”, messageText);

SmsSubmissionResponse response = client.getSmsClient().submitMessage(message);

for (SmsSubmissionResponseMessage responseMessage : response.getMessages()) {
System.out.println(responseMessage);
}

Now, I tried to create a Code block in a Voiceflow, I defined the variables but I always get an error.

Could anyone help me?
Beppe
:kissing_heart:

P.s.: The character ##### to mask my data

I succeeded using an API Block, now I need to read the result that I find in the RAW tab. For example, how do I read and save on a variable the “remaining-balance” ?
I must also retrieve only the time from what is present in “date”.
Respectively in the attached image “1.40960000” and “17:28:20”

Help me for this last step and then at the end I make a summary of all project.
:smiling_face_with_three_hearts:

click for image of Raw tab

You can find the final solution in in this tutorial