New command slash


I am a beginner, so please be understanding. I want to create commands in mattermost “ping”, “whois” and “ps”. I have no idea how to adapt my file to work with the mattermost.

I have something like that.


$json = file_get_contents('php://input');
$update = json_decode($content, true);

switch ($text):
	case "/whois":
		$status = "$text,0";
		file_put_contents($file, $status);
		$msg = "Enter the domain to search";
	case "/ping":
		$status = "$text,0";
		file_put_contents($file, $status);
		$msg = "enter the IP address";
	case "/ps":
		$status = "$text,0";
		file_put_contents($file, $status);
		$msg = "enter the text";

Can I count on any tips?


Hi @MajorS,

It’s been a long while since I’ve written any PHP but generally what you’ll want to do is, is set up three different slash commands on your Mattermost server. Then point each one at your different URLs (e.g. Have the user pass in any arguments after the slash command when they type it. Then on your server, parse the HTTP POST and respond appropriately with a message body for what you want to respond with.

See the documentation for more details: