twilio / twilio-ruby

A Ruby gem for communicating with the Twilio API and generating TwiML
MIT License
1.36k stars 464 forks source link

Autopilot macro incorrectly sets attribute names? #552

Closed ni3t closed 3 years ago

ni3t commented 3 years ago

Issue Summary

When connecting a call to Autopilot, using this example code to call a customer, make an introduction, then redirect to an autopilot action to handle customer input, I get an error in the twilio console.

TWILIO_CLIENT = ::Twilio::REST::Client.new(<secrets>)

twiml = 
  Twilio::TwiML::VoiceResponse.new
    .say("Hello")
    .connect do |c|
      c.autopilot(
        "<app SID>",
        target_task: "some_task"
      )
    end

call_params = { 
  to: <example>
  from: <our number>
  twiml: twiml
}

TWILIO_CLIENT.api.calls.create(call_params)

the error in the console is this:

Msg | "XML Validation warning" line | "4" parserMessage | " Attribute 'targetTask' is not allowed to appear in element 'Autopilot'." ErrorCode | "12200" cols | "78" url | "" LogLevel | "WARN"

My guess is this is due to the code here: https://github.com/twilio/twilio-ruby/blob/7e218c44288b8a0954e141dfc5c8e99b5f63ffa6/lib/twilio-ruby/twiml/twiml.rb#L44

it looks like the keyword args are automatically lowerCamelCased, which is causing the keyword arg target_task to be passed along as targetTask, instead of the expected TargetTask.

If I construct the relevant TwiML by hand and pass the attr in as TargetTask i get the expected behavior.

Technical details:

ni3t commented 3 years ago

I am happy to make a contribution to sidestep the lowerCamelCase step if the argument is target_task.

thinkingserious commented 3 years ago

Hello @ni3t,

Thank you for the detailed report and associated PR! We have your PR on our backlog for review.

eshanholtz commented 3 years ago

This is not a change that can be made in the library. An internal ticket has been filed against the relevant product team (reference ID UN-2070).