2023-01-27 03:22:44 -08:00
|
|
|
import type { INodeProperties } from 'n8n-workflow';
|
2022-04-01 08:21:25 -07:00
|
|
|
|
|
|
|
export const chatMessageOperations: INodeProperties[] = [
|
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
2022-04-25 02:22:16 -07:00
|
|
|
noDataExpression: true,
|
2022-04-01 08:21:25 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['chatMessage'],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Create',
|
|
|
|
value: 'create',
|
|
|
|
description: 'Create a message',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Create a chat message',
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get',
|
|
|
|
value: 'get',
|
|
|
|
description: 'Get a message',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Get a chat message',
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
{
|
2022-09-07 07:51:14 -07:00
|
|
|
name: 'Get Many',
|
2022-04-01 08:21:25 -07:00
|
|
|
value: 'getAll',
|
2022-09-13 03:36:36 -07:00
|
|
|
description: 'Get many messages',
|
2022-09-08 08:10:13 -07:00
|
|
|
action: 'Get many chat messages',
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'create',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export const chatMessageFields: INodeProperties[] = [
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
/* chatMessage:create */
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
{
|
2022-06-03 10:23:49 -07:00
|
|
|
displayName: 'Chat Name or ID',
|
2022-04-01 08:21:25 -07:00
|
|
|
name: 'chatId',
|
|
|
|
required: true,
|
|
|
|
type: 'options',
|
2022-08-17 08:50:24 -07:00
|
|
|
description:
|
2024-09-12 07:53:36 -07:00
|
|
|
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
2022-04-01 08:21:25 -07:00
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getChats',
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
operation: ['create', 'get'],
|
|
|
|
resource: ['chatMessage'],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Message Type',
|
|
|
|
name: 'messageType',
|
|
|
|
required: true,
|
|
|
|
type: 'options',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Text',
|
|
|
|
value: 'text',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'HTML',
|
|
|
|
value: 'html',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
operation: ['create'],
|
|
|
|
resource: ['chatMessage'],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
2022-04-25 02:22:16 -07:00
|
|
|
default: 'text',
|
2022-04-01 08:21:25 -07:00
|
|
|
description: 'The type of the content',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Message',
|
|
|
|
name: 'message',
|
|
|
|
required: true,
|
|
|
|
type: 'string',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
operation: ['create'],
|
|
|
|
resource: ['chatMessage'],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: '',
|
2022-04-25 02:22:16 -07:00
|
|
|
description: 'The content of the item',
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
2023-10-03 01:18:59 -07:00
|
|
|
{
|
|
|
|
displayName: 'Options',
|
|
|
|
name: 'options',
|
|
|
|
type: 'collection',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: ['create'],
|
|
|
|
resource: ['chatMessage'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: {},
|
|
|
|
description: 'Other options to set',
|
2024-07-29 05:27:23 -07:00
|
|
|
placeholder: 'Add option',
|
2023-10-03 01:18:59 -07:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Include Link to Workflow',
|
|
|
|
name: 'includeLinkToWorkflow',
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
description:
|
|
|
|
'Whether to append a link to this workflow at the end of the message. This is helpful if you have many workflows sending messages.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-04-01 08:21:25 -07:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
/* chatMessage:get */
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
{
|
|
|
|
displayName: 'Message ID',
|
|
|
|
name: 'messageId',
|
|
|
|
required: true,
|
|
|
|
type: 'string',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
operation: ['get'],
|
|
|
|
resource: ['chatMessage'],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
/* chatMessage:getAll */
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
{
|
2022-06-03 10:23:49 -07:00
|
|
|
displayName: 'Chat Name or ID',
|
2022-04-01 08:21:25 -07:00
|
|
|
name: 'chatId',
|
|
|
|
required: true,
|
|
|
|
type: 'options',
|
2022-08-17 08:50:24 -07:00
|
|
|
description:
|
2024-09-12 07:53:36 -07:00
|
|
|
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
2022-04-01 08:21:25 -07:00
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getChats',
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
operation: ['getAll'],
|
|
|
|
resource: ['chatMessage'],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Return All',
|
|
|
|
name: 'returnAll',
|
|
|
|
type: 'boolean',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
operation: ['getAll'],
|
|
|
|
resource: ['chatMessage'],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: false,
|
2022-04-25 02:22:16 -07:00
|
|
|
description: 'Whether to return all results or only up to a given limit',
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Limit',
|
|
|
|
name: 'limit',
|
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
operation: ['getAll'],
|
|
|
|
resource: ['chatMessage'],
|
|
|
|
returnAll: [false],
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
typeOptions: {
|
|
|
|
minValue: 1,
|
|
|
|
maxValue: 500,
|
|
|
|
},
|
2022-04-25 02:22:16 -07:00
|
|
|
default: 50,
|
|
|
|
description: 'Max number of results to return',
|
2022-04-01 08:21:25 -07:00
|
|
|
},
|
|
|
|
];
|