Send text messages directly from your IBM i with Twilio!

Now IBM i users can send text messages directly from their RPG, COBOL and CL code with just a few lines of code using just the recipient’s phone number (no need to know their carrier). With Eradani Connect’s outgoing API support, you can send text messages via Twilio, the leading open text messaging platform, at any point during your application business process. Send order acknowledgements, delivery notifications, pricing updates, special promotion announcements and any other communications quickly and easily. Check out this video on how it’s done. If it looks good, contact us for a personalized presentation and demo. Get started with Twilio text messaging from your IBM i today!

Video Transcript

All right, so let me hop in here and I’m going to share my screen. So the first thing that we’re going to look at is a text messaging system. And one of the things that I want to point out before we go into these demos is that we’re going to go through a couple of specific examples. They are all built with open source tools. And the important point of that is, you know, we do a lot of these presentations where we show an example of sending a text message, you know, and that is just one example, right? So we’ll go to an open source package manager, grab, you know, any one of the one and a half million open source modules there. What I’m going to show you is just a tiny little slice of what’s possible with these systems.

So the first use case that we have is a text messaging use case. In this case, what we want to do is we’ve got system operations happening on our IBM i and we want to send a message over to the operator via text message so we get it really quickly to get confirmation before we continue with the operation that we’re running. And what I’m going to do is I’m going to say cnfsmsc. This is my command here that is fronting a CL program. And I’m going to give it 120 seconds, which, you know, let’s make that 180 seconds. And I’m going to say it’s going to send to 295-9297. That’s my cell number. Actually, hold on. I missed a digit. 1(510)295-9297, which I need there. So I’m going to send it to my cell number. And what I’m going to say is system upgrade needs confirmation, right? So I’m just giving it a message. And I am going to send that call. And what I’m going to do here is actually I’m going to show you real quick. Now if you look at my phone here, you’ll see that I have a text message now that says system upgrade needs confirmation, reply denied to cancel the operation. So I’m going to come in here and I’m going to say deny. Why not? Let’s just cancel it. So I’m going to send my text message. You can see I sent deny. That’s there. It says confirmation received, canceling operation. Now what I’m going to do is I’m going to share my screen again. And if we go back to the 5250, my program here says success, (510)295-9297, deny, operation canceled.

So the system, two things happened here. My CL program that is run by this command sent a message to my phone. And then I sent a reply back to the CL program. And it actually received that message and was able to run actionable steps based on the contents of my message. So I’ve got two-way communication happening here. And the main point that I want to show here is that’s cool. We sent a text message back and forth from the system. I just gave it the number. That’s actually another thing to point out about this is we’re using an open source module that interprets everything we need for this call, which means that I don’t have to know the carrier. I don’t have to know any kind of information about what the number is that I’m talking to or anything like that. I just give it a phone number and a message to send, and boom, it’s done. 

And the way that we do this, what I’ve got on my screen now is the source code for my CL program. The way that I do this, what I want to emphasize here is that that entire program was really realistically three important lines of code. And what they are is basically this. We send our request. So in my CL program, I say call ECC send request. That sends a bunch of data over to the open source program. And I’ll explain why we do that in a second. So we send the data to the open source program. It’s then going to handle sending the text message. When it’s done, we do this. We say call ECC receive response. That’s going to receive data back from the open source program. And that’s all that I have to do here. And then the third line is when I come down here, I’m actually displaying the data. I’m sending a message with the result. And you can see here, I’m working with variables. And this is an important point here. I’m working with SMS status from number message. I’m working with individual variables. And in between here in these lines of code, you can see that I’m not doing any JSON parsing or any encryption or anything like that here. It’s just a really simple, I sent the message to the open source program. I receive the response. And the reason that we do that is if I bring up the open source program here, the reason we do that is because this is the code that I need to send a text message from JavaScript. This is it. I just say, create a message. Here’s the body data. Here’s the number I’m sending it from and the number that I’m sending it to. And that’s it.

So that’s why we do this is it’s really simple to send a text message from the open source. And the reason it’s so simple is because of this right here, which you may remember from Dan’s brief discussion about JavaScript. I’m using Twilio here. What I’m doing is I am importing an open source package. Twilio is a company that provides APIs for sending and receiving text messages. It is just one of the one and a half million open source modules that we have to choose from for JavaScript. So I just import their module. I say send the message and we’re done. That’s it. And then the CL program can receive the result.

Similarly, I got another section down here where I’m receiving the message. Same thing. Twilio receives the message. I send some data back to the CL program and we’re done. That’s it. Right. And these modules are handling the entire process.  So just as a quick recap here of that example program, right, what we did, I ran a command which called my CL program. That CL program set had one line of code really that was important there to send the message to the open source program. It brought in an open source module to send the text message and then it sent the it received the message, the response message from the open source system and sent the message back to the CL program.