-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { SlackAPI } from 'deno-slack-api/mod.ts'; | ||
import { DefineFunction, Schema, SlackFunction } from 'deno-slack-sdk/mod.ts'; | ||
|
||
/** | ||
* Functions are reusable building blocks of automation that accept | ||
* inputs, perform calculations, and provide outputs. Functions can | ||
* be used independently or as steps in workflows. | ||
* https://api.slack.com/future/functions/custom | ||
*/ | ||
export const EndGameFunctionDefinition = DefineFunction({ | ||
callback_id: 'end_game_function', | ||
title: 'End Game', | ||
description: 'Ends the game and tallies the results', | ||
source_file: 'functions/end_game_function.ts', | ||
input_parameters: { | ||
properties: { | ||
channel_id: { | ||
type: Schema.slack.types.channel_id, | ||
}, | ||
}, | ||
}, | ||
output_parameters: { | ||
properties: { | ||
message: { | ||
type: Schema.types.string, | ||
description: 'Greeting for the recipient', | ||
}, | ||
}, | ||
required: ['message'], | ||
}, | ||
}); | ||
|
||
export default SlackFunction(EndGameFunctionDefinition, async ({ inputs, token }) => { | ||
const { channel_id } = inputs; | ||
console.log('djb executing message to channel', channel_id); | ||
return { | ||
outputs: { | ||
message: `These are your winners:`, | ||
}, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { DefineWorkflow, Schema } from 'deno-slack-sdk/mod.ts'; | ||
import { EndGameFunctionDefinition } from '../functions/end_game_function.ts'; | ||
|
||
/** | ||
* A workflow is a set of steps that are executed in order. | ||
* Each step in a workflow is a function. | ||
* https://api.slack.com/future/workflows | ||
*/ | ||
const EndGameWorkflow = DefineWorkflow({ | ||
callback_id: 'end_game_workflow', | ||
title: 'End the game', | ||
description: 'Ends the game and tallies the results', | ||
input_parameters: { | ||
properties: { | ||
channel_id: { | ||
type: Schema.slack.types.channel_id, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const endGameFunctionStep = EndGameWorkflow.addStep(EndGameFunctionDefinition, { | ||
channel_id: EndGameWorkflow.inputs.channel_id, | ||
}); | ||
|
||
EndGameWorkflow.addStep(Schema.slack.functions.SendMessage, { | ||
channel_id: EndGameWorkflow.inputs.channel_id, | ||
message: endGameFunctionStep.outputs.message, | ||
}); | ||
|
||
export default EndGameWorkflow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters