Dashbot

Kik Documentation

Kik Documentation

Welcome to the Facebook documentation for Dashbot! Integrating Dashbot into your Facebook chatbot is quick and easy.

If you have any questions, comments, or suggestions, please feel free to contact us.

Kik Integration with Kik NPM

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Install Dashbot via NPM

npm install --save dashbot

Include Dashbot

Use the API key created above.

const dashbot = require('dashbot')(process.env.DASHBOT_API_KEY).kik;

Configure Dashbot handler and add to Kik Bot

Pass the bot handle created with the Kik npm module to Dashbot.

const Bot = require('@kikinteractive/kik');
const bot = new Bot({
username: process.env.KIK_USERNAME,
apiKey: process.env.KIK_API_KEY,
baseUrl: process.env.KIK_WEBHOOK_URL
});
bot.updateBotConfiguration();
dashbot.configHandler(bot);
bot.use(dashbot.logHandler);

Example

View sample code for a Kik Bot.



Kik Integration without Kik NPM

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Install Dashbot via NPM

npm install --save dashbot

Include Dashbot

Use the API key created above.

const dashbot = require('dashbot')(process.env.DASHBOT_API_KEY).kik;

Log all incoming messages

Send the full message to Dashbot.

Example Message

{
"type": "text",
"body": "pat me",
"from": "someuser",
"timestamp": 1470024587572,"<br></br>" "mention": null,
"participants": [
"someuser"
],
"readReceiptRequested": true,
"id": "987654321",
"chatId": "123456789"
}

Send Message

dashbot.logIncoming(process.env.KIK_API_KEY, process.env.KIK_USERNAME, message)

Where process.env.KIK_API_KEY is the API_KEY from Kik and process.env.KIK_USERNAME is the username for the bot from Kik, assuming you have a KIK_API_KEY and KIK_USERNAME environment variables.

Log all outgoing messages

Send the full message to Dashbot.

Example Message

{
"type": "text",
"body": "My Test Message",
"to": "someuser",
"chatId": "123456789"
}

Send Message

dashbot.logOutgoing(process.env.KIK_API_KEY, process.env.KIK_USERNAME, message)

Where process.env.KIK_API_KEY is the API_KEY from Kik and process.env.KIK_USERNAMEis the username for the bot from Kik, assuming you have a KIK_API_KEY and KIK_USERNAME environment variables.



Kik Integration with REST API

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Integrate the REST API

There are two integration points as outlined below.

1. When Kik posts to your webhook endpoint

When Kik posts to your webhook endpoint, post the same data Kik sent to you to the following endpoint:

https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
"apiKey": "<KIK_API_KEY>",
"username": "<KIK_USERNAME>",
"message": {
"type": "text",
"body": "Hello there!",
"from": "someuser",
"timestamp": 1610472907168,
"mention": null,
"participants": [
"someuser"
],
"readReceiptRequested": true,
"id": "987654321",
"chatId": "123456789"
}
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
-d '{"apiKey":"<KIK_API_KEY>","username":"<KIK_USERNAME>","message":{"type":"text","body":"Hello there!","from":"someuser","timestamp":<span class="doctimestamp"></span><script>[].forEach.call(document.getElementsByClassName("doctimestamp"), function(el) { el.innerHTML=Date.now()});</script>,"mention":null,"participants":["someuser"],"readReceiptRequested":true,"id":"987654321","chatId":"123456789"}}'
'https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.

Note
This is just an example — we accept any rich media that Kik accepts.

The KIK_API_KEY is the api key from Kik and KIK_USERNAME is the username for the bot from Kik.

2. When your bot sends a message to the Kik endpoint

When your bot sends a message, POST to the following endpoint:

https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
"apiKey": "<KIK_API_KEY>",
"username": "<KIK_USERNAME>",
"message": {
"type": "text",
"body": "Some sample text",
"to": "someuser",
"chatId": "123456789"
}
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
-d '{"apiKey":"<KIK_API_KEY>","username":"<KIK_USERNAME>","message":{"type":"text","body":"Some sample text","to":"someuser","chatId":"123456789"}}'
'https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.

Note
This is just an example — we accept any rich media that Kik accepts.

The KIK_API_KEY is the api key from Kik and KIK_USERNAME is the username for the bot from Kik.



Advanced Usage

Tracking Events in a Conversation

Events

You may wish to track certain events in conversations, such as:

  • External URL Clicks
  • Social Shares
  • Revenue
  • Anything else…

JSON Format

The JSON that you can send to track an event is:

  • name – string (required)
  • userId – string (required)
  • conversationId – string (optional)
  • type – enum (required)
    • customEvent
    • revenueEvent
    • shareEvent
    • pageLaunchEvent

For each event type, you can pass additional properties:
customEvent

  • extraInfo – object (optional)

revenueEvent

  • amount – number (required)
  • referenceNumber – string (optional)
  • metadata – object (optional)

pageLaunchEvent

  • extraInfo – object (optional)

shareEvent

  • sharedMessage – object (optional)

referralEvent

  • name – string (required)
  • ref – string the referral tag (optional)
  • source – string the referral source (eg. ADS, WEB) (optional)
  • ad_id – string an ID to identify the ad (optional)
  • referer_uri – string the URI that sent the referer(optional)

Tracking Custom Events

Post to the endpoint

https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
"name": "trackMeEvent",
"type": "customEvent",
"userId": "967295313370594",
"extraInfo": {
"start": 1500504070512,
"difference": 374,
"end": 1500504070886
}
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
-d '{"name":"trackMeEvent","type":"customEvent","userId":"967295313370594","extraInfo":{"start":1500504070512,"difference":374,"end":1500504070886}}'
'https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.

Tracking Revenue Events

Post to the endpoint

https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
"name": "boughtSandwich",
"type": "revenueEvent",
"userId": "967295313370594",
"amount": 17.45,
"metadata": {
"productName": "Ham Sandwich",
"sku": "abc123123"
}
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
-d '{"name":"boughtSandwich","type":"revenueEvent","userId":"967295313370594","amount":17.45,"metadata":{"productName":"Ham Sandwich","sku":"abc123123"}}'
'https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.

Tracking Page Launch Events

Post to the endpoint

https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
"name": "Launched Detail Page",
"type": "pageLaunchEvent",
"userId": "967295313370594",
"extraInfo": {
"url": "https://www.dashbot.io/"
}
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
-d '{"name":"Launched Detail Page","type":"pageLaunchEvent","userId":"967295313370594","extraInfo":{"url":"https://www.dashbot.io/"}}'
'https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.

Tracking Share Events

Post to the endpoint

https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
"name": "sharedLink",
"type": "shareEvent",
"userId": "967295313370594",
"sharedMessage": {
"text": "come check out this bot"
}
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
-d '{"name":"sharedLink","type":"shareEvent","userId":"967295313370594","sharedMessage":{"text":"come check out this bot"}}'
'https://tracker.dashbot.io/track?platform=kik&v=11.1.0-rest&type=event&apiKey=API_KEY_HERE'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.

Edit this page on GitHub