Skip to content

How to send a file by uploading it from disk#

Installation#

Do not forget to create a module:

go mod init example

Installation:

go get github.com/green-api/telegram-api-client-golang

Import#

import (
    "github.com/green-api/telegram-api-client-golang/pkg/api"
)

Examples#

How to initialize an object#

GreenAPI := api.GreenAPI{
    IDInstance:       "4100000000",
    APITokenInstance: "d75b3a66374942c5b3c019c698abc2067e151558acbd412345",
}

Note that the keys can be obtained from environment variables:

IDInstance := os.Getenv("ID_INSTANCE")
APITokenInstance := os.Getenv("API_TOKEN_INSTANCE")

How to send a file by uploading it from disk#

To send a file, you need to specify the path to the required document as the first parameter.

Link to the example: sendFileByUpload/main.go

response, _ := GreenAPI.Methods().Sending().SendFileByUpload("example.png", map[string]interface{}{
    "chatId": "79876543210@c.us",
})

Running the application#

go run main.go

The list of examples#

Description Link to the example
How to send a message sendMessage/main.go
How to send a file by uploading it from disk sendFileByUpload/main.go
How to send a file by link sendFileByUrl/main.go
How to create a group createGroup/main.go