Skip to content

MerciGlobal Cloud ERP

WhatsApp Chatbot Setup & Implementation Guide

This document provides a complete end-to-end technical and functional guide for configuring a WhatsApp Chatbot in MerciGlobal Cloud ERP. It covers webhook registration, template approval, workflow automation, CRM integration, PHP configuration, licensing, and sample message templates.


1. Webhook Registration

Step 1: Register Webhook URL

  1. Navigate to: Channels
  2. Click Add Webhook
  3. Enter the following URL: https://devx.merciglobal.com/apis/wbot.php
  4. Save the configuration.

โš ๏ธ Ensure the webhook is successfully registered before proceeding to template creation.


2. Template Creation

Two templates must be created inside the WhatsApp channel:

  1. Template for Non-Customers
  2. Template for Registered Customers

Important Notes

  • Templates must be submitted and approved before usage.
  • Use the Sync and Refresh buttons after submission.
  • Continue refreshing until the template status shows:

  • Approved

  • Rejected

โœ… Only Approved templates can be used inside workflows.


3. Create API via Workflow

Navigate to: Menu โ†’ Automation โ†’ Workflow

Steps

  1. Click Add
  2. Select Webhook
  3. Choose Custom Webhook
  4. Provide a suitable Title
  5. Click Create
  6. Click Save Webhook
  7. Click Capture Parameters
  8. Copy the generated Webhook URL
  9. Open the generated webhook URL in a new browser tab and append parameters.

Example Test

Append to the created webhook:

?mobile=919879000300&msg=Test&file=sample

Press Enter in the browser.

You should receive a Success response.

Parameter Validation

Verify that parameters such as:

  • mobile
  • msg
  • file

are properly captured and displayed in the workflow parameter section.


4. Connect Workflow to CRM

  1. Connect the created widget on the workflow wall to CRM
  2. From CRM list select: Send Message Template V2
  3. Click Refresh next to Channel selection and select the appropriate Channel Name
  4. Click Refresh next to Template selection and choose the approved template

Parameter Mapping

  • Map webhook parameters to template variables.
  • Ensure correct mapping of:

  • Mobile number

  • Dynamic message parameters
  • Any custom fields

Accurate mapping is mandatory for successful template execution.


5. Save and Enable Workflow

  1. Provide a meaningful Title (top-right corner)
  2. Enable the workflow
  3. Click Save

The API is now successfully created and connected for CRM automation.


6. Configure wbot.php File

Copy the sample wbot.php file into your project directory.

Modify the following parameters according to your project:

  • Project Name
  • API welcome URLs
  • Campaign values
  • Database logic
  • CRM redirection logic

Sample wbot.php Code

<?php

function wbot_process_msg($wbot,$info){
   $from = substr($info['from_mobile'],2);
   $person = $info['person'];
   $msg = trim($info['message']);
   $time = date('d M Y') . ' @ ' . date('H:i:s');

   $wbot->dolog(json_encode($info));

   initProject( 'PROJECT_NAME', 1, 1 );

   $yrcompinfo = getYearCompIDCurrentDate();
   $yearid = $yrcompinfo['yearid'];
   $compid = $yrcompinfo['compid'];

   initProject( 'PROJECT_NAME', $yearid, $compid );

   $q = "SELECT id, account
         FROM #fasmast
         WHERE mobile LIKE '%$from%'";
   $res = myExecute($q);
   if ($res->num_rows == 0){
      $res->close();

      // Sender NOT found
      $campaign = 'Adhoc';
      $url = "API_URL_FOR_NON_CUSTOMERS?mobile=91$from";
   }
   else{
      $row = getrow($res);
      $acid = $row['id'];
      $name = proper($row['account']);
      $res->close();

      if (at('SAMPLE',$msg) >= 0){
         $bal = NetBalance( $acid ) . " (acid=$acid)";

         $url = "https://webhooks.whatapi.in/webhook/XXXX?mobile=91$from&project=cipl&answer=Ledger%20Balance%20$bal";
      }
      else{
         $crm_tts_code = base64_url_encode("project=cipl&mobile=$from");
         $url = $wbot->api_welcome_cust . "?mobile=91$from&url=$crm_tts_code";
      }
   }
   $wbot->send($url);
}
?>

7. WhatsApp Chatbot License Creation

To activate WhatsApp chatbot functionality:

  1. A WhatsApp chatbot usage license must be created for the project
  2. Send the following to Admin:

  3. Customer registration details

  4. Payment confirmation details
  5. Admin will create WhatsApp account access license for the project

โš ๏ธ Chatbot will not function without proper licensing.


8. Template Sample Section

Below are sample WhatsApp template structures for both Non-Customer and Registered Customer scenarios.


8.1 Message Sample โ€“ Number NOT Registered in MerciGlobal Cloud ERP

Template Name: NON_CUSTOMER_WELCOME_V1

Message Body:

Hello ๐Ÿ‘‹ Thank you for contacting {{project_name}}.

We could not find your mobile number in our records.

To get started, please choose one of the options below:

Footer: MerciGlobal Cloud ERP Support

Suggested Action Buttons

  1. ๐Ÿ”— Register Now

  2. Type: URL Button

  3. URL: https://yourcompany.com/register

  4. ๐Ÿ“ž Call Support

  5. Type: Call Button

  6. Phone: +91XXXXXXXXXX

  7. โ„น๏ธ Company Website

  8. Type: URL Button

  9. URL: https://yourcompany.com

Optional Quick Reply Buttons

  • Register Me
  • Talk to Executive
  • More Information

8.2 Message Sample โ€“ Number Registered in MerciGlobal Cloud ERP

Template Name: CUSTOMER_WELCOME_V1

Message Body:

Hello {{customer_name}} ๐Ÿ‘‹ Welcome back to {{project_name}}.

We are happy to assist you. Please select one of the options below:

Footer: MerciGlobal Cloud ERP Services

Suggested Action Buttons

  1. ๐Ÿ“„ View Ledger Balance

  2. Trigger keyword: BALANCE

  3. ๐Ÿ“ฆ Order Status

  4. Trigger keyword: STATUS

  5. ๐Ÿงพ Download Statement

  6. URL Button: https://yourcompany.com/statement?mobile={{mobile}}

  7. ๐Ÿ“ž Call Relationship Manager

  8. Type: Call Button

  9. Phone: +91XXXXXXXXXX

Optional Dynamic Message Example

If customer requests balance:

Dear {{customer_name}}, Your current ledger balance is: โ‚น{{ledger_balance}} As on {{current_date}}.

Thank you for doing business with us.


9. Operational Best Practices

  • Ensure mobile numbers are stored in consistent format (e.g., without country code internally).
  • Always verify template approval status before mapping.
  • Test webhook thoroughly before enabling production workflow.
  • Maintain logging using $wbot->dolog() for debugging.
  • Keep project configuration consistent across API calls.
  • Validate parameter mapping before going live.

10. Implementation Checklist

[ ] Webhook Registered [ ] Templates Created [ ] Templates Approved [ ] Workflow Created [ ] Parameters Captured [ ] Parameters Mapped [ ] Workflow Enabled [ ] wbot.php Updated [ ] License Created


End of Document