Git Product home page Git Product logo

Comments (13)

jescalan avatar jescalan commented on August 21, 2024 1

Yeah so that is what we are doing already with the im.open piece, and it's working ok, although its a bit ugly. It also requires an existing msg object, which is not ideal like you said. It definitely would be a lot better to have an independent method that wouldn't be coupled to or hacked on to an existing conversation. For example, what if I wanted to bot to message a user as soon as it is booted up?

Also in order to be able to add correctly to a queue, I assume there would need to be some extra logic here, making it even more compelling as a helper method.

from bolt-js.

selfcontained avatar selfcontained commented on August 21, 2024

Interesting, gonna think that through a bit.

In regards to having the bot message a different user, is it that you want the bot to @mention the user in the current channel, or send a dm, or in a new channel?

from bolt-js.

jescalan avatar jescalan commented on August 21, 2024

For my particular use case, it would be sending a DM. Some type of method like:

slapp.directMessageUser('U12HSK2', 'hello there!').route('foobar')

Would be really great. In this case, the second argument would be the same as can normally be passed to msg.say(), so while it's a string here, it could be an object if it has buttons, attachments, etc.

from bolt-js.

selfcontained avatar selfcontained commented on August 21, 2024

Gotcha, makes sense. I can see how it's awkward and error-prone trying to use the existing msg object to accomplish that. There is some context stored on the existing msg that would be needed to dm the new user (msg.meta.bot_token). This is what it would look like to do something like that w/ the raw client library:

// assuming someone says "bug U12HSK2" - would probably parse out @mention though
slapp.message(/bug (.+)/, (msg, userToBug) => {
  msg.say("you got it, I'll pester them now")

  var token = msg.meta.bot_token

  slapp.client.im.open({token, user: userToBug}, (err, data) => {
    if (err) {
      return console.error(err)
    }
    let channel = data.channel.id

    // it would be nice to have a new msg object w/ the channel default to the dm channel we acquired somehow
    msg.say({ channel: channel, text: 'Hi, just here to bug you!' })
  })
})

The issue there is mainly that we're re-using the same msg object, overriding the channel, and the way it is, route() won't work (it would be tied to the original user that messaged still). We've had a use case for taking a msg object and creating a new one from it w/ new context, i.e. a different user or channel (or both). This could be useful here too. Something like this, not sure on the name msg.copy though:

// assuming someone says "bug U12HSK2" - would probably parse out @mention though
slapp.message(/bug (.+)/, (msg, userToBug) => {
  msg.say("you got it, I'll pester them now")

  var token = msg.meta.bot_token

  slapp.client.im.open({token, user: userToBug}, (err, data) => {
    if (err) {
      return console.error(err)
    }
    let channel = data.channel.id

    // something like this to create a new msg scoped to the new user/channel (retains tokens and other metadata this way)
    msg.copy({ channel, user: userToBug })
      .say('Hey, just here to bug you!')
      .route('user-bugged')
  })
})

On the fence w/ wrapping the slapp.client.im.open() call with a helper, would be useful, but couples the library a bit more to a specific slack api (im.open), and adds more surface area to test/maintain.

from bolt-js.

selfcontained avatar selfcontained commented on August 21, 2024

Good point about opening up a message outside the context of receiving a message, definitely a use case we need to consider. The main challenge there is acquiring the tokens/meta-data on demand for the specific team of the user we want to message. Currently those are all provided via a request-enrichment model (on beep boop extracted from headers). It would be nice to have a generic way to grab team-specific meta-data in more of an ad-hoc fashion, and was agnostic to the persistence of those (similar to the current context lookup middleware). I could see it being an extension of the current context lookup middleware, or related.

from bolt-js.

jescalan avatar jescalan commented on August 21, 2024

I'm entirely less experienced in this field, but is it not possible to get the token from the slapp instance after it connects? Or perhaps on initialization it could be grabbed?

from bolt-js.

selfcontained avatar selfcontained commented on August 21, 2024

That approach would work if you were only concerned about a single slack team that your app has been added to, but you could potentially have many teams running your app.

from bolt-js.

jescalan avatar jescalan commented on August 21, 2024

Hmm so perhaps you could specify the team as a parameter to the method and it could get that team's token?

from bolt-js.

selfcontained avatar selfcontained commented on August 21, 2024

ya, something that generates a message object for you based on a team, and it would have the corresponding message.meta populated for you (with the tokens and all that other jazz you get via headers on beep boop currently).

from bolt-js.

mirekm avatar mirekm commented on August 21, 2024

I'm wondering if there's any progress on this feature. I'm working on a bot supplying a small stats message each day to some of our channels.

from bolt-js.

mirekm avatar mirekm commented on August 21, 2024

On the topic: is there currently any way to obtain the teams and bot tokens using BeepBoop platform? I want to implement a scheduled job per team sending a short message to one of the channels every morning.

from bolt-js.

mirekm avatar mirekm commented on August 21, 2024

For those interested in the topic this seems to be the answer (using Slack Teams or/with Chronos Scheduler): https://beepboophq.com/docs/api

from bolt-js.

seratch avatar seratch commented on August 21, 2024

I'm sorry to say, but the maintainers of this project (bolt-js) no longer support the slapp library. Please let us close this issue now.

from bolt-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.