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
- Navigate to: Channels
- Click Add Webhook
- Enter the following URL: https://devx.merciglobal.com/apis/wbot.php
- 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:
- Template for Non-Customers
- 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
- Click Add
- Select Webhook
- Choose Custom Webhook
- Provide a suitable Title
- Click Create
- Click Save Webhook
- Click Capture Parameters
- Copy the generated Webhook URL
- 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
- Connect the created widget on the workflow wall to CRM
- From CRM list select: Send Message Template V2
- Click Refresh next to Channel selection and select the appropriate Channel Name
- 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
- Provide a meaningful Title (top-right corner)
- Enable the workflow
- 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:
- A WhatsApp chatbot usage license must be created for the project
-
Send the following to Admin:
-
Customer registration details
- Payment confirmation details
- 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
-
๐ Register Now
-
Type: URL Button
-
๐ Call Support
-
Type: Call Button
-
Phone: +91XXXXXXXXXX
-
โน๏ธ Company Website
-
Type: URL Button
- 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
-
๐ View Ledger Balance
-
Trigger keyword: BALANCE
-
๐ฆ Order Status
-
Trigger keyword: STATUS
-
๐งพ Download Statement
-
URL Button: https://yourcompany.com/statement?mobile={{mobile}}
-
๐ Call Relationship Manager
-
Type: Call Button
- 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