You’ve chosen to use the bbpnns Reply by Email Webhook instead of the WordPress Cron system. Smart choice. Now, every time the Webhook is called, the plugin will check your inbox for the newest replies to be added to your bbpress forums.
[vinyl scratching] Wait, what’s a webhook?
Webhook is nothing but a fancy name for an action taken by a site when a given URL is accessed. In the plugin settings you were given a web address to use.
The trick now is getting that webhook called as frequently as possible without enraging your web host.
Keep reading to learn about our recommended methods of setting up the Webhook calls.
IMPORTANT: On March 30, 2019, Gmail changed their API and IFTTT can no longer offer its service. We’re sorry, but it is not within our control. Please refer to the Zapier or Real Cron Jobs steps instead.
For the purpose of this tutorial, we’ll assume you’re using Gmail. Setting up Outlook 365 (if you have the paid service) should be pretty much the same (we haven’t done it ourselves, to be honest, as we don’t have the paid service).
Here’s what you need to do to get bbpnns Reply by Email running with IFTTT:
- Create a free IFTTT account just to use with this plugin, if you don’t already have one. Simply go to https://ifttt.com and follow the signup steps. You can also choose to connect with your Google or Facebook account.
- Once your account is set up, go to the Gmail service page: https://ifttt.com/gmail (or https://ifttt.com/office_365_mail if you’re setting up your paid Outlook account).
- You can only have one connected Gmail account per IFTTT account, so if you already have Gmail connected with your existing IFTTT account, disconnect it *. Then click the big Connect button.This will take you to the Gmail OAuth screen, where you’ll need to log in with the Gmail account you set up in your bbpnns Reply by Email settings screen, and click ‘Allow’ when prompted.
- That’s it for Gmail. Now we need to tell IFTTT that we want to use Webhooks. Go to https://ifttt.com/maker_webhooks and Click connect, just like you did for Gmail.You will not get any Oauth screens or anything. Just the Webhooks screen without the connect button.
- Finally, set up your Applet to call our Webhook when new messages arrive. IFTTT seems to check Gmail every minute, so this is by far the best solution you can get. Click My Applets > Create, or go directly to https://ifttt.com/create. You’ll see the new applet screen:
Click on the big blue “+ this” link (yes, it’s a link – I was a bit lost way back when I first tried it).
- Enter Gmail in the “Choose a Service” screen, and click the Gmail icon.
- In the Trigger screen that comes up, select the box that says ‘Any new email in inbox’. You’ll be taken back to the New Applet screen with the ‘+ that’ now linked and the Gmail icon replacing the ‘+ this’. Click ‘+ that’ and type Webhooks. Click the Webhooks icon.
- Click the ‘Make a web request’ action box (the only one available at the time we wrote this tutorial).
- Enter the bbpnns Reply by Email Webhook URL you were given in the plugin’s settings screen in the URL field. Leave the other fields as they are, as they are not important. Finally, click the ‘Create Action’ button at the bottom of the box.
- You’re almost there! You can now choose to change the description of your action and whether to receive notifications when the applet runs. Just click ‘Finish’ to complete the applet creation.
Once your applet is created, you can turn it off or on, and also force check the Gmail account.
You can take a more complicated approach and share a gmail account by setting up labels for messages that contain <you>+usc_ as the beginning of the “to” field, and have the Gmail trigger run when a message gets labeled, but that’s beyond the scope of this tutorial.
Zapier is another service like IFTTT, where you get to create “Zaps”. Like IFTTT, you can connect to service providers and create triggers. Unlike IFTTT, it lets you connect to IMAP so you can use it for free Outlook/Hotmail accounts and even your hosting provider’s email service if you’re using that. The downside of using Zapier is that it only checks your mailbox in 15 minute intervals instead of every minute, so your forum participants are likely to think something went wrong and re-send the replies over and over. Each email reply will be translated into a forum reply, even if it’s a duplicate.
IMPORTANT: The bbpnns Reply by Email plugin requires an email server that supports “plus aliases”, i.e. sending messages to email@example.com is the same as delivering to [email protected] To our knowledge, the only large hosting providers that currently support this are Gmail and Outlook/Hotmail. The plugin will NOT work without it. Only go the IMAP route if you tested “plus alias” support manually or via the plugin settings screen. You’ve been warned :). Continuing…
To set up a Zap to trigger the webhook, follow these steps:
- Create a free zapier account if you don’t have one;
- Search for IMAP by Zapier app and select it;
- Search for Webhooks by Zapier app and select it;
- Click the ‘Use this Zap’ button in the box that says ‘Create Webhook post from new IMAP emails’.
- Follow the instructions to create the Zap. When prompted to connect an IMAP account, use the IMAP settings that your hosting provider gave you;
- Click Save+Continue;
- Select Inbox when prompted to select an IMAP folder. Click Continue;
- Click Fetch+Continue to test the connection;
- If the test is successful, click Continue to set up the Webhook;
- The only option now is to “Fire off a single POST request as a form or JSON”. Click Continue;
- Enter the Webhook URL you were given in the bbpnns Reply by Email plugin’s settings screen in the Zapier URL field. Click Contiue;
- Click Send Test to Webhooks by Zapier. Don’t worry if it says that the test was successful but no data was available. That’s intentional.
- Finally, click finish.
Zapier will check the mailbox for new messages every 15 minutes and call our plugin to do the processing.
Real Cron Jobs
The Cron system was designed to let people run programs at given dates/times or intervals (called jobs). It is essential in any Unix or Linux environment, and all decent hosts will let you create new jobs.
WordPress tried its best to create a faux Cron system for those who can’t or don’t want to deal with real Cron systems. However, because it needs to keep its performance good, it can’t simply run indefinitely in the background waiting for whatever date/time there are jobs to run. It only runs when someone visits your site, so even if you have a job that was set to run at, say, noon every day, and your site only receives a visitor at 5PM, that’s when the noon job will run.
You can (and, for bbpnns Reply by Email to work effectively, should) replace the Cron functionality that’s bundled with WordPress with a real Cron job. It’s quite simple and jsut requires editing wp-config.php to disable the internal WP Cron before running your own.
There are several tutorials available on how to do that. I like the one at SiteGround.
Feel free to follow that tutorial to the letter if you want to (to replace WP Cron), especially if you chose to not use the Webhook.
To get bbpnns Reply by Email to work as a Webhook, you’ll need to add the Webhook command that you got in the Settings screen as a new job in the Cron Job screen in cPanel – you don’t need to replace WP Cron at all.
Set it to run as frequently as possible without enraging your hosting provider. SiteGround asks that you don’t run any jobs in intervals smaller than 30 minutes. This is obviously not frequently enough for any good user experience (where’s my email reply? should I send it again?), which is why using Cron Jobs is last on our list.
This concludes our tutorial on how to set up bbpnns Reply by Email to work with Webhooks. We strongly believe that setting up IFTTT with Gmail is the best option to get the smoothest email to reply user experience.