[WordPress] How to notify Slack of website inquiries.

Site

In the course of running a website, we receive many questions and requests through our contact form.In order to process these quickly, it is important to have a system in place to receive notifications immediately.In this article, we will show you how to send notifications to Slack when an inquiry comes in.It is a prerequisite that you have created a contact form with the Contact Form 7 plugin.

Importance of working with Slack

Slack is a very important tool in our business.It may take some time to get used to its use, but it is highly customizable and provides access to a wide variety of tools.

The following are some of the benefits of working with Slack

Increased client confidence with fast response time

When inquiring by e-mail, there are two types of situations: one in which the reply is immediate and the other in which it is not.For the client, it is clear which is more reliable.

Even if you have set up notifications for incoming e-mails, you may be late to notice them.However, if you have a smartphone application and notifications enabled, you can receive real-time notifications at any time.

Clients are often in a hurry and may contact other competitors if replies are slow.Improved response time will also reduce lost opportunities.Quick response times are critical to building trust.

Facilitate sharing of inquiries among team members

In the course of a project, it is necessary to share inquiries among team members.It is time-consuming for each person to check his or her e-mail.

Setting up notifications in Slack will facilitate the sharing of opinions with team members.Since the contents of notifications are logged, it will be easier to consult with them.

Slack integration is very important; use Slack to improve your operational efficiency!

How to send inquiry notifications to Slack in WordPress

The following are the steps to send inquiry notifications to Slack in WordPress.
First, here are the steps on the Slack side.

  • STEP.2
    Click on “Create New App
  • STEP.3
    Select “From scratch
  • STEP.4
    Select the name of the app and the workspace for notifications and click “Create App
  • STEP.5
    Select “Incoming Webhooks”
    Screenshot
  • STEP.6
    Turn on Activate Incoming Webhooks
  • STEP.7
    Click “Add New Webhook to Workspace,” select the channel to be notified, and click Allow.
  • STEP.8
    Note down the “Webhook URL

The next step is on the WordPress side.

  • STEP.3
    Select Slack>Add New from the left bar of the WordPress dashboard screen
  • STEP.4
    Fill out the form and click “Save
    Screenshot
  • STEP.5
    You will be notified of your inquiry

You can leave it as it is, but here are some steps you can take if you want us to notify you of your inquiry as well.

  • STEP.1
    Select Plugins > Plugin File Editor from the left bar of the WordPress dashboard screen

  • STEP.2
    Select the plugin you want to edit in the upper right corner and edit the following line in Slack Contact Form 7
    function wp_slack_wpcf7_submit( $events ) {
      $events['wpcf7_submit'] = array(
        // Action in Gravity Forms to hook in to get the message.
        'action' => 'wpcf7_submit',
        // Description appears in integration setting.
        'description' => __( 'When someone sent message through Contact Form 7', 'slack' ),
        // Message to deliver to channel. Returns false will prevent
        // notification delivery.
        'message' => function( $form, $result ) {
          // @todo: Once attachment is supported in Slack
          // we can send payload with nicely formatted message
          // without relying on mail_sent result.
          $sent = (
            ! empty( $result['mail_sent'] )
            ||
            ( ! empty( $result['status'] ) && 'mail_sent' === $result['status'] )
          );
          if ( $sent ) {
            return apply_filters( 'slack_wpcf7_submit_message',
              sprintf(
                __( 'Someone just sent a message through *%s* _Contact Form 7_. Check your email!', 'slack' ),
                is_callable( array( $form, 'title' ) ) ? $form->title() : $form->title
              ),
              $form,
              $result
            );
          }
          return false;
        }
      );
      return $events;
    }
    add_filter( 'slack_get_events', 'wp_slack_wpcf7_submit' );

    Rewrite the highlighted location above as follows

    if ( $sent ) {
      $submission = WPCF7_Submission::get_instance();
      $formdata = $submission->get_posted_data();
      $contents = "A new inquiry has been submitted.\n\n";
    
      $fields = array(
        'your-name' => 'Name',
        'your-email' => 'Email Address',
        'your-subject' => 'title',
        'your-message' => 'body',
      );
    
      foreach ($fields as $key => $label) {
        $val = isset($formdata[$key]) ? $formdata[$key] : '';
        $contents .= $label . ":\n" . $val . "\n\n";
      }
    
      return apply_filters(
        'slack_wpcf7_submit_message',
        $contents,
        $form,
        $result
      );
    }

    Your-name” and “your-email” reflect the values you entered when you set up the form in Contact Form 7, so please edit them accordingly.

  • STEP.3
    You will be notified of your inquiry

summary

Integration with Slack is very important for the management of your WordPress site.There are many advantages such as immediate response to inquiries, information sharing among team members, and visualization of site traffic.On the other hand, attention should also be paid to disadvantages such as centralization of information and appropriate security measures.

If you are not sure how to do this, please feel free to contact us.
Contact us

This article is partly generated by AI.Therefore, we do not necessarily guarantee the accuracy, reliability, or completeness of the content of the article.

Comment

Copied title and URL