4

I am trying to send an sms using nexmo gem,

The code was working fine up till a couple of days ago. enter image description here

def send_sms
    @number = params[:number]
    @nannytel = params[:phone]
    nexmo = Nexmo::Client.new(
    key: 'xxxxxxx',
    secret: 'xxxxxxx'
    )

    notification = "The contact number is following #{@nannytel}"

    response = nexmo.send_message(
      from: "SENDERID",
      to: @number,
      text: notification
    )

    if response['messages'].first['status'] == '0'
    flash[:success] = "Yayy!  We just sent you details for the nanny "
    redirect_to root_path
    else
    flash[:alert] = "Uh Oh! Something went wrong, please try entering your number again"
    redirect_to root_path
    end
  end

Above is the method in pages controller

Rahul Lakhaney
  • 109
  • 1
  • 7

1 Answers1

4

Please modify following code

response = nexmo.send_message(
  from: "SENDERID",
  to: @number,
  text: notification
)

AS

response = nexmo.sms.send(
  from: "SENDERID",
  to: @number,
  text: notification
)

above changes are needed as per documentation for version 5.0.2

OR

Use version 4.8 instead of 5.0.2

gem 'nexmo', '4.8'
Mike Szyndel
  • 10,461
  • 10
  • 47
  • 63
Ganesh
  • 1,924
  • 1
  • 18
  • 31