slack

package
v0.27.3-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 11 Imported by: 0

README

---
title: "Slack"
lang: "en-US"
draft: false
description: "Learn about how to set up a VDP Slack component https://github.com/instill-ai/instill-core"
---

The Slack component is an application component that allows users to get and send message on Slack.
It can carry out the following tasks:

- [Read Message](#read-message)
- [Send Message](#send-message)



## Release Stage

`Alpha`



## Configuration

The component configuration is defined and maintained [here](https://github.com/instill-ai/component/blob/main/application/slack/v0/config/definition.json).




## Setup




In order to communicate with Slack, the following connection details need to be
provided. You may specify them directly in a pipeline recipe as key-value pairs
withing the component's `setup` block, or you can create a **Connection** from
the [**Integration Settings**](https://www.instill.tech/docs/vdp/integration)
page and reference the whole `setup` as `setup:
${connection.<my-connection-id>}`.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
| Token (required) | `token` | string | Fill in your Slack app access token. For more information about how to access to create app tokens, please refer to the Slack API documentation. |




## Supported Tasks

### Read Message

Get the latest message since specific date


| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_READ_MESSAGE` |
| Channel Name (required) | `channel-name` | string | A channel name display in Slack |
| Start to read date | `start-to-read-date` | string | earliest date in all read messages |



| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Conversations | `conversations` | array[object] | An array of conversations with thread messages |






### Send Message

send message to a specific channel


| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_WRITE_MESSAGE` |
| Channel Name (required) | `channel-name` | string | A channel name display in Slack |
| Message (required) | `message` | string | message to be sent to the target channel |



| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Result | `result` | string | result for sending message |







Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(bc base.Component) *component

Init returns an implementation of IConnector that interacts with Slack.

Types

type Conversation

type Conversation struct {
	UserID             string               `json:"user-id"`
	UserName           string               `json:"user-name"`
	Message            string               `json:"message"`
	StartDate          string               `json:"start-date"`
	LastDate           string               `json:"last-date"`
	TS                 string               `json:"ts"`
	ReplyCount         int                  `json:"reply-count"`
	ThreadReplyMessage []ThreadReplyMessage `json:"thread-reply-messages"`
}

type ReadTaskResp

type ReadTaskResp struct {
	Conversations []Conversation `json:"conversations"`
}

type SlackClient

type SlackClient interface {
	GetConversations(params *slack.GetConversationsParameters) ([]slack.Channel, string, error)
	PostMessage(channelID string, options ...slack.MsgOption) (string, string, error)
	GetConversationHistory(params *slack.GetConversationHistoryParameters) (*slack.GetConversationHistoryResponse, error)
	GetConversationReplies(params *slack.GetConversationRepliesParameters) ([]slack.Message, bool, string, error)
	GetUsersInfo(users ...string) (*[]slack.User, error)
}

type ThreadReplyMessage

type ThreadReplyMessage struct {
	UserID   string `json:"user-id"`
	UserName string `json:"user-name"`
	DateTime string `json:"datetime"`
	Message  string `json:"message"`
}

type UserInputReadTask

type UserInputReadTask struct {
	ChannelName     string `json:"channel-name"`
	StartToReadDate string `json:"start-to-read-date"`
}

type UserInputWriteTask

type UserInputWriteTask struct {
	ChannelName string `json:"channel-name"`
	Message     string `json:"message"`
}

type WriteTaskResp

type WriteTaskResp struct {
	Result string `json:"result"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL