@@ -9,7 +9,7 @@ Here is the `sendMessage` action of the Telegram block:
|
||||
```ts
|
||||
import { createAction, option } from '@typebot.io/forge'
|
||||
import { auth } from '../auth'
|
||||
import { got } from 'got'
|
||||
import ky from 'ky'
|
||||
|
||||
export const sendMessage = createAction({
|
||||
auth,
|
||||
@@ -27,14 +27,14 @@ export const sendMessage = createAction({
|
||||
run: {
|
||||
server: async ({ credentials: { token }, options: { chatId, text } }) => {
|
||||
try {
|
||||
await got.post(`https://api.telegram.org/bot${token}/sendMessage`, {
|
||||
await ky.post(`https://api.telegram.org/bot${token}/sendMessage`, {
|
||||
json: {
|
||||
chat_id: chatId,
|
||||
text,
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
console.log('ERROR', error.response.body)
|
||||
console.log('ERROR', await error.response.text())
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -13,8 +13,6 @@ An action can do one of the following things:
|
||||
|
||||
The most common action is to execute a function on the server. This is done by simply declaring that function in the action block.
|
||||
|
||||
If you need to use an external package that is not compatible with web browser environment, you will have to dynamically import it in the server function. You can find an example of this in the [Anthropic's Create Chat Message action](https://github.com/baptisteArno/typebot.io/blob/main/packages/forge/blocks/anthropic/actions/createChatMessage.tsx)
|
||||
|
||||
Example:
|
||||
|
||||
```ts
|
||||
|
||||
Reference in New Issue
Block a user