Kik is a messaging app for connecting users. Analyzing message content and user interactions can inform content strategies and user engagement approaches.
Welcome to the Kik documentation for Dimension! Integrating Dimension into your Kik 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 Dimension via NPM
npm install --save dimensionlabs
Include Dimension
Use the API key created above.
const dimension = require('dimension')(process.env.DIMENSION_API_KEY).kik;
Configure Dimension handler and add to Kik Bot
Pass the bot handle created with the Kik npm module to Dimension.
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();
dimension.configHandler(bot);
bot.use(dimension.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 Dimension via NPM
npm install --save dimensionlabs
Include Dimension
Use the API key created above.
const dimension = require('dimension')(process.env.DIMENSION_API_KEY).kik;
Log all incoming messages
Send the full message to Dimension.
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
dimension.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 Dimension.
Example Message
{
"type": "text",
"body": "My Test Message",
"to": "someuser",
"chatId": "123456789"
}
Send Message
dimension.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_USERNAME
is 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.dimensionlabs.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.dimensionlabs.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.dimensionlabs.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.dimensionlabs.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.