feat(telegram-bot): add send message action

This commit is contained in:
Ali BARIN
2022-12-04 16:49:30 +01:00
parent 39ac3ff4c2
commit 8c343abac5
3 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import sendMessage from './send-message';
export default [sendMessage];

View File

@@ -0,0 +1,59 @@
import qs from 'qs';
import defineAction from '../../../../helpers/define-action';
export default defineAction({
name: 'Send message',
key: 'sendMessage',
description: 'Sends a message to a chat you specify.',
arguments: [
{
label: 'Chat ID',
key: 'chatId',
type: 'string' as const,
required: true,
description: 'Unique identifier for the target chat or username of the target channel (in the format @channelusername).',
variables: true,
},
{
label: 'Message text',
key: 'text',
type: 'string' as const,
required: true,
description: 'Text of the message to be sent, 1-4096 characters.',
variables: true,
},
{
label: 'Disable notification?',
key: 'disableNotification',
type: 'dropdown' as const,
required: false,
value: false,
description: 'Sends the message silently. Users will receive a notification with no sound.',
variables: false,
options: [
{
label: 'Yes',
value: true,
},
{
label: 'No',
value: false,
},
],
},
],
async run($) {
const payload = {
chat_id: $.step.parameters.chatId,
text: $.step.parameters.text,
disable_notification: $.step.parameters.disableNotification,
};
const response = await $.http.post('/sendMessage', payload);
$.setActionItem({
raw: response.data,
});
},
});

View File

@@ -14,4 +14,5 @@ export default defineApp({
primaryColor: '2AABEE',
beforeRequest: [addAuthHeader],
auth,
actions,
});