Brief:
- Purpose: import call history from MegaPBX into MikoPBX CDR.
- Next: from MikoPBX you can export call history to 1C:Enterprise (see
getHistory.epf). - Limitation: works only with MegaPBX; the module is read‑only and does not control calls.
- Access to MegaPBX API (CRM API) and a valid API key/credentials.
- Installed MikoPBX with permissions to install and run modules.
- In the MikoPBX web UI go to: Modules → Module Marketplace → Upload new module.
- Select the
ModuleMegafonPbxarchive and wait for installation to finish. - Activate the module.
In the module settings specify:
- Megafon PBX address: e.g.
vats.megafon.ru. - API key for authorization in MegaPBX.
- Which number to display in history — internal or employee mobile number.
- Time offset — shift record time by the specified hours.
- CRM token — secret string used to authenticate incoming webhook events from MegaPBX (must match the token configured in the MegaPBX cabinet, see below).
Save the changes.
The sync script uses the module’s saved connection settings and the sync period.
- The module queries the MegaPBX History API and fetches events for a period.
- Records are inserted into MikoPBX CDR; duplicate protection is applied.
- The module is read‑only and does not modify data in MegaPBX.
Besides the periodic pull, the module exposes a public REST endpoint that MegaPBX VATS can push events to (real‑time call notifications, history records with recording link, contact lookups for popup cards):
POST https://<your-pbx>/pbxcore/mega-pbx/event
Content-Type: application/x-www-form-urlencoded (or application/json)
Authentication is done via the crm_token field in the request body
(must match the CRM token from the module settings).
Supported cmd values:
event— call state notifications (INCOMING / ACCEPTED / COMPLETED / …); forwarded to 1C via SOAP ifModuleCTIClientis configured, otherwise written to the file log.history— final call record with mp3 link; accepted with200 okand ignored, since the cron workerbin/synchCdr.phpalready loads the same history via/crmapi/v1/history/json.contact— client lookup by phone for a popup card on the IP phone. Returns{"contact_name": "..."}ifModuleCTIClient/ its CRM daemon are available,{}otherwise.
To enable webhook delivery in MegaPBX:
- Open the MegaPBX customer cabinet → Integrations → CRM API.
- Set the CRM URL to
https://<your-pbx>/pbxcore/mega-pbx/event. - Set the CRM token to the same value you saved in the module settings.
Logs are written with rotation (40 MB × 9 files) to:
/storage/usbdisk1/mikopbx/log/ModuleMegafonPbx/EventController.log
The webhook endpoint is public (no Bearer/cookie auth, only crm_token).
At minimum:
- Use HTTPS only. Without TLS the
crm_tokenis sent in plain text. - Restrict the source IP on the firewall. MegaPBX delivers webhooks from
a known address — for example, traffic on the production VATS goes from
193.201.230.155. Configure your firewall / nginx allow‑list so that/pbxcore/mega-pbx/*accepts only this address (and any other documented MegaPBX outbound IPs of your installation; verify the current list with the operator's support). - Use a strong, random
crm_token(e.g. UUIDv4) and rotate it periodically. - Monitor
auth_failentries in the EventController log — repeated failures indicate a brute‑force attempt.
- Call history imported to MikoPBX can be exported to 1C by standard means.
- The repository includes
getHistory.epffor fetching history from MikoPBX into 1C.
- MegaPBX CRM API (History): api.megapbx.ru
- Megafon VATS REST API: vats.megafon.ru/rest_api
- Questions and bug reports — via the project’s issue tracker.
- License: see
LICENSE.