# Version 2 (new method)

## Features

* Open tickets directly from WhatsApp
* Simplify your exchanges and track your tickets directly from the app or a web browser

## Requirements (self-hosted)

| GLPI     | PHP minimum | PHP recommanded |
| -------- | ----------- | --------------- |
| ≥ 11.0.3 | 8.2         | 8.4             |

{% hint style="info" %}
A [GLPI Network BASIC](https://services.glpi-network.com/#offers) subscription (or higher) is required. This plugin is also available for all GLPI Network [Cloud instances](https://glpi-network.cloud).
{% endhint %}

* Must have an active WhatsApp Business account (Meta) with a valid phone number
* Must have a GLPI instance accessible via the internet and HTTPS

{% hint style="success" %}
**GDPR - Good to know** For the WhatsApp plugin to function correctly, GLPI stores the user's phone number in its database. This information is essential for the WhatsApp plugin to function.

Using the anonymize plugin may lead to undesired behavior if the phone number is anonymized.
{% endhint %}

***

## Install the plugin

<div align="left"><img src="https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/9Qj0mu4gH2me62JPF1tD/attachments/de293202-7883-40aa-8336-a5da825a0438.png" alt="Install the plugin"></div>

The plugin settings will then be configured in `Setup` > `General` > `Whatsapp`.

***

## Create and configure the Meta (WhatsApp) application

### Create an application with the Meta account

* From the Meta Developer account: <https://developers.facebook.com/apps/creation/>
* Click on Create an Application ID
* Select the business account that will be linked to the application
* Click Next, then validate your application by clicking on Go to dashboard

![Create an application](https://3573604317-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUCcURk2xlvtpVGbiRZf%2Fuploads%2F6PoiRAFCGPJTCZwFkNxP%2F84a794cd-1480-46f4-94bf-36c905c97fa4.png?alt=media\&token=a750f48d-fc66-46c5-b534-e9fdb15fa507)

* Select the business account that will be linked to the application

![Select business account](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/7BofJXmb96B6RVYzxMn2/attachments/7ccbe582-5f0c-45da-97d3-d545a4adbb9d.png)

* Click on **`Next`**,then validate your application by clicking on **`Go to dahboard`**

![Go to dashboard](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/h0Qa4h0S72hhpsSBCNyT/attachments/672931a5-8615-42a3-942a-cdabd7d3db6e.png)

### Setup the application

* Once created, you will be taken to your application's dashboard.
* From this page, click on **`Use cases`** > **`Customize`**

![Use cases - Customize](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/wEarwBcUcTgUXZViPs0i/attachments/29e4ac08-c940-4e86-b9db-fc8ca175eb66.png)

<figure><img src="https://3573604317-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUCcURk2xlvtpVGbiRZf%2Fuploads%2FD9WeHl2h4czAIiUKRweJ%2Ff1a4758e-07e8-46c6-8025-73fc1ae2c00f.png?alt=media&#x26;token=67d28aef-dafe-4e4d-9042-3a1b2022fd84" alt=""><figcaption><p>Use cases - Customize</p></figcaption></figure>

* Click on Configure API in the left menu and make sure the phone number is correctly registered.

![Configure API and phone number](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/A5rks126tt0fq767TfLa/attachments/e73383b4-fe1c-40f3-9866-e139b3816442.png)

* If this is not the case, click on **Add a phone number** and follow the steps.

![Add a number](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/TYbYswsN2iKi5lAnu99H/attachments/de3625f9-0221-4472-903a-c5cb567c323a.png)

### Setup the Webhook

* From the Configuration tab, copy/paste the URL and the token (available from GLPI **`Setup`** > **`General`** > **`Whatsapp`**).
* Click on **Verify and save**.

![Callback URL and GLPI token](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/Hh7XPuV38IUvO7gHf6KZ/attachments/5ba74809-9836-4444-b12e-1f26c8bddc29.png)

* Once the callback URL and token are validated, a list of fields will appear. Find the **`messages`** field and check it.

![Activate messages](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/FQ8hIS2jkiUi71nGwWyw/attachments/30435321-f530-4aef-b6b0-c02a43ca6d93.png)

***

## Manage users

It is preferable to create a dedicated user who will have specific permissions to be authorized to use WhatsApp webhooks.

### Create a user

* From your Meta account (<https://business.facebook.com/>), go to **`Settings`** > **`People`**.
* Click on **`+ Invite people`**.
* Enter the requested information:
  * Email address
  * Assign access: select Full control
  * Assign an asset: select the desired WhatsApp account and ensure that **`Messages`**, **`Message templates`**, and **`Phone numbers (view only)`** are checked.

![Invite people / assign assets](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/48zxMBz81fPrMIvZ9zx9/attachments/fd335935-08ae-4c8a-becf-6a11ccdb46bc.png)

{% hint style="info" %}
Before the user can manage the application, they will need to accept the invitation to join the WhatsApp account. Once the invitation is accepted, there may be a delay before they can be granted permissions on the application.

![](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/inH3kpWQqRuCw5nVEPYY/attachments/9796a5ed-fb90-4323-b07f-c2b8e6617da7.png)
{% endhint %}

* Confirm to save the account and send the invitation.

### Assign the application

* Once the invitation has been accepted, go to your Meta account, then **`Accounts`** > **`Apps`**.
* Select the application you created earlier, then **`Assign people`**.
* Check the desired user and assign the necessary permissions.

![Assign people to app](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/f5OSns2LAxL5wicrNwyU/attachments/a4c546f8-5671-48d7-9c7c-cc21a6fff3f6.png)

<div align="left"><img src="https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/dczvxh8M9j6SCfNURfgb/attachments/3393b9db-bf0c-48e8-9ffb-83230df358d0.png" alt="Assign permissions"></div>

### Creating a System User Account

The system user account allows generating a token that must be entered in GLPI to validate the configuration between WhatsApp and GLPI. This user will be used as the bot for the application.

* In your Meta account, go to **`Users`** > **`System users`**, click on **`+ Add`**.
* Enter a name for the account.
* Select **`Employee`**.
* Confirm to create the account.
* After creating the system user:
  * Click the menu on the right, then **`Assign assets`**.

![Assign assets to system user](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/Zjxc51p0QLUfzCE7Jrs9/attachments/d493c501-a101-42e0-8a70-be23c99a590c.png)

* Select the created application and then **`Full control`**.
* In the **`WhatsApp Accounts`** section, select **`Messages templates (view only`**`)` and **`Messages`**.
* Click on **`Assign assets`**.

![Assign WhatsApp assets](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/6YMUcqTJdovO0jxF40Fd/attachments/bcd48084-98dc-43f9-95e4-7d517a48d7a2.png)

### Generating the token

* From system users, click on `Generate token`.

![Generate token](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/84DgqGS9M8op4afurWVL/attachments/29afd9bb-213a-4f2a-98af-aee551fb8dd9.png)

* Select the desired application.
* Select the token expiration time (60 days or never).

{% hint style="danger" %}
If you select 60 days, you will need to renew your token to avoid service interruptions for your application.
{% endhint %}

* Assign the following 3 permissions:
  * **`whatsapp_business_manage_events`**
  * **`whatsapp_business_management`**
  * **`whatsapp_business_messaging`**

![Select permissions for token](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/shch9jtFOMinkFblfHVK/attachments/89604c80-fd33-4725-ba55-02c1b9979f03.png)

* Then click on Generate token.

{% hint style="info" %}
Keep this token, which must be entered in GLPI.
{% endhint %}

***

## GLPI Configuration

* From your GLPI instance, go to **`Setup`** > **`General`** > **`WhatsApp`**.
* In **WhatsApp Business Account ID**, enter the WhatsApp account ID (available in your account settings on Meta then **`Accounts`** > **`WhatsApp Accounts`**: <https://business.facebook.com/latest/settings/whatsapp\\_account>).

![GLPI WhatsApp account ID](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/sERObRr2HUXmWfCQRI8Q/attachments/698eadd8-42dc-4468-84b5-d2da88f305a6.png)

* In **Access Token**, enter the previously generated token.
* Save your entry.

If everything is OK, a message will appear informing you that your configuration is valid.

![Configuration valid](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/azuWzePCYlozBtgJZigo/attachments/a5b57826-a951-4e3c-9046-e1d0033a31b1.png)

## Configuring Notification Templates

You don't need to do anything special regarding the templates. They are generated directly by the plugin and are visible in the Message Templates section of the WhatsApp plugin configuration on GLPI.

![Message templates in GLPI](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/m40nyl6aK4e4Re6nw4vu/attachments/208c4611-696d-49df-89d5-814e62ffd8f2.png)

The **`refresh`** button allows you to resynchronize the templates with WhatsApp if they are not APPROVED (or when adding new languages via the plugin).

## Before activating your application

### Privacy Policy and Logo

Before activating your application, you will need to provide a URL for the privacy policy.

* From **`Application Setup`** > **`Basic`**, enter the appropriate URL.
* Also add a logo (the one that will appear publicly on the WhatsApp contact).

![App basic settings - privacy and logo](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/9lwl3If44IUh3cdSS92l/attachments/93caadc8-3aa5-479d-990b-6e91c92f0aff.png)

### Payment Method

A payment method must be enabled, otherwise message templates cannot be sent.

* From your [Meta account](https://business.facebook.com/), go to **`Accounts`** > **`WhatsApp accounts`**.
* Select the desired account.
* Click on **`Payment settings`** and follow the steps.

![Payment settings](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/ubuOqkzieJaYOa4oXEeR/attachments/ac05a5cd-eee9-4bb3-a2e3-d36d0984116c.png)

***

## Publish your application

You can now publish your application.

![Publish application](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/zR7TxAAMUS8YHZ0wA3F9/attachments/80c33446-efa2-4e60-8fdb-3cb9f9c14419.png)

***

## Ticket configuration

### Anonymous access

You can allow or deny access to anonymous users (those not present in the database).

![Anonymous access setting](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/wlUaB1TwH59Epe5EqsHf/attachments/6e859db5-ae71-4a7e-9fb4-8b63debfdb80.png)

### Ticket title template

You can add variables and/or text that will be transcribed into the ticket title.

<div align="left"><img src="https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/4YFg6kS8NayngSVfmbxn/attachments/0b64f11c-41ed-4274-a524-e904d3fb865e.png" alt="Ticket title template"></div>

### Business Rules

To customize the plugin's behavior, you can add business rules. The engine works like the GLPI rules engine.

Rules management is located in **`Administration`** > **`Rules`** > **`WhatsApp - Ticket Rules`**.

![WhatsApp Ticket Rules](https://content.gitbook.com/content/uUCcURk2xlvtpVGbiRZf/blobs/j5s0krtvMtbvyt3UJPgZ/attachments/bb5c9024-1d9f-43a0-9a57-14e41ac471d3.png)

The criteria relate to either anonymous users or WhatsApp numbers and will trigger actions such as sending a message upon receipt of a ticket, updating the entity, category, urgency, etc.

***

## Current Limitations

* Only ticket follow-up updates and solutions are sent to the user. Tasks and satisfaction surveys are not compatible.
