messagebird / ruby-rest-api

MessageBird's REST API for Ruby
BSD 2-Clause "Simplified" License
37 stars 46 forks source link

"Send your first WhatsApp template message" from offical docs does not work #88

Open diaclavijo opened 8 months ago

diaclavijo commented 8 months ago

Following the official tutorial for "Send your first WhatsApp template message". Does not work for Ruby SDK

image

Even using the latest master at the time of writting this. This commit 64bcb3f17decff8141821fb61b1bd39331095da1

It suggest copy and pasting this code

# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(KEY)
# Enable conversations whatsapp sandbox feature
#client.enable_feature(MessageBird::Client::CONVERSATIONS_WHATSAPP_SANDBOX_FEATURE)

# Start a conversation
conversation = client.start_conversation('123451234, 'channelId', :type => 'hsm',
    :content => {
        :hsm => {
          :namespace => 'XXXX,
          :templateName => 'support',
          :language => {
            :policy => 'deterministic',
            :code => 'en'
          },
          :params => [
            {:default => 'Roberto'},
            {:default => '123'},
            {:default => 'new coffee machine'},
            {:default => 'MessageBird, Trompenburgstraat 2C, 1079TX Amsterdam'}
          ]
      }
    })

But when that's done it fails with "MessageBird::ServerException: Unknown response from server"

When debugging into the gem the params being sent includes key channel_id with value channelId . If set it correctly, still the code in the gemfile sends the key value with "channel_id" while it should be "channelId" and it returns with error:

0> response.body => "{\"errors\":[{\"code\":9,\"description\":\"'channelId' is a required parameter\",\"parameter\":\"channelId\"}]}\n"