2022-08-17 08:50:24 -07:00
import { INodeProperties } from 'n8n-workflow' ;
2022-02-19 02:18:43 -08:00
export const messageOperations : INodeProperties [ ] = [
{
displayName : 'Operation' ,
name : 'operation' ,
noDataExpression : true ,
type : 'options' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a message' ,
2022-07-10 13:50:51 -07:00
action : 'Create a message' ,
2022-02-19 02:18:43 -08:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a message' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a message' ,
2022-02-19 02:18:43 -08:00
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a message' ,
2022-07-10 13:50:51 -07:00
action : 'Get a message' ,
2022-02-19 02:18:43 -08:00
} ,
{
name : 'Update' ,
value : 'update' ,
description : 'Update a message' ,
2022-07-10 13:50:51 -07:00
action : 'Update a message' ,
2022-02-19 02:18:43 -08:00
} ,
] ,
default : 'create' ,
} ,
] ;
export const messageFields : INodeProperties [ ] = [
/* -------------------------------------------------------------------------- */
/* message:create */
/* -------------------------------------------------------------------------- */
{
2022-06-03 10:23:49 -07:00
displayName : 'Space Name or ID' ,
2022-02-19 02:18:43 -08:00
name : 'spaceId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getSpaces' ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'create' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Space resource name, in the form "spaces/*". Example: spaces/AAAAMpdlehY. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2022-02-19 02:18:43 -08:00
} ,
{
displayName : 'JSON Parameters' ,
name : 'jsonParameters' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'create' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : false ,
description : 'Whether to pass the message object as JSON' ,
} ,
{
displayName : 'Message' ,
name : 'messageUi' ,
type : 'collection' ,
required : true ,
placeholder : 'Add Message' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'create' ] ,
jsonParameters : [ false ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
default : '' ,
} ,
// { // TODO: get cards from the UI (check the Slack node, specifically the blocks parameter under message: post)
// displayName: 'Cards',
// name: 'cards',
// placeholder: 'Add Cards',
// type: 'fixedCollection',
// default: '',
// typeOptions: {
// multipleValues: true,
// },
// description: 'Rich, formatted and interactive cards that can be used to display UI elements such as: formatted texts, buttons, clickable images',
// options: [
// {
// name: 'metadataValues',
// displayName: 'Metadata',
// values: [
// {
// displayName: 'Name',
// name: 'name',
// type: 'string',
// default: '',
// description: 'Name of the card',
// },
// {
// displayName: 'Header',
// name: 'header',
// type: 'json',
// default: '',
// description: 'Header of the card',
// },
// {
// displayName: 'Sections',
// name: 'sections',
// type: 'json',
// default: '',
// description: 'Sections of the card',
// },
// {
// displayName: 'Actions',
// name: 'cardActions',
// type: 'json',
// default: '',
// description: 'Actions of the card',
// },
// ],
// },
// ],
// },
] ,
} ,
{
2022-08-17 08:50:24 -07:00
displayName :
'See <a href="https://developers.google.com/chat/reference/rest/v1/spaces.messages#Message" target="_blank">Google Chat Guide</a> To Creating Messages' ,
2022-02-19 02:18:43 -08:00
name : 'jsonNotice' ,
type : 'notice' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'create' ] ,
jsonParameters : [ true ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
} ,
{
displayName : 'Message (JSON)' ,
name : 'messageJson' ,
type : 'json' ,
required : true ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'create' ] ,
jsonParameters : [ true ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
description : 'Message input as JSON Object or JSON String' ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'create' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
options : [
// {
// displayName: 'Thread Key',
// name: 'threadKey',
// type: 'string',
// default: '',
// description: 'Thread identifier which groups messages into a single thread. Has no effect if thread field, corresponding to an existing thread, is set in message. Example: spaces/AAAAMpdlehY/threads/MZ8fXhZXGkk.',
// },
{
displayName : 'Request ID' ,
name : 'requestId' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'A unique request ID for this message. If a message has already been created in the space with this request ID, the subsequent request will return the existing message and no new message will be created.' ,
2022-02-19 02:18:43 -08:00
} ,
] ,
} ,
/* -------------------------------------------------------------------------- */
/* messages:delete */
/* -------------------------------------------------------------------------- */
{
displayName : 'Message ID' ,
name : 'messageId' ,
type : 'string' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'delete' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
description : 'Resource name of the message to be deleted, in the form "spaces//messages/"' ,
} ,
/* -------------------------------------------------------------------------- */
/* message:get */
/* -------------------------------------------------------------------------- */
{
displayName : 'Message ID' ,
name : 'messageId' ,
type : 'string' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'get' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
description : 'Resource name of the message to be retrieved, in the form "spaces//messages/"' ,
} ,
/* -------------------------------------------------------------------------- */
/* message:update */
/* -------------------------------------------------------------------------- */
{
displayName : 'Message ID' ,
name : 'messageId' ,
type : 'string' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'update' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
description : 'Resource name of the message to be updated, in the form "spaces//messages/"' ,
} ,
{
displayName : 'JSON Parameters' ,
name : 'jsonParameters' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'update' ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : false ,
description : 'Whether to pass the update fields object as JSON' ,
} ,
{
displayName : 'Update Fields' ,
name : 'updateFieldsUi' ,
type : 'collection' ,
required : true ,
placeholder : 'Add Options' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'update' ] ,
jsonParameters : [ false ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
default : '' ,
} ,
// { // TODO: get cards from the UI (check the Slack node, specifically the blocks parameter under message: post)
// displayName: 'Cards',
// name: 'cards',
// placeholder: 'Add Cards',
// type: 'fixedCollection',
// default: '',
// typeOptions: {
// multipleValues: true,
// },
// description: 'Rich, formatted and interactive cards that can be used to display UI elements such as: formatted texts, buttons, clickable images',
// options: [
// {
// name: 'metadataValues',
// displayName: 'Metadata',
// values: [
// {
// displayName: 'Name',
// name: 'name',
// type: 'string',
// default: '',
// description: 'Name of the card',
// },
// {
// displayName: 'Header',
// name: 'header',
// type: 'json',
// default: '',
// description: 'Header of the card',
// },
// {
// displayName: 'Sections',
// name: 'sections',
// type: 'json',
// default: '',
// description: 'Sections of the card',
// },
// {
// displayName: 'Actions',
// name: 'cardActions',
// type: 'json',
// default: '',
// description: 'Actions of the card',
// },
// ],
// },
// ],
// },
] ,
} ,
{
2022-08-17 08:50:24 -07:00
displayName :
'See <a href="https://developers.google.com/chat/reference/rest/v1/spaces.messages#Message" target="_blank">Google Chat Guide</a> To Creating Messages' ,
2022-02-19 02:18:43 -08:00
name : 'jsonNotice' ,
type : 'notice' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'update' ] ,
jsonParameters : [ true ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
} ,
{
displayName : 'Update Fields (JSON)' ,
name : 'updateFieldsJson' ,
type : 'json' ,
required : true ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'message' ] ,
operation : [ 'update' ] ,
jsonParameters : [ true ] ,
2022-02-19 02:18:43 -08:00
} ,
} ,
default : '' ,
description : 'Message input as JSON Object or JSON String' ,
} ,
] ;