module for an SMS queue

31 views
Skip to first unread message

Vincent Bastos

unread,
Feb 23, 2017, 2:04:58 AM2/23/17
to tryton-dev
I would like to suggest a module to manage an SMS queue. I am interested to get feedback/comments.

I need to create a module to send SMS's via an SMS gateway provider called Twilio [1]. The reason for this queue is because users should be able to tell if messages have been sent or not without having to access another system.

The idea is that we could have a generic SMS queue module which is basically a single model: SMSQueue.

sms.queue:
  • to: {phone number}
  • from: {from number}
  • body: text field
  • SMSStatus: selection
I also envisaged a second object to relate to any model:
sms.queue-models:
  • sms: Many2One to sms.queue
  • ref: Reference

A provider/gateway specific module would simply use the model above to store messages etc ...


Cédric Krier

unread,
Feb 23, 2017, 3:40:08 AM2/23/17
to tryton-dev
On 2017-02-22 23:04, Vincent Bastos wrote:
> I would like to suggest a module to manage an SMS queue. I am interested to
> get feedback/comments.
>
> I need to create a module to send SMS's via an SMS gateway provider called
> Twilio [1]. The reason for this queue is because users should be able to
> tell if messages have been sent or not without having to access another
> system.
>
> The idea is that we could have a generic SMS queue module which is
> basically a single model: SMSQueue.

Very bad idea to implement a queue with SQL table, especially using
isolation level as repeatable read.
This is even worst if the queue has to work with external system which
does not support 2 phases commit.

The best solution is to interface with the information system of the
gateway.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Vincent Bastos

unread,
Feb 23, 2017, 3:53:52 AM2/23/17
to tryto...@googlegroups.com
On Thu, Feb 23, 2017 at 6:39 PM, Cédric Krier <cedric...@b2ck.com> wrote:
On 2017-02-22 23:04, Vincent Bastos wrote:
> I would like to suggest a module to manage an SMS queue. I am interested to
> get feedback/comments.
>
> I need to create a module to send SMS's via an SMS gateway provider called
> Twilio [1]. The reason for this queue is because users should be able to
> tell if messages have been sent or not without having to access another
> system.
>
> The idea is that we could have a generic SMS queue module which is
> basically a single model: SMSQueue.

Very bad idea to implement a queue with SQL table, especially using
isolation level as repeatable read.
This is even worst if the queue has to work with external system which
does not support 2 phases commit.

The best solution is to interface with the information system of the
gateway.

Hey Cedric,

The way the Twilio API works is that you send it a request to send a message and it manages the queue. In effect, The queue is not in Tryton, but in Twilio, but Tryton has a record of what messages were sent to Twilio.

When you send a "request to send an sms" to Twilio it allows you to add a call back url that Twilio will call when the state of the message changes.

Perhaps I should remove the term queue from the model as this model just stores what was sent to the actual queue.

Cheers,

--
Vincent Bastos
Lava Lab Software

Cédric Krier

unread,
Feb 23, 2017, 4:50:06 AM2/23/17
to tryto...@googlegroups.com
On 2017-02-23 18:53, Vincent Bastos wrote:
> On Thu, Feb 23, 2017 at 6:39 PM, Cédric Krier <cedric...@b2ck.com> wrote:
> The way the Twilio API works is that you send it a request to send a
> message and it manages the queue. In effect, The queue is not in Tryton,
> but in Twilio, but Tryton has a record of what messages were sent to Twilio.
>
> When you send a "request to send an sms" to Twilio it allows you to add a
> call back url that Twilio will call when the state of the message changes.

This will be doable if twilio support 2 phase commit and if it retries
the callback if they failed.
But I do not see a generic design here, at best a twilio module.

Vincent Bastos

unread,
Feb 24, 2017, 1:24:24 AM2/24/17
to tryto...@googlegroups.com
On Thu, Feb 23, 2017 at 7:45 PM, Cédric Krier <cedric...@b2ck.com> wrote:
On 2017-02-23 18:53, Vincent Bastos wrote:
> On Thu, Feb 23, 2017 at 6:39 PM, Cédric Krier <cedric...@b2ck.com> wrote:
> The way the Twilio API works is that you send it a request to send a
> message and it manages the queue. In effect, The queue is not in Tryton,
> but in Twilio, but Tryton has a record of what messages were sent to Twilio.
>
> When you send a "request to send an sms" to Twilio it allows you to add a
> call back url that Twilio will call when the state of the message changes.

This will be doable if twilio support 2 phase commit and if it retries
the callback if they failed.
But I do not see a generic design here, at best a twilio module.

Twilio just provides an HTTP restful API.

I was thinking of sending a request inside the create method and saving the record with a different value depending on whether the request was successful or not.

Thanks

Cédric Krier

unread,
Feb 24, 2017, 4:45:06 AM2/24/17
to tryto...@googlegroups.com
This is not transactionally safe.
At best it could be done like the sendmail_transactional which is ensure
the server is up on the vote and send on finish without raising any
exception. It is not perfect but it should work in the majority cases.
Reply all
Reply to author
Forward
0 new messages