Closed imdgr886 closed 4 months ago
We can update the trigger's Channel Ids at runtime programmatically using the below method. https://api.slack.com/automation/triggers/manage#update_runtime
We can update the trigger's Channel Ids at runtime programmatically using the below method. https://api.slack.com/automation/triggers/manage#update_runtime
but I still have a question, how do the bot knows it was invited into a channel. I see other sdk can receive event for bot_join
. But I can't find any event for deno sdk.
Does it mean I mush execute a shotcut command first for get channel id?
Thank you!
yes. i was also facing the same situation . i wrote a shortcut command like AllowBot which captures the ChannelId and dynamically updates the AppMentioned Trigger using the above method.
Indeed, the channel_id
property on many event triggers is required today. However, the team will be working on dropping this requirement in the future. We have no timeline at this moment on when that will be.
In the meantime, dynamically updating a trigger is one workaround, as @pranith12345 mentions. The general pattern of having a shortcut trigger trip a workflow that configures a second workflow that does the work you are trying to accomplish is a common one that we have seen emerge to address this general issue. I have turned to calling this the 'configurator' pattern. I am not a big fan of it but it does get the job done. Hopefully in the near future we can make changes to the platform to remove the need for this pattern.
Indeed, the
channel_id
property on many event triggers is required today. However, the team will be working on dropping this requirement in the future. We have no timeline at this moment on when that will be.In the meantime, dynamically updating a trigger is one workaround, as @pranith12345 mentions. The general pattern of having a shortcut trigger trip a workflow that configures a second workflow that does the work you are trying to accomplish is a common one that we have seen emerge to address this general issue. I have turned to calling this the 'configurator' pattern. I am not a big fan of it but it does get the job done. Hopefully in the near future we can make changes to the platform to remove the need for this pattern.
yes shortcut
is a good solution to update get the channel_id
dynamically. But this deno sdk supports much less events than classical sdk. I want to send a tutorial after the bot was been invited into a channel so my user will get start easier.
it seems can implement by this sdk
It's true, the new automation platform supports less events at this time compared to the old platform. There are many security and permission considerations related to tokens, workflows and an entire new persona (the builder persona: the person that builds workflows in Workflow Builder, possibly using functions from other third party apps) that need careful review and refactor, all the while maintaining backwards compatibility for the existing platform.
We will be working to improve that, but it will take time. In the mean time, I will certainly forward this feedback to our team so that we can weigh it when prioritizing work.
An update on this issue: we will be rolling out support for a all_resources: true / false
property that can be used instead of channel_ids
for the events that have to-date required channel_ids
. Support for this should already be live in production, and I am working on exposing this ability for Trigger
definitions using this SDK.
This is now out in deno-slack-sdk 2.10 and deno-slack-api 2.4!
@filmaj thanks for this update! I was able to add it my slack app, but the bot seems to still only work in the channels whose ID I had specified earlier on and invited. Is there anything else I need to do aside from adding all_resources: true
to the event definition?
const trigger: Trigger<typeof workflow.definition> = {
type: TriggerTypes.Event,
name: "Trigger the app mention workflow",
workflow: `#/workflows/${workflow.definition.callback_id}`,
event: {
event_type: TriggerEventTypes.AppMentioned,
// channel_ids: ["old_channel_id"],
all_resources: true,
},
inputs: {
channel_id: { value: TriggerContextData.Event.AppMentioned.channel_id },
user_id: { value: TriggerContextData.Event.AppMentioned.user_id },
message_ts: { value: TriggerContextData.Event.AppMentioned.message_ts },
text: { value: TriggerContextData.Event.AppMentioned.text },
},
};
@wnamen for the app mentioned event, your app has to already be a member of the channel to get notified of the event - even if you set all_resources: true
. Can you try testing the scenario where both:
channel_ids
, and@filmaj thanks for your quick response. Yep that all makes sense! I tried the following scenarios:
all_resources
change) + existing member of channel + was a previously hard coded channel_id
-> works!all_resources
change) + existing member of channel + was not previously hard coded channel_id
-> does not work :(all_resources
change) + invited to new channel + was not previously hard coded channel_id
-> does not work :(Here's a screenshot of 3. The bot should respond with a message. I checked the slack activity logs and I didn't see any event.
Going to re-open this issue and investigate. A couple of requests:
all_resources
, or creating a new one?The above is mostly so that I can try to reproduce the problem. Appreciate your patience and assistance in providing this info 🙇
@filmaj false alarm! Your second bullet reminded me that our team had not run the slack trigger update
command. After doing so and re-deploying, it works as expected.
For what it's worth, we definitely expected the slack deploy
command to act as a rebuild of the trigger definitions. Sorry for dragging you into this rabbit hole.
@wnamen no worries, I'm happy to hear it is working for you. And totally hear you re: management of triggers; having triggers live in their own kind of 'lifecycle', with separate create/update commands in certain cases, creates an experience where I think it's easy to forget updating the trigger definition. For example, when deploying or running an app, and the CLI detects that your app has no triggers created and there are trigger definitions available in your project, it will ask if you want to create a trigger. While this is a nice first-run experience, the CLI doesn't provide this kind of experience once triggers are defined for the app - which I think naturally leads to the situation you found yourself in!
I wonder what more we could do here to prevent this from happening 🤔
In any case, I will close this issue, but if you have further questions or problems feel free to re-open or file a new issue.
@filmaj these are great thoughts. I think in the meantime, we will expand our CI/CD scripts to detect when a commit contains a trigger/workflow def change and throw an error/warning reminder. It's a simple solution while y'all continue to explore improvements for the slack cli.
Question
When I follow the tutorials to create a event trigger, I don't know how to set the event propoty.