First we want to receive the data a user is sending from Slack. We can
do that with the following lines:

//Slack Details$command = $_POST['command'];$text = $_POST['text'];

But this will receive the whole output. In the slash command admin
section, you can view the outgoing payload, and see what is being sent
to the server. In this case, we are using the text variable which is
just one long line, like text=94070.

But since we want to get the number and the message, we will need to
split the message and phone number. To do this, we will need to use the
explode function in
PHP which takes care of all of that.

Since our structure is number then message, we need to get the
number first.

//Parse$pieces = explode(" ", $text, 2);

We can then assume that the rest of the Slack input is the message body,
so we are using the limit of 2 to get the rest of the array.

We will be using the
sending SMS with PHP script from an
earlier tutorial. Set your app key and secret, and then set the
receiving phone number with the $phone_number=$pieces[0]; part of
the array. This will set the number that we will be sending the message
to.

Then set the message body with the rest of the array with
$message=array("message"=>$pieces[1]);.

There is also another message sent to the user on line 30 in the code
which will send a Sinch message ID back to the user, or an error
message. You can remove this if you want to deal with it yourself.

Run a few tests in Slack to check the system works. You must enter a
phone number with the international dialling code at the beginning,
either as +12784210884 or 0012784210884. If you enter a number
like 12784210884, you will get an error as the Sinch API needs the
international dialling code to send.