Getting Started for Kik Bots

Botmetrics: Analytics for Kik Bots

Kik is a leader and innovator in as both a messaging service and a bot platform to enable more intelligent engagement between companies and people.

botmetrics makes it simple to get instant analytics and gives you levers to increase engagement with your Kik Bot without additional engineering work.

We’ll show you how to get started collecting metrics in 4 easy steps:

Step 1: Get A Kik API Key

Add your Kik API Key and your Kik Bot’s username to botmetrics (don’t worry the API Key has been regenerated!)

Fetch your bot’s username and API Key and add them to BotmetricsFetch your bot’s username and API Key and add them to Botmetrics

Step 2: Update Your Bot's Webhook Handler

Add a line of code to your webhook handler and collect data

// Remember to run `npm install --save botmetrics` in your app.
//
// If you are using an Express-based app, parse the request body
// and pass along req.body as an argument to Botmetrics
// for example:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var Botmetrics = require('botmetrics');

app.use(bodyParser.json()); // for parsing application/json

app.post('/webhooks', function(req, res) {
  Botmetrics.track(req.body, {
    apiKey: process.env.BOTMETRICS_API_KEY,
    botId: process.env.BOTMETRICS_BOT_ID
  });
  
  res.status(200).send("ok");
});

app.listen(5000, function () {
  console.log('facebook bot listening on port 5000!');
});

Step 3: Track Conversations

When you are sending a response back to the user, make sure to send that payload to Botmetrics using the Botmetrics.track API as well.

request = require('request');

sendMessageToKik = function(kikBotUsername, kikApiKey, text) {
  var payload = {
    'messages': [
      {
        'body': 'bar', 
        'to': 'laura', 
        'type': text, 
        'chatId': 'b3be3bc15dbe59931666c06290abd944aaa769bb2ecaaf859bfb65678880afab'
      }
    ]
  };

  // Send to the User by making an HTTP POST request to https://api.kik.com/v1/messages with your Kik API Key
  request.post({
                 url: 'https://api.kik.com/v1/message',
                 headers: {
                   "Content-Type": "application/json"
                 }
               }).
          auth(kikBotUsername, kikApiKey);
  
  // ...and then send to Botmetrics
  Botmetrics.track(payload, {
    apiKey: process.env.BOTMETRICS_API_KEY,
    botId: process.env.BOTMETRICS_BOT_ID
  });
}

Step 4: Profit

You can now instantly see detailed metrics about your customers such as new and active user growth, demographic and geographic distributions, and user action attributes. With no additional engineering effort you will also have the ability to segment users based on these characteristics and send them targeted smart time-zone aware notifications.

Get Botmetrics for free and engage your customers like never before.