Skip to content

How to import the library and initiate your bot#

Installation#

Don't forget to create a module:

go mod init example

Installation:

go get github.com/green-api/whatsapp-chatbot-golang

You can create an instance in your personal account using link. Click create and select a tariff. To start receiving incoming notifications, you need to configure your instance. Open your personal account page via link. Select an instance from the list and click on it. Click Change. IN Notifications category includes all webhooks that need to be received.

How to initialize an object#

To initiate a bot, you need to use the NewBot method from the library and specify the instance number and token from your personal account.

bot := whatsapp_chatbot_golang.NewBot("INSTANCE_ID", "TOKEN")

Note that keys can be obtained from environment variables:

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

List of examples#

Description Link to example
How to initialize a handler base.go
How to initialize a scene baseScene.go
Scene "Echo" echo.go
How to receive other types of notifications event.go
How to filter incoming messages filter.go
How to work with bot state state.go
Example of a ready-made chat bot full.go