Let's make use of the Messaging API SDK sample code

2026/06/04

Hello! I'm Zenigami, a technical writer. When using the Messaging API SDKs provided by LY Corporation, have you ever wondered, "How do I actually translate these specifications into real code?"

One of the best ways to solve this problem is to check out the SDK's sample code.

In this article, I'll introduce where to find the SDK sample code, the benefits of leveraging it, and walk through a portion of the sample code for the Ruby version.

SDK sample code for each language

The Messaging API SDKs for various languages are all open-sourced and available on GitHub. Inside the examples (or samples) directory of each repository, you can find sample code that is ready to run.

LanguageSample Code URL
Javaline-bot-sdk-java/samples
Pythonline-bot-sdk-python/examples
Node.jsline-bot-sdk-nodejs/examples
Goline-bot-sdk-go/examples
PHPline-bot-sdk-php/examples
Rubyline-bot-sdk-ruby/examples

Benefits of leveraging sample code

The sample code includes fundamental implementations such as signature verification, Webhook handling, and error handling, giving you a solid base to build your development upon.

Additionally, it demonstrates how to utilize various Messaging API features such as sending push messages or reply messages. This makes the sample code incredibly valuable as a reference during your development process.

Example: Sending a push message with the Ruby SDK

As a quick guide on how to read the sample code, let's take a look at how to send a push message using the Ruby SDK. The sample code for the Ruby SDK is located in line-bot-sdk-ruby/examples. Within this directory, v2/kitchensink showcases code for a wide variety of features.

By exploring the sample code, you can easily see that sending a push message to a user is implemented like this:

ruby
client = Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: ENV.fetch("LINE_CHANNEL_ACCESS_TOKEN"))

push_request = Line::Bot::V2::MessagingApi::PushMessageRequest.new(
  to: "User ID",
  messages: [
    Line::Bot::V2::MessagingApi::TextMessage.new(text: "Hello, world!")
  ]
)

client.push_message(push_message_request: push_request)

Conclusion

If you ever find yourself stuck while working with a Messaging API SDK, taking a look at the sample code for your language might just point you toward the solution. I hope this article helps pave the way for a fun and smooth development experience!