[QUERY] When Triggered Via Message Shortcut, Possible To Access Message Text, Send to External API, Then OpenForm (or views.open?)
jpaulgale opened this issue · 1 comments
Question
Upon message shortcut being triggered in a message, I am looking to
- take message text
- send message text to an LLM with tool function to extract task_name + due_date
- use OpenForm (or views.open?) with pre-filled task_name + due_date fields
I can't seem to figure out how to
A) access the message text in the workflow.ts
B) send to the LLM prior to the OpenForm step
- if I need to jerry rig something where I give user a non-essential modal ask user to confirm they want the task sent, prior to sending the message text to LLM, that is workable
Thank you for your time!
Context
Documentation on slack.com is confusing to me inre: what is for Bolt vs what is for deno-slack-sdk.
I've created the app, gotten it to successfully send placeholder text (and text from OpenForm if I use that as the first step) to openai, but I cannot seem to access the message text or understand how to include a step prior to OpenForm, which is leading me to think views.open is the way, as per the below documentation:
https://api.slack.com/automation/forms
https://api.slack.com/automation/interactive-messages
https://api.slack.com/automation/interactive-modals#open-block-kit-action
Environment
cat import_map.json | grep deno-slack "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.11.0/", "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.4.0/",
deno --version deno 1.43.3 (release, aarch64-apple-darwin) v8 12.4.254.13 typescript 5.4.5
sw_vers && uname -v ProductName: macOS ProductVersion: 14.4.1 BuildVersion: 23E224 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030
Hey @jpaulgale! 👋 Super interesting use case and this seems possible using a custom function and the built-in open form function!
I'd recommend the following flow with a few more workflow-related features if that's alright. It'll still requires an extra step before opening a modal, but after an LLM response is received:
- Start a workflow with a "reaction added" event trigger
- Add a custom function as the first step:
a. As input, take themessage_ts
andchannel_id
from the event trigger
b. Gather message contents usingconversations.history
withinclusive: true
,limit: 1
,latest: message_ts
, andchannel: channel_id
c. Ask the LLM to perform the needed magic
d. As output, return thetask_name
anddue_date
- Send a message with interactive buttons using the built-in "send a message" step to prompt someone to fill out a form. I believe this works in thread or for ephemeral messages too, and is needed for the
interactivity
returned as an output. - Use the "open form" step with the fields you want, defaults from step 2, and
interactivity
from step 3! - Continue the workflow however you'd like!
This is suggested with more automation features in mind as the Deno SDK supports this well, but the same can be accomplished with other means of gathering message text and opening modals if that's preferred. Please let me know if this works for you or if you have other questions!