• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Sending formatted results to Slack Webhook

Sending formatted results to Slack Webhook 3 years 10 months ago #40253

  • matt.hankosky
  • matt.hankosky's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 1
Recently, I was tasked with coming up with a form for employees to submit if they are not going to be in the office. This form has 3 visible fields (Name, Reason, Comments) along with 1 hidden filed (slack). The Name field has been set with a default value of {global:fullname} since users need to be logged in to access the form anyway. The Reason field is a Dropdown with Items ( | Please Select[c], Working From Home, Personal Day, Sick, Other). The last field is a text box called "Comments" that is for any additional info. The slack webhook can only handle one variable called "text". So we need to define our message. We also wanted to customize the messages to make them more human readable when in slack vs whats in our database. We made a PHP script that looks at the Reason field and runs a if statement to determine the reason and set the message text. We then take the message text and post that into our hidden field.


Once you have your form setup, head over to PHP Scripts and go to "Script called on form process"
$reason = $_POST['form']['Reason'][0]; 
$name = $_POST['form']['Name'];
 
if ($reason == "Working From Home"){
$message = "$name is working from home today.";}
elseif ($reason == "Personal Day"){
$message = "$name is taking a personal day.";}
elseif ($reason == "Sick"){
$message = "$name is out of the office today and not available.";}
else {
$message = "$name is out of the office today and not available.";}
$_POST['form']['slack'] = $message;

Next, we head over to the "Post to Location (Silent Post) page.
We set Post information to another location = Yes
Post the Information Silently = Yes
Method = Post
Post to URL = (This is your Slack Webhook URL, you can create a webhook url by following this guide.

Under advanced Parameters click add
Set name to text
Set value to {slack:value}

Under Headers click Add
Set Name to Content-type
Set Value to application/json

Save your form and test.

This should now post a message to the Slack Channel when the form is filled out.
The administrator has disabled public write access.
The following user(s) said Thank You: info5553

Sending formatted results to Slack Webhook 3 years 10 months ago #40254

  • matt.hankosky
  • matt.hankosky's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 1
I will work on documentation for Microsoft Teams as well.
Last Edit: 3 years 10 months ago by matt.hankosky.
The administrator has disabled public write access.

Sending formatted results to Slack Webhook 11 months 3 weeks ago #42749

Hello Matt,

thank you for the tutorial. Is there any chance to access the Teams tutorials, too?

Greets
Thomas
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!