Skip to content
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

[QUERY] When Triggered Via Message Shortcut, Possible To Access Message Text, Send to External API, Then OpenForm (or views.open?) #321

Open
jpaulgale opened this issue May 16, 2024 · 1 comment
Labels
question Further information is requested

Comments

@jpaulgale
Copy link

jpaulgale commented May 16, 2024

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

@zimeg zimeg added the question Further information is requested label May 21, 2024
@zimeg
Copy link
Member

zimeg commented May 21, 2024

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:

  1. Start a workflow with a "reaction added" event trigger
  2. Add a custom function as the first step:
    a. As input, take the message_ts and channel_id from the event trigger
    b. Gather message contents using conversations.history with inclusive: true, limit: 1, latest: message_ts, and channel: channel_id
    c. Ask the LLM to perform the needed magic
    d. As output, return the task_name and due_date
  3. 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.
  4. Use the "open form" step with the fields you want, defaults from step 2, and interactivity from step 3!
  5. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants