user2278469
user2278469

Reputation: 23

bot configuration on kik is not working as expected

I am trying to create an echo bot on kik. I have followed dev.kik.com, created a bot but then when i am trying to configure the bot, it does nothing(no message on kik or my middleware).

set up: 1. I have echo bot implemented using nodejs and hosted on azure. I have tested with AdvanceREST and i know that if the message is received correctly, it does respond back. 2. I have tried sending my bot configuration as below via nodejs request module.

request.post({
    url : 'https://api.kik.com/v1/config',
    auth: {
            'user' : 'botname',
            'pass' : 'botkey'
        }, 
    headers:{
        'Content-Type': 'application/json'
    },
    form :JSON.stringify({
        "webhook": "https://myurl",
        "features": {
           "manuallySendReadReceipts": false,
           "receiveReadReceipts": false,
           "receiveDeliveryReceipts": false,
           "receiveIsTyping": false
        }
    }) 
}, function(err,httpResponse,body){
        if(err){
            res.send(err);
        }
        if(httpResponse.statusCode === 200){
            res.send(JSON.parse(body));    
        }

    });

any help in this regard is greatly appreciated... thanks

Upvotes: 1

Views: 1240

Answers (2)

quikst3r
quikst3r

Reputation: 1853

request.post({
    url : 'https://api.kik.com/v1/config',
    auth: {
            'user' : 'botname',
            'pass' : 'botkey'
        }, 
    headers:{
        'Content-Type': 'application/json'
    },
    json: true,
    body :{
        "webhook": "https://myurl.com/incoming",
        "features": {
           "manuallySendReadReceipts": false,
           "receiveReadReceipts": false,
           "receiveDeliveryReceipts": false,
           "receiveIsTyping": false
        }
    }
}, function(err,httpResponse,body){
    if(err){
        res.send(err);
    }
    if(httpResponse.statusCode === 200){
        res.send(JSON.parse(body));    
    }
});

This should work a) ensure your url is valid, I know you just had a placeholder there but b) Use json:true and the key body it will work

You could also checkout kik's node library https://www.npmjs.com/package/@kikinteractive/kik which can set a config easily

Upvotes: 1

Joe Capka
Joe Capka

Reputation: 562

The config api is very picky. I managed to get it to work by using the following POST request, I used Postman. The key was to send an empty object as the features value:

POST /v1/config HTTP/1.1
Host: api.kik.com
Content-Type: application/json
Authorization: Basic --------- my auth token -----------------
Cache-Control: no-cache
Postman-Token: 217953a0-64da-556e-6817-5309bf4b92e8

{ 
    "webhook": "https://kwcraftbeer.azurewebsites.net/incoming",
    "features": {}

}

Upvotes: 0

Related Questions