Pregunta

I'm using Twilio and Sidekiq to send text messages at specified times, but am having difficulty finding more exact documentation. Are there any good resources for this, since the wiki and github documentation don't seem to have anything as specific as I need?

¿Fue útil?

Solución

I would use the official twilio gem, it gives you a super easy wrapper to do pretty much every thing you would want to do with twilio. So your worker would look something like this...

require 'twilio-ruby'
class SendSMS
  include Sidekiq::Worker

  def perform(record_id)
    record = Collection.find record_id
    @twilio = Twilio::REST::Client.new "[Your Account SID]", "[Your Token]"

    @twilio.account.messages.create(
      from: '[Your Phone Number]',
      to: record.phone_number,
      body: 'Hey there!  This is your reminder.'
    )
  end
end

You would then schedule your Sidekiq job like so.

SendSMS.perform_at(record.remind_at, record.id)

Based on what you outlined above, something similar to this should do it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top