Illustration with a yellow cookie.
We are using cookies

This website uses cookies and other tracking tools to improve the user experience, display customized content and ads, analyze website traffic, and determine the source of traffic.

Start building AI chatbots and email bots with Amio.

Book a 30-minute session where we will find out how AI bot can help you decrease call center costs, increase online conversion, and improve customer experience.

Book a demo
BlogAPI

New Feature: Node.js SDK

April 11, 2022
February 12, 2024
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

Table of Contents
1
Quick Link
Article by:
Matous Kucera

Matous is a co-founder of Amio. As a software engineer, he built several profitable businesses. Now, he is helping e-commerce businesses to get most out of chatbots and email bots.

We understand your business on

Book a 30-min consultation session where we will discuss your support cost optimization potential, experience improvements, including our online conversion increase techniques

Start free