Botkit: bot.startTyping Not Working in Slack

Created on 23 Nov 2016  Â·  17Comments  Â·  Source: howdyai/botkit

In a previous version this seemed to work fine but after updating to 0.4.2 calling bot.startTyping(message) no longer initiates the typing event in slack. Looking at logs I can see the message is being sent, but when I look at Slack nothing happens.

2016-11-23T00:36:54.258406+00:00 app[web.1]: debug: SAY { type: 'typing', channel: 'D0F9HXX' }
2016-11-23T00:36:54.261285+00:00 app[web.1]: debug: chat.postMessage { type: 'typing',
2016-11-23T00:36:54.261287+00:00 app[web.1]: channel: 'D0F9HXXXX',
2016-11-23T00:36:54.261289+00:00 app[web.1]: text: null,
2016-11-23T00:36:54.261289+00:00 app[web.1]: username: null,
2016-11-23T00:36:54.261290+00:00 app[web.1]: parse: null,
2016-11-23T00:36:54.261290+00:00 app[web.1]: link_names: null,
2016-11-23T00:36:54.261291+00:00 app[web.1]: attachments: null,
2016-11-23T00:36:54.261292+00:00 app[web.1]: unfurl_links: null,
2016-11-23T00:36:54.261292+00:00 app[web.1]: unfurl_media: null,
2016-11-23T00:36:54.261293+00:00 app[web.1]: icon_url: null,
2016-11-23T00:36:54.261294+00:00 app[web.1]: icon_emoji: null,
2016-11-23T00:36:54.261294+00:00 app[web.1]: as_user: true,
2016-11-23T00:36:54.261295+00:00 app[web.1]: token: 'xxx' }

Slack-related bug

Most helpful comment

As @agamrafaeli points out, the typing event is not supported by the chat.postMessage, which has recently become the default way of sending messages from Botkit.

It is only supported by the RTM.

You can tell botkit to prefer the RTM for sending messages, and thus re-enable typing indicators, by passing in {send_via_rtm: true} when you create your controller object:

var controller = Botkit.slackbot({send_via_rtm: true});

All 17 comments

Try the below:

controller.hears('aloha',['direct_message','direct_mention','mention'],function(bot,message) {

bot.replyWithTyping(message,'Hello yourself.');

});

I tried bot.replyWithTyping(message,'Hello yourself.') and even that is not showing an indication of typing in Slack. Also, replyWithTyping doesn't play nice with attachment style messages, which I am using.

I actually like the bot.startTyping because I make requests to other services after 'hearing' keywords and I want to indicate to the user that the bot is doing something while they wait for the request to be processed. It's not a huge deal but makes for a better experience IMO.

Hey Jonny, I am experiencing the same issue not seeing the "bot is now typing..." message.

@JonathanDn So you still haven't found any solutions since we spoke on Slack?

nope unfortunatley... :(

On Fri, Nov 25, 2016 at 3:12 PM, Alex Budin notifications@github.com
wrote:

@JonathanDn https://github.com/JonathanDn So you still haven't found
any solutions since we spoke on Slack?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/howdyai/botkit/issues/507#issuecomment-262954946, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ASyoCx3La5qVYQL02ODYAwQ4f0UAyXoRks5rBt7CgaJpZM4K6HRM
.

The official documenation as seen here (at time of posting, 26 Nov, 2016 21:50 UTC): https://api.slack.com/methods/chat.postMessage

there is no support for the type field on posting messages. startTyping uses this field. I also tried forcing as_user to be false and that didn't help, albeit some comments on the Slack documentation regarding the importance of as_user for this case.

I also commented on similar issue on the official node-slack-sdk: https://github.com/slackapi/node-slack-sdk/issues/98

Maybe Slack deprecated "Is typing..." for bots?

@agamrafaeli is right. I've just tested bot.startTyping and slack is not taking this any more. So may be there is another workaround.

user_tying is listed under https://api.slack.com/events/user_typing just saw today.

Not working for me too, I even tried sending {type: 'typing', as_user: true}.

As @agamrafaeli points out, the typing event is not supported by the chat.postMessage, which has recently become the default way of sending messages from Botkit.

It is only supported by the RTM.

You can tell botkit to prefer the RTM for sending messages, and thus re-enable typing indicators, by passing in {send_via_rtm: true} when you create your controller object:

var controller = Botkit.slackbot({send_via_rtm: true});

@benbrown I did try your suggestion to have the bot use RTM but I am still not getting any 'istyping' indicators in Slack. Is there anything else that needs to be done?

My controller:
var controller = Botkit.slackbot({ send_via_rtm: true // debug: false, // logLevel: 7 });

On a side note Slack does compare events to RTM and says to use RTM for presence indications like 'istyping' https://api.slack.com/faq#events_api

EDIT: In v0.4.3 the docs specify passing send_via_rtm: true into controller.spawn({}) not the controller object itself as I suggest below. Without any changes you can get typing indicators to work in v0.4.3 by passing it as above.

@benbrown @JonnyBoy333 I was able to get this working, I think it just wasn't working since v0.4.2
It seems that Slackbot_worker is looking for bot.config.send_via_rtm which its not finding in bot.config. So messages were being sent via chat.postMessage, and never reaching the rtm.send

However, botkit.config.send_via_rtm does exist once you've passed it into the controller. I changed the logic to look there and we've got typing indicators back.

img_6563

Not exactly sure what to propose to fix this. Either point to botkit.config.send_via_rtm or add it to bot.config. Are controller configuration variables supposed to be present in bot.config? @benbrown?

Submitted #533 to send typing indication messages via rtm, and fix send_via_rtm

Great fix @jonchurch

@jonchurch that's great fix. But, i will wait for its official updated version to its botkit to use than manually adjust its configuration. :)

Currently in v0.4.3 send_via_rtm is expected to be passed into controller.spawn({ send_via_rtm: true }) instead of the controller object. docs

Which is why your code snippet @JonnyBoy333 would not work.

When working with slack apps (which I think most people are) how to spawn a bot with these options passed in is not very apparent. I think some people are passing them into their controller object or the configureSlackApp({}) function and not reconnecting as a result.

Thanks @jonchurch, adding send_via_rtm to the bot spawn did work and now I have 'Is Typing' functionality again. Hopefully they integrate this into the events api in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HannanShaik picture HannanShaik  Â·  3Comments

TheJimFactor picture TheJimFactor  Â·  4Comments

abinashmohanty picture abinashmohanty  Â·  4Comments

abinashmohanty picture abinashmohanty  Â·  4Comments

GautierT picture GautierT  Â·  3Comments