May 20, 2018

New Feature: Node.js SDK

The server-side javascript SDK implements all common endpoints, webhooks, and an HTTP client so that you can focus more on business logic.

We ourselves use Amio API on projects where messaging is necessary. We always ended up writing lots of boilerplate code for every new project that got copy pasted all the time. It was more than natural that we ended up compiling all that reapeted code to an SDK. Since we mostly use javascript as a server-side language, our first SDK is written in it.

How will it help you?

  • Http client - No need to setup an HTTP client. Just provide the SDK with your access token and you're ready to go.
  • Error handling - In case an error occurs it's mapped to Amio error object.
  • Connectors - The connectors are the glue point between API and your code. They implement all the endpoints and HTTP verbs. Less space for you to make a mistake. Instead of having to call the endpoint and verb, you just call a method:
// without SDK
request('GET', '/v1/channels/{{channel_id}}/contacts/{{contact_id}}/messages') 

// with SDK
amioApi.messages.list({{channel_id}}, {{contact_id}})
  • Webhooks - When you receive a webhook, it automatically checks X-Hub-Signature to verify that the webhook was sent by Amio. Furthermore, it provides convenience methods for every event type. There's no need to write the routing yourself.
// without SDK
function routeEvents(event, data) {
  switch(event) {
    'message_received': handleMessageReceived(data); break;
    'messages_delivered': handleMessagesDelivered(data); break;
    // ...
  }
}

// with SDK
amioWebhookRouter.onMessageReceived(handleMessageReceived)
amioWebhookRouter.onMessagesDelivered(handleMessagesDelivered)

Future plans

We're observing repeating patterns in our code-bases. In next releases, we'll probably add some shortcut methods like sendTextMessage(), sendImageMessage() and some builders for structred messages messageBuilder().addButton().addTitle()

Help us improve

As always we'll be glad for any comments or suggestions you report.

Let the SDK simplify your development!

Amio.io Team

Honza Donátek
Honza Donátek

http://www.amio.io