Skip to main content
Version: 4.2

Webhook Proxy

The webhook proxy is a simple PHP application that will allow you to send notifications to Slack, Discord, Google Chat, Pushover and Telegram. It's also possible to create your own providers for other services.

Install locally on your control server

You may install the proxy locally on your control server. This is the easiest option and will allow for communication internally.

To install the proxy, run the following commands on your control server.

mkdir -p /opt/virtfusion/extras
cd /opt/virtfusion/extras
wget https://software.virtfusion.net/integrations/virtfusion-webhook-proxy.tar.gz
tar -xzf virtfusion-webhook-proxy.tar.gz
rm virtfusion-webhook-proxy.tar.gz
cd webhook-proxy
cp config-example.php config.php
chown virtfusion. -R /opt/virtfusion/extras/webhook-proxy
cp /opt/virtfusion/extras/webhook-proxy/extras/control_nginx.conf /opt/virtfusion/nginx/conf/conf.d/webhook_proxy.conf
systemctl reload vf-nginx

After it's installed, you may use the following webhook URL without authentication or encryption.

http://127.0.0.1:7001

Examples

Slack Notifications

http://127.0.0.1:7001?provider=slack_notifications&url=SLACK_WEBHOOK_URL

Discord Notifications

http://127.0.0.1:7001?provider=discord_notifications&url=DISCORD_WEBHOOK_URL

Google Chat Notifications

http://127.0.0.1:7001?provider=google_chat_notifications&url=GOOGLE_WEBHOOK_URL

Other providers require a more complex configuration.

Install remotely

The proxy can be installed anywhere you like. Its just a simple PHP application that will run on shared hosting.

The only requirement is PHP 8.0+ and the public directory as your web root.

Download

Download the latest version of the module.

VersionReleasedLink
1.0.02023-11-09download

Configuration

The configuration file (config.php) is located in the root folder and contains the provider configuration and credentials plus settings for a bearer token and IP restrictions.

Creating your own provider

To create your own provider, you need to add it to the providers array in the configuration file like so.

'providers' => [

/*
|
| Custom notifications.
|
*/

'custom_notifications' => [
'url' => '',
],
...

You then need to create a matching provider in the providers directory with the same naming, custom_notifications.php. Feel free to use the existing providers as a base for your own.

If you just want to modify an existing provider, it's wise to duplicate it and add it as a new provider. I.e slack_notifications --> slack_notifications_custom.

Provider Configuration

Slack

Creating a Slack incoming webhook involves a few steps.

Log in to Slack

  • Open your web browser and go to the Slack workspace where you want to create the incoming webhook.
  • Log in with your Slack credentials.

Go to App Directory

  • In the left sidebar, click on Apps or App Directory, depending on your Slack workspace version. Search for Incoming WebHooks:
  • In the App Directory search bar, type "Incoming WebHooks" and press Enter.

Select Incoming WebHooks

  • Click on the "Incoming WebHooks" app from the search results.

Add to Slack

  • On the Incoming WebHooks app page, click the `Add to Slackz button.

Choose a Channel

  • Select the Slack channel where you want the incoming webhook to post messages.
  • Click on Add Incoming WebHooks Integration

Copy the Webhook URL

  • After adding the integration, you'll be provided with a Webhook URL. This URL is unique to your Slack channel.
  • Copy the Webhook URL.

Discord

Creating a Discord incoming webhook involves a few steps.

Create a Discord Server

  • If you don't have a Discord server, create one. If you already have a server, you can use an existing one.

Create a Text Channel

  • Choose or create a text channel where you want the incoming webhook messages to appear.

Integrate an Incoming Webhook

  • Go to your Discord server.
  • Click on the settings icon (gear icon) next to the channel name.
  • Choose "Integrations."
  • Click on the Create Webhook button.

Set up Webhook

  • Name: Give your webhook a name. This is the name that will be displayed when it sends messages.

  • Channel: Choose the text channel where you want the messages to appear.

  • Avatar: You can optionally set a custom avatar for the webhook.

Copy Webhook URL

  • Once you've filled in the details, click on the Copy Webhook URL button.

Google Chat

Creating a Google Chat incoming webhook involves a few steps.

Create a Google Chat Room

  • Open Google Chat in your browser: https://chat.google.com/
  • Create a new room or select an existing room where you want the incoming webhook messages to appear.

Configure Room Settings

  • Click on the room name at the top of the screen.
  • In the room details panel, click on the settings icon (gear icon) to access room settings.
  • Enable "Allow external people" if you want external services to post messages to this room.

Create an Incoming Webhook

Choose a Google Account

  • Select the Google account that you want to associate with the incoming webhook.

Select a Room

  • Choose the room where you want the incoming webhook messages to appear.

Configure the Webhook

  • Give your webhook a name.
  • Optionally, you can upload an image for the webhook.

Copy the Webhook URL

  • After configuring the webhook, click on the Save button.
  • Copy the generated webhook URL.

Pushover

Obtain your API credentials from https://pushover.net/

Edit config.php and amend your credentials.

'pushover_notifications' => [
'url' => 'https://api.pushover.net/1/messages.json',
'token' => '<API_TOKEN>',
'user' => '<API_USER>',
'successPriority' => 0,
'failPriority' => 1,
]

Telegram

Creating a Telegram bot involves several steps, including creating a Telegram account, creating a new bot on the Telegram BotFather platform and obtaining the API token.

Create a Telegram Account

  • If you don't already have a Telegram account, download the Telegram app on your mobile device or use the web version and create an account.

Create a New Bot on BotFather

  • Open the Telegram app and search for BotFather.
  • Start a chat with BotFather and use the /newbot command to create a new bot.
  • Follow the instructions provided by BotFather to set a name and username for your bot.
  • Once the bot is created, BotFather will provide you with an API token. Save this token; you'll need it to authenticate your bot.

Get Your Chat ID

  • If your bot needs to send messages to a specific user or group, you'll need to obtain the chat ID. You can use the getUpdates method after sending a message to your bot. Alternatively, there are online tools that can help you retrieve your chat ID.

Construct the URL

https://api.telegram.org/bot<YOUR_API_TOKEN>/sendMessage?chat_id=-<YOUR_CHAT_ID>