Skip to content
This repository has been archived by the owner on Nov 26, 2019. It is now read-only.

Channel Kik

Floren Henri edited this page Nov 18, 2016 · 10 revisions

Set up your Kik account

  • Log into Kik on your phone
  • Follow the steps on the Kik app to create your account
  • Go on this page https://dev.kik.com/#/home to find the code you need to scan to have access to your bot
  • Go to "Setting" > "Your Kik code" on your phone and use the picture icon to scan the code of your browser.
  • Go on the Configuration page and copy your API Key

alt text

Start your bot in local

Ngrok

  • Download the appropriate version of Ngrok on your computer
  • Open a new tab in your terminal:
./ngrok http 8080
  • Copy and paste the https://*******ngrok.io you get, you will need it for the next step
  • Leave your Ngrok serveur running

Start Connector in local

  • Clone and install Connector
$ git clone https://github.com/RecastAI/bot-connector.git
$ cd bot-connector
$ yarn install
$ yarn start-dev
  • Create your bot
$ curl -X POST "http://localhost:8080/bots/" --data "url=YOUR_NGROK_URL"
  • Create your channel
$ curl -X  POST \
  --data "slug=YOUR_BOT_SLUG" --data "isActivated=true" --data "type=kik" \
  --data "apiKey=YOUR_API_KEY" --data "webhook=YOUR_NGROK_URL" --data "userName=YOUR_BOT_NAME" \
  "http://localhost:8080/bots/:bot_id/channels"

Your bot

A small example of bot:

 import express from 'express'
 import bodyParser from 'body-parser'
 import request from 'superagent'
 
 const app = express()
 app.set('port', process.env.PORT || 5000)
 app.use(bodyParser.json())
 
 const config = { url: 'http://localhost:8080', botId ='yourBotId' }
 
   /* Get the request from the connector */
 
   app.post('/', (req, res) => {
     const conversationId = req.body.message.conversation
       const message = [{
         type: 'text',
         content: 'my first message',
       }]
 
     /* Send the message back to the connector */
     request.post(`${config.url}/bots/${config.botId}/conversations/${conversationId}/messages`)
       .send({ messages, senderId: req.body.senderId })
       .end((err, res) => {
         if (err) {
           console.log(err)
         } else {
           console.log(res)
         }
       })
   })
 
 app.listen(app.get('port'), () => {
   console.log('Our bot is running on port', app.get('port'))
 })
Clone this wiki locally