> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blinkops.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WeChat

> WeChat is a versatile app that combines messaging, social media, and mobile payments.

<Warning>
  Please note that this is a beta version of the WeChat integration using the
  `Sandbox Official Account`. This integration is still under development and
  may have limitations or unexpected behaviors.
</Warning>

## Creating a WeChat connection

## Using Access Token

To create the connection you need:

* An Application ID
* An Application Secret

### Obtaining the credentials

1. Go to [WeChat Public Platform Sandbox](https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login).

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/1.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=b65d095774e81866ba595d3ca56420a6" alt="WeChat Public Platform Sandbox" width="3680" height="2212" data-path="img/WeChat/1.png" />

2. Login with your WeChat ID.

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/2.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=623597543d278bedc6f39e510aa33979" alt="Login" width="3680" height="2212" data-path="img/WeChat/2.png" />

3. Copy your `App ID` and `App Secret`. You will need them for [creating your connection in Blink](#creating-your-connection).

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/3.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=460fe405bccbe1f170b8206ba11dc480" alt="Obtaining credentials" width="2592" height="1678" data-path="img/WeChat/3.png" />

### Creating your WeChat Sandbox Official Account

Due to **WeChat Sandbox Account** limitations, WeChat will be able to send events only to a single webhook. It means you will have one webhook per **WeChat Sandbox Account**.

1. Create a new workflow in **Blink**. This will be the only workflow that will receive message from users.

2. Change the trigger type to **WeChat Webhook Events**.

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/4.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=36f1340796697e4658303d76e3f824c4" alt="WeChat Webhook Events" width="2326" height="1388" data-path="img/WeChat/4.png" />

3. Insert your `Webhook URL` and the `API Key` as a query parameter to your **WeChat Sandbox** like the following:

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/5-1.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=9c96164049808f177f8769ad1e68d7cc" alt="Copy from Blink" width="2302" height="1358" data-path="img/WeChat/5-1.png" />

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/5-2.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=999a42dbad4eac542f0afbe8c5f94984" alt="Paste in WeChat Sandbox" width="2592" height="1678" data-path="img/WeChat/5-2.png" />

4. Fill the `Token` field a random string.

5. Click on **Submit**.

If you got a green `Successfully Saved` notification, that means the setup is completed.

Your configuration should look like the following:

<img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/6.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=d50784682ad56c5f748efb5a60bb6b3b" alt="Configuration" width="2194" height="518" data-path="img/WeChat/6.png" />

From this moment, WeChat will send events to your webhook on every user interaction with this account. User interactions that will trigger the webhook are:

* Send a message
* Tap a custom menu
* Follow an account
* Scan a QR code

### Subscribing to your WeChat Sandbox Official Account

After the initial setup is complete, in order to interact with the Sandbox, each user will have to subscribe to the created account.

1. Navigate to your [WeChat Public Platform Sandbox](https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo\&t=sandbox/index).

2. Scroll down to the **Test Account QR Code** section.

3. Scan the QR code with WeChat.

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/7-1.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=e3efdf5dc1a89c666d2994a3b10b588c" alt="Scan QR" width="2486" height="1626" data-path="img/WeChat/7-1.png" />

4. Click on **Subscribe**.

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/7-2.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=b4f4351a67f34c9cf9e9d51b8af8d298" alt="Subscribe" width="1800" height="1388" data-path="img/WeChat/7-2.png" />

   <img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/8.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=46fa57e6b48780896b89fa92d46b424f" alt="Subscribed" width="1172" height="1360" data-path="img/WeChat/8.png" />

Now, you should see the subscribed users show up in the **Test Account QR Code** section.

<img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/9.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=b50d1ee69ce67b11afa54748d8b1e581" alt="Subscribed Users" width="2114" height="618" data-path="img/WeChat/9.png" />

Your **WeChat Sandbox Official Account** should be available in WeChat in the `Official Accounts` tab.

<img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/10-1.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=dd7bebedfb21a3a0de846b1e6e10e239" alt="Official Accounts Tab" width="1950" height="1408" data-path="img/WeChat/10-1.png" />

<img src="https://mintcdn.com/blinkops-2/rEe5UBpGIz5iEH3e/img/WeChat/10-2.png?fit=max&auto=format&n=rEe5UBpGIz5iEH3e&q=85&s=c9844ff3e4feef552133572fec310e4b" alt="WeChat Sandbox Official Account" width="1946" height="1404" data-path="img/WeChat/10-2.png" />

### Creating your connection

1. In the Blink platform, navigate to the **Connections** page > **Add connection**. A New Connection dialog box opens displaying icons of external service providers available.

2. Select the **WeChat** icon. A dialog box with name of the connection and connection methods appear.

3. (Optional) Edit the name of the connection. At a later stage you cannot edit the name.

4. Select **Access Token** as the method to create the connection.

5. Fill in the parameters:

   * The Application ID
   * The Application Secret

6. (Optional) Click **Test Connection** to test it.

7. Click **Create connection**. The new connection appears on the **Connections** page.
