-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WorkflowStep can not save #982
Comments
Hi @Arxing - Are there any logs you can provide for what you see when the WorkflowStep.edit vs. .save is occurring? |
Hi @Arxing, I've checked your code and found that the following line of code can throw exceptions (actually the code as-is does not compile for me).
I've revised the part this way: it.value(stateValues["task_name_input"]?.get("task_name")?.value) Here is the complete code and its build settings: import com.slack.api.bolt.App
import com.slack.api.bolt.middleware.builtin.WorkflowStep
import com.slack.api.bolt.socket_mode.SocketModeApp
import com.slack.api.model.kotlin_extension.block.withBlocks
import com.slack.api.model.workflow.WorkflowSteps
fun main() {
System.setProperty("org.slf4j.simpleLogger.log.com.slack.api", "debug")
val app = App()
val step = WorkflowStep.builder()
.callbackId("socket-mode-step")
.edit { _, context ->
context.configure(withBlocks {
section {
blockId("intro-section")
plainText("text")
}
input {
blockId("task_name_input")
label("Task Name")
element {
plainTextInput {
actionId("task_name")
}
}
}
})
context.ack()
}
.save { req, context ->
val stateValues = req.payload.view.state.values
val inputs = buildMap {
// This part used to be failing
put("taskName", WorkflowSteps.stepInput {
it.value(stateValues["task_name_input"]?.get("task_name")?.value)
})
}
val outputs = buildList {
add(WorkflowSteps.stepOutput {
it.name("taskName").type("text").label("Task Name")
})
}
context.update(inputs, outputs)
context.ack()
}
.execute { _, context ->
context.ack()
}
.build()
app.step(step)
SocketModeApp(app).start()
} plugins {
id("org.jetbrains.kotlin.jvm") version "1.6.21"
id("application")
}
repositories {
mavenCentral()
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.slack.api:bolt-socket-mode:1.22.0")
implementation("com.slack.api:slack-api-model-kotlin-extension:1.22.0")
implementation("com.slack.api:slack-api-client-kotlin-extension:1.22.0")
implementation("javax.websocket:javax.websocket-api:1.1")
implementation("org.glassfish.tyrus.bundles:tyrus-standalone-client:1.17")
implementation('org.slf4j:slf4j-simple:1.7.36') // or logback-classic
}
application {
mainClassName = "MyAppKt" // add "Kt" suffix for main function source file
} I hope this helps. Can you close this issue if my response was helpful? |
sorry, fun ViewState.findElementOrNull(id: String): ViewState.Value? {
return values.flatMap { (_, stateTree) ->
stateTree.entries
}.find { (elementId, _) ->
elementId == id
}?.value
}
fun ViewState.findElement(id: String): ViewState.Value = findElementOrNull(id).notNull() It is expected to return the ViewState.Value of the specified element |
Here is the log that triggers Workflow.save after I add step in WorkflowBuilder and click "save"
it just shows me the error "Sorry, there was a problem trying to save your step." and the dialog doesn't close, but can see in the background that the step have been added, is this a slack WorkflowBuilder bug? Or am I missing some details? |
@Arxing I am still unsure about the cause of the issue that you are facing. Can you share your app's App Manifest (the YAML settings that you can find at https://api.slack.com/apps)? If your app does not enable Interactivity, the situation may arise. |
Here is my app's App Manifest, I replaced some sensitive information with "*". display_information:
name: *
description: *
background_color: "#0f3663"
features:
bot_user:
display_name: *
always_online: true
shortcuts:
- name: 刪除這則訊息
type: message
callback_id: deleteMessage
description: 刪除這則訊息
- name: Create a Schedule
type: global
callback_id: createSchedule
description: 快速建立一個 Automation Schedule
slash_commands:
- command: /query-top-fatal-issues
url: *
description: 查詢 Fatal Crashlytics
usage_hint: "平台 \b查詢天數 查詢筆數"
should_escape: false
- command: /query-top-non-fatal-issues
url: *
description: 查詢 Non-Fatal Crashlytics
usage_hint: "平台 \b查詢天數 查詢筆數"
should_escape: false
- command: /gen-appbot-token
url: *
description: 取得 App Bot Token
should_escape: false
- command: /appbot-set-role
url: *
description: 設定使用者的角色
should_escape: false
- command: /appbot-admin
url: *
description: 管理員功能
should_escape: false
- command: /appbot-automation
url: *
description: APP 自動化指令
should_escape: false
- command: /appbot-test
url: *
description: 測試用指令
should_escape: false
workflow_steps:
- name: 測試用 Step
callback_id: copy_review
oauth_config:
scopes:
user:
- chat:write
- channels:history
- reactions:read
- users:read
- users:read.email
- channels:write
- groups:write
- mpim:write
- im:write
bot:
- chat:write
- app_mentions:read
- chat:write.customize
- chat:write.public
- channels:read
- commands
- emoji:read
- groups:read
- incoming-webhook
- users.profile:read
- users:read
- users:read.email
- im:write
- groups:write
- mpim:write
- workflow.steps:execute
settings:
event_subscriptions:
request_url: *
bot_events:
- workflow_step_execute
interactivity:
is_enabled: true
request_url: *
org_deploy_enabled: false
socket_mode_enabled: false
token_rotation_enabled: false |
@Arxing Thanks for sharing the app's Manifest. The settings look great. Another possible cause would be a 3-second timeout. Your whole save function execution might take 3+ seconds for some reason. Can you modify your save method as below? .save { req, context ->
app.executorService().submit {
// Run the following code asynchronously
val stateValues = req.payload.view.state.values
val inputs = buildMap {
put("taskName", WorkflowSteps.stepInput {
it.value(stateValues["task_name_input"]?.get("task_name")?.value)
})
}
val outputs = buildList {
add(WorkflowSteps.stepOutput {
it.name("taskName").type("text").label("Task Name")
})
}
context.update(inputs, outputs)
}
// Immediately acknowledge the request
context.ack()
} The |
I know there's a 3-second timeout. I've tried calling |
@Arxing Thanks for your response. hmm, I don't have anything further to guess at this point. I would suggest trying my example and seeing if there is any difference. Here is my App Manifest: display_information:
name: workflow-step-socket-mode-app
features:
bot_user:
display_name: workflow-step-socket-mode-app
always_online: false
workflow_steps:
- name: socket-mode-step
callback_id: socket-mode-step
oauth_config:
scopes:
bot:
- workflow.steps:execute
settings:
event_subscriptions:
bot_events:
- workflow_step_execute
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false You can create a new app and then generate a new App-Level token with If your issue can arise only with a specific app and/or a workspace, please contact our customer support agents for further help by checking the Slack server-side activity data. You can submit inquiries either by |
Hi @seratch I'm happy to tell you that I solved my problem! the problem is because I used But I immediately encountered another problem, I successfully added the step I wrote in my workflow, but when I am in workflowStepSave or workflowStepExecute I will receive {
"token": "*",
"team_id": "*",
"api_app_id": "*",
"event": {
"type": "workflow_step_execute",
"callback_id": "triggerAction",
"workflow_step": {
"workflow_step_execute_id": "3569568604502.2193215711.7d10728bace18d43446a83d38ff5e584",
"workflow_id": "409291001966899534",
"workflow_instance_id": "409292316780540782",
"step_id": "fcef04d0-62e0-4c0d-b4c8-8bf064b42d96",
"inputs": {
"action": {
"value": "v-a"
}
},
"outputs": [
{
"name": "name-label",
"type": "text",
"label": "label"
}
]
},
"event_ts": "1653486831.627975"
},
"type": "event_callback",
"event_id": "Ev03HMU2N2QG",
"event_time": 1653486831,
"authorizations": [
{
"enterprise_id": null,
"team_id": "*",
"user_id": "*",
"is_bot": true,
"is_enterprise_install": false
}
],
"is_ext_shared_channel": false
} and that workflowStepExecute is not executed, I don't know where the problem is |
@Arxing You might miss the logs but I am sure that url_verification request was sent separately. Let me know if you have anything else that you need our help. Otherwise, we will close this issue in a few business days. |
Hi, I am bumping into a similar issue @Arxing pointed out in regards to ngrok and although I could work on a similar manner to deploy to a stage environment, curious to understand better as developing locally would boost productivity drastically.
Thanks |
I follow this document and tried adding WorkflowStep to my Slack bot, WorkflowStep.edit works fine, but WorkflowStep.save fails anyway, I can't find the reason, can you help me?
Reproducible in:
The Slack SDK version
Java Runtime version
OS info
The text was updated successfully, but these errors were encountered: