Conversation
067800e to
03b098b
Compare
dmohns
left a comment
There was a problem hiding this comment.
Looks great. Leaving a few comments here.
- Can you explain what is the exact purpose of
MovitelTransactionParserandVodacomTransactionParser? For example, they simply get converted to Regex? - Is there a way, for each rule, to see the last X (maybe 15) messages that matched the filter? And, if they succesfully parsed?
Originally the separation of However, with all the parsing rules having the same variables i.e txn ref, account, phone etc. I have now consolidated this into a single deserialization abstraction
I think we can already get this information from the |
I meant something else, could we get the last X messages from |
Bear with me for a moment on this one. Couldn't we achieve the same thing using the SMS list page and the parsed message list page on the plugin? I may be missing something. |
|
@dmohns I've addressed most of your comments, kindly review. |
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Plugins\SmsTransactionParser\SmsParsing\Contracts; | ||
|
|
||
| use App\Plugins\SmsTransactionParser\SmsParsing\DTO\ParsedSmsData; | ||
|
|
||
| interface ISmsTransactionParser { | ||
| /** | ||
| * @param array<string, string> $regexMatches Named capture groups from the parsing rule regex | ||
| */ | ||
| public function parse(string $body, array $regexMatches): ?ParsedSmsData; | ||
| } |
There was a problem hiding this comment.
This interface is only used once. I think it's a left over. Can we remove it ?
| ``` | ||
|
|
||
| This command fetches new messages from the TextBee API and processes them the same way the webhook would. | ||
| It runs automatically on a schedule when the plugin is active, so no manual setup is needed. |
There was a problem hiding this comment.
Can you clarify what the schedule is? daily, weekly ?
| $address = $this->addressesService->getAddressByPhoneNumber(str_replace(' ', '', $phoneNumber)); | ||
| $sender = $address instanceof Address ? $address->owner : null; | ||
| $senderId = $sender?->getKey(); |
There was a problem hiding this comment.
This fails there are SMS with alphanumeric sender IDs. For example
array:3 [
"sender" => "ALDI TALK"
"body" => """
...
"""
"receivedAt" => "2026-04-10T15:46:31.000Z"
]
[2026-04-16 15:31:16] development.ERROR: Command [textbee-sms-gateway:fetch-incoming-sms] failed {"exception":"libphonenumber\\NumberParseException","message":"The string supplied did not seem to be a phone number.","file":"/Users/daniel/Development/micropowermanager/src/backend/vendor/giggsey/libphonenumber-for-php-lite/src/PhoneNumberUtil.php","line":1480,"trace":"#0 /Users/daniel/Development/micropowermanager/src/backend/vendor/giggsey/libphonenumber-for-php-lite/src/PhoneNumberUtil.php(2945): libphonenumber\\PhoneNumberUtil->parseHelper('ALDITALK', NULL, false, true, Object(libphonenumber\\PhoneNumber))
There was a problem hiding this comment.
We're now handle edge cases like this.
|
Ready for review @dmohns |
| $address = $this->addressesService->getAddressByPhoneNumber(str_replace(' ', '', $phoneNumber)); | ||
| $sender = $address instanceof Address ? $address->owner : null; | ||
| $senderId = $sender?->getKey(); | ||
|
|
||
| $sms = $this->smsService->createSms([ | ||
| 'receiver' => $address->phone ?? $phoneNumber, | ||
| 'body' => $body, | ||
| 'sender_id' => $senderId, | ||
| 'direction' => Sms::DIRECTION_INCOMING, | ||
| 'status' => Sms::STATUS_DELIVERED, | ||
| ]); | ||
|
|
||
| event(new SmsStoredEvent($phoneNumber, $body, $sms)); |
There was a problem hiding this comment.
Something inconsistent here. This works different to the callbacks. I.e. it always creates records in sms table even for Spam SMS and for Transaction SMS.
Also, currently running this creates duplicate SMS records.
There was a problem hiding this comment.
This has now been addressed.




Makes progress on #1345
#1351 should be merged before this.
Brief summary of the change made
This PR expands on the bi-directional sms communication feature. With these changes we are creating use-case to support recording transactions from Mobile money providers through sms receipts.
MPM uses the sms gateway to obtain the receipts and does sms parsing using a flexible Parsing rule configured by the user as a plugin.
Are there any other side effects of this change that we should be aware of?
Describe how you tested your changes?
Pull Request checklist
Please confirm you have completed any of the necessary steps below.