Can Hubot Slack bot store sessions


I am trying to implement simple slack bot. So I have configured hubot which will take inputs from slack and passing it to my webapp (django app) and it will take whatever the response from django-app and will reply to slack.

In this process I am trying to store session in django using request.session but that is not reflected in slack. If I am accessing the django-url in browser it is able to store sessions and getting proper response with session.

So does the problem lie with slack or my approach and is there a way to store sessions in hubot when requesting to django-app ??


I can not speak to the specific technologies you use (hubot, django), but I am using server sessions with my Slack apps all the time and can give you a general answer on how it works. Note that my Slack apps are build with PHP, but I think its safe to assume that the principles are the same.

<strong>Slack does not support sessions</strong>

In general Slack does not support sessions or context. Instead everything is request based. So if you want to have sessions to keep a functional context between requests you need to organize that by yourself in your Slack app.

<strong>Challenge for using server sessions with server requests</strong>

One challenge is that most server sessions are designed to work with a client that uses a browser. e.g. a PHP server session will store a cookie in the browser, so the server knows, which requests belong to the same session. This does obviously not work with Slack, since all Slack requests are coming from a server and and there is no browser involved.

<strong>Approach for using server sessions with Slack</strong>

But you can use severs session with Slack with these two tricks:

<em>Manually set the session ID</em>

Usually the ID of a session is chosen automatically by the server, but you can also set it manually. This allows you to tell the server to continue an existing session that was started with a previous request.

<em>Include session ID in Slack control</em>

The functional session of a user is tied together by the Slack controls he uses. (e.g. an interactive button). Its possible to include custom data in those controls (see <a href="https://stackoverflow.com/a/45971885/4379151" rel="nofollow">this answer</a> for details) and that allows you to include the current session ID in it.

<em>Full approach</em>

You include the ID of your current session in the Slack controls, that you create with your app (e.g. an interactive button). Once the user clicks a button Slack will send a request to your app, which will include the session ID. That allows your app to continue an already started server session.


  • Post image to slack using httr package in R
  • Cannot delete a chat message via Slack API
  • number range in a regex
  • Newbie question about maven
  • Designing a simple bandpass/bandstop filter in Matlab
  • border-image-outset in CSS
  • Large items in the notification area (AKA system tray)?
  • “stacking” arrays in a new dimension?
  • Determine name of a JavaScript object instance's class
  • HDFS resiliency to machine restarts in DC/OS
  • Replacing accents w/ their counterparts in AS3
  • Are there any fluent WPF projects? [closed]
  • Rewrite part of javascript with C#
  • How to blur the specific part of image without using Render Script,as my minsdk is 14.
  • GRPC and types import error in App Engine Datastore
  • How to use SBT with multiple sub project web applications?
  • C# 4 and CLR Compatibility
  • Zend Framework bassed projects
  • Installing PHP 7 on digitalocean
  • Create DicomImage from scratch using Dcmtk
  • Android activity accessing service's static reference before the service is ready
  • How to do unit test for HttpContext.Current.Server.MapPath
  • Resize panoramic image to fixed size
  • Volusion's generic SQL folder, functionality
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Running a C# exe file
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • ORA-29908: missing primary invocation for ancillary operator
  • Matrix multiplication with MKL
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • How do you join a server to an Active Directory (domain)?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • coudnt use logback because of log4j
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How does Linux kernel interrupt the application?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Converting MP3 duration time