SMS Notifications Custom App

Hello community

I was working on adding more functionality to Erpnext Telegram Integration app, And one of my friends asked me about the possibility of adding support for sending SMS notifications, and I liked the idea, and here we are.

So I have added SMS notifications to the app, You can find it in the Extra Notifications section under SMS Notifications.

The SMS Settings is the original Doctype from Frappe, We should first record the SMS gateway settings from here.

And then we can add a new SMS Notification.

The SMS RECIPIENTS is a child DocType linked with Contact Master.

And we should make sure we have in the Contact Doc a Contact Number with Is Primary Mobile checked to appear in the Mobile No field.

And the rest is as the original Erpnext Notification.

You can find the app on GitHub.

Greetings

18 Likes

Hello @youssef

I checked the SMS notifcation and it works. Good job

But I need to be able to send a “thank you” sms to customers once a sales invoice is submitted. This is possible in email, but I cannot seem to be able to figure this out in SMS

Can you point me in the direction to go?

Regards

You can try this:

Thanks @youssef

Will this work on v12? I just tested it now and it seems not to work.

The send_sms API has been moved to Frappe Core.

Try the code below:

var message= ***[Add message here]***    

frappe.call({
            method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
             args: {
               receiver_list: ***[add numbers here]***,
               msg: message,
             },
             callback: function(r) {
               if(r.exc) {msgprint(r.exc); return;
               console.log(message)}
             }
           });

Thanks @Tanuj

Could you explain what the [add numbers here} and message codes are for ?

I want the script to be able to pick the numbers from the contact list of the customer on the sales order automatically

Its where you add your custom message and/or phone number. The receiver list takes an array, so even if its just one number make sure to wrap it in brackets.

Thanks @Tanuj

Like I said I do not expect to hardcode the telephone numbers. I will be sending many sales orders to many customers, i expect the system to pick the phone numbers automatically based on the customer chosen

Check this, please

https://github.com/yrestom/erpnext_telegram/tree/sms_dynamic_recipients

To get Dynamic Recipients

You can use this option " Dynamic Recipients"

You should definitely consider preparing the contact as follows:

Note: This is a test branch and it will be merged after successfully testing it.

1 Like

Really Cool

Just want is needed

Any hope of same for the Telegram Notifications too?

Yes, it has been updated with the same feature as well.

any possibility to support WeChat also?

1 Like

@szufisher Please check this App:

Hi @Mohammed_Redha

Can you confirm if you have used this app and what it really does?

For now there no plans to support WeChat

Now SMS notification support Dynamic Recipients

in Extra Notifications:

  1. Go to → SMS Settings and set it up as here.

  2. Go to → SMS Notification → New

    You can configure various notifications in your system to remind you of important activities. As the original Erpnext Notification.

    Here chose the “Recipients” want to send to them the notification or use the checkbox “Dynamic Recipients” to get the recipient from the DocType dynamically if it has a Link Field like “Customer”, “Supplier”, “Student” or “Employee”, for this it needs to set up a Contact for the customer, supplier…, and make sure the contact is related to the customer or supplier… and has Primary Mobile number as default.

  3. Press Save.

I also have interest in a WeChat integration into project management so that our sourcing team can integrate their WeChat conversations with suppliers into the Project Management doc_type which will allow us to aggregate all communication.

Have you or others tried to adapt the API for this purpose? I am willing to commit some budget to developers who can build and contribute to the core. @szufisher @srdgame

@youssef I followed the setup instructions and if I define recipient the sms is sent but if I select dynamic recipients I get the error below:

Traceback (most recent call last):
File “/home/ubuntu/frappe-bench/apps/erpnext_telegram_integration/erpnext_telegram_integration/erpnext_telegram_integration/doctype/sms_notification/sms_notification.py”, line 309, in evaluate_alert
alert.send(doc)
File “/home/ubuntu/frappe-bench/apps/erpnext_telegram_integration/erpnext_telegram_integration/erpnext_telegram_integration/doctype/sms_notification/sms_notification.py”, line 126, in send
self.send_sms_msg(doc, context)
File “/home/ubuntu/frappe-bench/apps/erpnext_telegram_integration/erpnext_telegram_integration/erpnext_telegram_integration/doctype/sms_notification/sms_notification.py”, line 146, in send_sms_msg
send_sms(
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/sms_settings/sms_settings.py”, line 56, in send_sms
receiver_list = validate_receiver_nos(receiver_list)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/sms_settings/sms_settings.py”, line 31, in validate_receiver_nos
throw(_(“Please enter valid mobile nos”))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 411, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’, is_minimizable=is_minimizable, wide=wide, as_list=as_list)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 390, in msgprint
_raise_exception()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 344, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: Please enter valid mobile nos

Here’s the test customer contact link

And here’s the test contact doctype

Am I missing something?

1 Like

Make sure you set default contact for the customer

@youssef thanks for the quick reply. I selected the default contact and still getting same error: