Docs
Official Tools
Function Tools
Slack

Slack

The Slack Tool facilitates communication with Slack channels by providing features that allow you to send or fetch messages.

Please note that the Slack Tool is designed as a supplementary tool for an exisiting chatbot and does not actively listen for new messages. For effective operation, the app requires explicit identification of the target user_id, channel_id, and/or thread_id within your instructions.

Setup

Get Slack Access Token

Follow this guide to create a Slack app and grab your access token: https://api.slack.com/tutorials/tracks/getting-a-token (opens in a new tab)

Authorization

npi auth slack --access-token <slack-access-token>

Usage

npi app slack "Get the last 10 messages from the channel with ID {{channel_id}}"

Supported Features

Direct Messaging

  • Description: Engage in one-on-one conversations by sending direct messages to a user. A new direct message channel will be created if necessary.
  • In-Context Parameters1:
    • Recipient's user ID.
    • Content of the message.

Examples

  1. Send a Greeting Message to a User

    npi app slack "Send a greeting message to XXX (user id: {{user_id}})."
  2. Ask for User Confirmation and Await Their Reply

    npi app slack "Send a direct message to XXX (user id: {{user_id}}) asking them to confirm next Monday's meeting, and wait for their reply."

Message Dispatch

  • Description: Post messages to a specified Slack channel.
  • In-Context Parameters:
    • Target channel ID.
    • Content of the message.

Examples

  1. Broadcast a Message to a Specific Channel

    npi app slack "Send a greeting message to the channel with ID {{channel_id}}."

Message Retrieval

  • Description: Fetch historic messages from a specified Slack channel.
  • In-Context Parameters:
    • Channel ID where the messages are located.
    • (Optional) Maximum number of messages to retrieve.

Examples

  1. Fetch Messages from a Channel

    npi app slack "Get the last 10 messages from the channel with ID {{channel_id}}."

Message Response

  • Description: Reply to an existing message within a Slack channel.
  • In-Context Parameters:
    • The channel ID of the message to respond to.
    • Description to identify the message for a reply. The app will search and match the message according to your input.
    • (Optional, Inferred) Content of the reply message.

Examples

  1. Reply to a Message in a Channel

    npi app slack "Reply to the latest message in the channel with ID {{channel_id}}. You can write anything you like."
Didn't find the feature you were looking for? Feel free to submit an issue or PR!

Footnotes

Footnotes

  1. In-Context Parameters refer to the special information that you may specify in the instructions. Parameters marked as Inferred could be deduced from the context without needing explicit mention.