{"id":15103090,"url":"https://github.com/green-api/whatsapp-chatbot-golang","last_synced_at":"2025-10-22T22:31:50.709Z","repository":{"id":161279970,"uuid":"636014408","full_name":"green-api/whatsapp-chatbot-golang","owner":"green-api","description":"This library helps you easily create a golang chatbot application with WhatsApp API","archived":false,"fork":false,"pushed_at":"2024-10-07T11:20:44.000Z","size":59,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-30T15:44:26.058Z","etag":null,"topics":["whatsap-go","whatsapp","whatsapp-api","whatsapp-api-go","whatsapp-bot","whatsapp-chat","whatsapp-chatbot","whatsapp-chatbot-golang","whatsapp-golang"],"latest_commit_sha":null,"homepage":"https://green-api.com/en/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/green-api.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-04T00:24:39.000Z","updated_at":"2024-10-07T11:20:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"0a99ad19-0b12-4122-9d1e-9691cbc8c7ba","html_url":"https://github.com/green-api/whatsapp-chatbot-golang","commit_stats":{"total_commits":22,"total_committers":4,"mean_commits":5.5,"dds":0.5454545454545454,"last_synced_commit":"20044b2ccf665a9b7044b2d70424fa1e20a04124"},"previous_names":["green-api/whatsapp-chatbot-golang"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-chatbot-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-chatbot-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-chatbot-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-chatbot-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-api","download_url":"https://codeload.github.com/green-api/whatsapp-chatbot-golang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237748132,"owners_count":19359783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["whatsap-go","whatsapp","whatsapp-api","whatsapp-api-go","whatsapp-bot","whatsapp-chat","whatsapp-chatbot","whatsapp-chatbot-golang","whatsapp-golang"],"created_at":"2024-09-25T19:20:54.774Z","updated_at":"2025-10-22T22:31:50.703Z","avatar_url":"https://github.com/green-api.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# whatsapp-chatbot-golang\n\n| Support links                                                                                                                                                                                                                                                                                                                                                                                                                           | Guides \u0026 News                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [![Support](https://img.shields.io/badge/support--mail-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white)](mailto:support@greenapi.com) [![Support](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\u0026logo=telegram\u0026logoColor=white)](https://t.me/greenapi_support_eng_bot) [![Support](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white)](https://wa.me/77273122366) | [![Guides](https://img.shields.io/badge/YouTube-%23FF0000.svg?style=for-the-badge\u0026logo=YouTube\u0026logoColor=white)](https://www.youtube.com/@greenapi-en) [![News](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\u0026logo=telegram\u0026logoColor=white)](https://t.me/green_api) [![News](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white)](https://whatsapp.com/channel/0029VaLj6J4LNSa2B5Jx6s3h) |\n\n[Документация на русском языке.](docs/README_RU.md)\n\nwhatsapp-chatbot-golang - library for integration with WhatsApp messenger via API\nservice [greenapi.com](https://greenapi.com/). To use the library, you need to obtain a registration token\nand account ID in [personal account](https://console.greenapi.com/). There is a free developer account plan.\n\n\u003e **Important Note:** Since version 1.0.0, the library uses `whatsapp-api-client-golang-v2` instead of\n`whatsapp-api-client-golang`.\n\n## API\n\nDocumentation for the REST API can be found at [link](https://greenapi.com/docs/api/). The library is a wrapper for the\nREST API,\ntherefore the documentation in the link above also applies to the library itself.\n\n## Authorization\n\nTo send a message or perform other GREEN API methods, the WhatsApp account in the phone app must be in\nauthorized state. To authorize your account, go to [personal account](https://console.greenapi.com/) and\nscan the QR code using the WhatsApp application.\n\n## Installation\n\nDon't forget to create a module:\n\n```shell\ngo mod init example\n```\n\nInstallation:\n\n```shell\ngo get github.com/green-api/whatsapp-chatbot-golang\n```\n\n## Import\n\n```go\nimport (\n\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n)\n```\n\n## Setup\n\nBefore launching the bot you should enable incoming notifications in instance settings by\nusing \u003ca href=\"https://green-api.com/en/docs/api/account/SetSettings/\"\u003eSetSettings method\u003c/a\u003e.\n\n```json\n\"incomingWebhook\": \"yes\",\n\"outgoingMessageWebhook\": \"yes\",\n\"outgoingAPIMessageWebhook\": \"yes\",\n```\n\n## Examples\n\n### How to set up an instance\n\nYou can create an instance in your personal account using [link](https://console.greenapi.com/). Click create and\nselect a tariff.\nTo start receiving incoming notifications, you need to configure your instance. Open your personal account page\nvia [link](https://console.greenapi.com/instanceList). Select an instance from the list and click on it. Click **Change\n**. In\n**Notifications** category includes all webhooks that need to be received.\n\n### How to initialize an object\n\nTo initiate a bot, you need to use the `NewBot` method from the library and specify the instance number and token from\nyour personal account.\n\n```go\nbot := chatbot.NewBot(\"INSTANCE_ID\", \"TOKEN\")\n```\n\nNote that keys can be obtained from environment variables:\n\n```go\nIDInstance := os.Getenv(\"ID_INSTANCE\")\nAPITokenInstance := os.Getenv(\"API_TOKEN_INSTANCE\")\n```\n\n### How to start receiving and responding to messages\n\nTo start receiving notifications, you need to call the bot.StartReceivingNotifications() method on the bot.\nBut before that you need to add a handler; this can be done in two ways. You can do this directly in the `main` function\nas in the `base` example:\n\nLink to example: [base.go](examples/base/main/base.go).\n\n```go\npackage main\n\nimport (\n\t\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n)\n\nfunc main() {\n\tbot := chatbot.NewBot(\"INSTANCE_ID\", \"TOKEN\")\n\n\tbot.IncomingMessageHandler(func(message *chatbot.Notification) {\n\t\tif message.Filter(map[string][]string{\"text\": {\"test\"}}) {\n\t\t\tmessage.AnswerWithText(\"Well done! You have write \\\"test\\\".\")\n\t\t} else {\n\t\t\tmessage.AnswerWithText(\"Write \\\"test\\\"!\")\n\t\t}\n\t})\n\n\tbot.StartReceivingNotifications()\n}\n```\n\nOr if you have complex nested scripts, it is better to use Scenes as in the `baseScene` example.\nUsing Scenes is easy - put the bot logic into a separate structure that implements the `Scene` interface, and add it to\nthe bot using the `bot.SetStartScene(StartScene{})` method.\nThe starting scene can call the next one using the `message.ActivateNextScene(NextScene{})` method, then the next\nwebhook will go into the new scene, this will allow you to divide the bot into separate parts and make the code more\nreadable and editable:\n\n```go\npackage main\n\nimport (\n\t\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n)\n\nfunc main() {\n\tbot := chatbot.NewBot(\"INSTANCE_ID\", \"TOKEN\")\n\n\tbot.SetStartScene(StartScene{})\n\n\tbot.StartReceivingNotifications()\n}\n\ntype StartScene struct {\n}\n\nfunc (s StartScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(message *chatbot.Notification) {\n\t\tif message.Filter(map[string][]string{\"text\": {\"test\"}}) {\n\t\t\tmessage.AnswerWithText(\"Well done! You have write \\\"test\\\".\")\n\t\t\tmessage.AnswerWithText(\"Now write \\\"second scene\\\"\")\n\t\t\tmessage.ActivateNextScene(SecondScene{})\n\t\t} else {\n\t\t\tmessage.AnswerWithText(\"Write \\\"test\\\"!\")\n\t\t}\n\t})\n}\n\ntype SecondScene struct {\n}\n\nfunc (s SecondScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(message *chatbot.Notification) {\n\t\tif message.Filter(map[string][]string{\"text\": {\"second scene\"}}) {\n\t\t\tmessage.AnswerWithText(\"Well done! You have write \\\"second scene\\\".\")\n\t\t\tmessage.ActivateNextScene(StartScene{})\n\t\t} else {\n\t\t\tmessage.AnswerWithText(\"This is second scene write \\\"second scene\\\"!\")\n\t\t}\n\t})\n}\n```\n\nIf you need that when creating a new state, it already has some default values, you need to change the `InitData` field\nof the `StateManager` structure.\nIn the standard implementation of `MapStateManager` this is done like this:\n\n```go\npackage main\n\nimport (\n\tgreenapi \"github.com/green-api/whatsapp-api-client-golang-v2\"\n\t\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n\t\"github.com/green-api/whatsapp-chatbot-golang/examples/full\"\n)\n\nfunc main() {\n\tbot := chatbot.NewBot(\"INSTANCE_ID\", \"TOKEN\")\n\n\tbot.StateManager = chatbot.NewMapStateManager(\n\t\tmap[string]interface{}{\n\t\t\t\"defaultField1\": \"defaultValue1\",\n\t\t\t\"defaultField2\": \"defaultValue2\",\n\t\t\t\"defaultField3\": \"defaultValue3\",\n\t\t})\n\n\tbot.SetStartScene(full.StartScene{})\n\n\tbot.StartReceivingNotifications()\n}\n```\n\nPlease note that errors may occur while executing queries so that your program does not break due to them, you need to\nhandle errors. All library errors are sent to the `ErrorChannel` channel, you can handle them for example in this way:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n\t\"github.com/green-api/whatsapp-chatbot-golang/examples/full\"\n)\n\nfunc main() {\n\tbot := chatbot.NewBot(\"INSTANCE_ID\", \"TOKEN\")\n\n\tbot.SetStartScene(full.StartScene{})\n\n\t//All errors will simply be output to the console\n\tgo func() {\n\t\tselect {\n\t\tcase err := \u003c-bot.ErrorChannel:\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err)\n\t\t\t}\n\t\t}\n\t}()\n\n\tbot.StartReceivingNotifications()\n}\n```\n\n### How to receive other notifications and handle the notification body\n\nYou can receive not only incoming messages, but also outgoing ones, as well as their statuses and any other types of web\nhooks.\nTo do this, simply add a new handler to the scene or main function. Each scene can have multiple handlers.\n\nLink to example: [event.go](examples/event/main/event.go).\n\n```go\npackage main\n\nimport (\n\tcb \"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n)\n\ntype StartScene struct {\n}\n\nfunc (s StartScene) Start(bot *cb.Bot) {\n\tbot.IncomingMessageHandler(func(notification *cb.Notification) {\n\t\t//Logic for processing input messages\n\t})\n\n\tbot.OutgoingMessageHandler(func(notification *cb.Notification) {\n\t\t//Logic for processing outgoing messages\n\t})\n\n\tbot.OutgoingMessageStatusHandler(func(notification *cb.Notification) {\n\t\t//Logic for processing outgoing message statuses\n\t})\n\n\tbot.IncomingBlockHandler(func(notification *cb.Notification) {\n\t\t//Logic for processing chat blocking\n\t})\n\n\tbot.IncomingCallHandler(func(notification *cb.Notification) {\n\t\t//Logic for processing incoming calls\n\t})\n\n\tbot.DeviceInfoHandler(func(notification *cb.Notification) {\n\t\t//Logic for processing webhooks about the device status\n\t})\n\n\tbot.StateInstanceChangedHandler(func(notification *cb.Notification) {\n\t\t//Logic for processing webhooks about changing the instance status\n\t})\n}\n```\n\n### Receive webhooks via HTTP API\n\nYou can get incoming webhooks (messages, statuses) via HTTP API requests in the similar way as the rest of the Green API\nmethods are implemented. Herewith, the chronological order of the webhooks following is guaranteed in the sequence in\nwhich they were received FIFO. All incoming webhooks are stored in the queue and are expected to be received within 24\nhours.\n\nTo get incoming webhooks, you have to sequentially call two\nmethods \u003ca href=\"https://green-api.com/en/docs/api/receiving/technology-http-api/ReceiveNotification/\"\u003e\nReceiveNotification\u003c/a\u003e\nand \u003ca href=\"https://green-api.com/en/docs/api/receiving/technology-http-api/DeleteNotofication/\"\u003e\nDeleteNotification\u003c/a\u003e. ReceiveNotification method receives an incoming webhook. DeleteNotification method confirms\nsuccessful webhook receipt and processing. To learn more about the methods, refer to respective ReceiveNotification and\nDeleteNotification sections.\n\n### How to filter incoming messages\n\nFiltering by webhook type occurs automatically at the handler creation level, for\nexample - [event.go](examples/event/main/event.go).\nOther types of filters are implemented using the `Filter` method, which takes `map[string][]string{}` as a parameter.\nThe key of this map is a string with the name of the parameter by which filtering will occur, the value of the map is a\nslice with a set of expected values.\nIf there are several expected values in the filter for a parameter, then the method returns `true` if at least one\nexpected value matches the webhook field.\nIf a method filters several parameters at the same time, the method returns `true` only if all parameters pass the test.\n\n| Names of parameters for filtering | Description                                                                                                   |\n|-----------------------------------|---------------------------------------------------------------------------------------------------------------|\n| `text`                            | Filter by message text, if at least one of the expected values matches, returns `true`                        |\n| `text_regex`                      | Filter by message text, but by regex pattern, if at least one pattern in the slice matches, returns true      |\n| `sender`                          | Returns `true` if at least one expected value equals the message sender ID                                    |\n| `chatId`                          | Returns `true` if at least one expected value equals the message's chat ID                                    |\n| `messageType`                     | Returns `true` if at least one expected value is equal to the value of the `messageType` field in the webhook |\n\nLink to example: [filter.go](examples/filter/main/filter.go).\n\n```go\npackage main\n\nimport (\n\tcb \"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n)\n\ntype StartScene struct {\n}\n\nfunc (s StartScene) Start(bot *cb.Bot) {\n\tbot.IncomingMessageHandler(func(message *cb.Notification) {\n\t\tif message.Filter(map[string][]string{\"text\": {\"1\"}}) {\n\t\t\tmessage.AnswerWithText(\"This message text equals \\\"1\\\"\")\n\t\t}\n\n\t\tif message.Filter(map[string][]string{\"text_regex\": {\"\\\\d+\"}}) {\n\t\t\tmessage.AnswerWithText(\"This message has only digits!\")\n\t\t}\n\n\t\tif message.Filter(map[string][]string{\"text_regex\": {\"6\"}}) {\n\t\t\tmessage.AnswerWithText(\"This message contains \\\"6\\\" in the text\")\n\t\t}\n\n\t\tif message.Filter(map[string][]string{\"text\": {\"hi\"}, \"messageType\": {\"textMessage\", \"extendedTextMessage\"}}) {\n\t\t\tmessage.AnswerWithText(\"This message is a \\\"textMessage\\\" or \\\"extendedTextMessage\\\", and text equals \\\"hi\\\"\")\n\t\t}\n\t})\n}\n```\n\n### How to manage user state\n\nBy default, in this library the state is stored in a map of type `map[string]interface{}{}`.\nThe key can be any string, any object can be the value.\nThe state ID is the chat ID, meaning each chat will have a separate state.\nTo manage the state, you need to use the methods of the `Notification` structure:\n\n| Manager method        | Description                                   |\n|-----------------------|-----------------------------------------------|\n| `ActivateNextScene()` | Activates the selected scene.                 |\n| `GetCurrentScene()`   | Returns the current scene.                    |\n| `GetStateData()`      | Returns the status data of the selected chat. |\n| `SetStateData()`      | Replaces the state data of the selected chat. |\n| `UpdateStateData()`   | Updates the status data of the selected chat. |\n\n\u003e Webhooks like incomingBlock, deviceInfo, stateInstanceChanged are not tied to the chat, so they do not have their own\n\u003e state.\n\u003e If you want to interact with the states of other chats other than the chat of the webhook being processed, you can use\n\u003e the methods of the `StateManager` structure directly. The `StateManager` methods do the same as the `Notification`\n\u003e structure methods, but they expect an additional `stateId` parameter.\n\nAs an example, a simple bot was created to simulate user registration.\n\nLink to example: [state.go](examples/state/main/state.go).\n\n```go\npackage main\n\nimport (\n\t\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n)\n\ntype StartScene struct {\n}\n\nfunc (s StartScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(notification *chatbot.Notification) {\n\t\tif notification.Filter(map[string][]string{\"text\": {\"/start\"}}) {\n\t\t\tnotification.AnswerWithText(\"Hi! This bot is an example of using state.\\nPlease enter your login:\")\n\t\t\tnotification.ActivateNextScene(LoginScene{})\n\t\t} else {\n\t\t\tnotification.AnswerWithText(\"Please enter the /start command.\")\n\t\t}\n\t})\n}\n\ntype LoginScene struct {\n}\n\nfunc (s LoginScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(notification *chatbot.Notification) {\n\t\tlogin, err := notification.Text()\n\t\tif err != nil || len(login) \u003e 12 || len(login) \u003c 6 {\n\t\t\tnotification.AnswerWithText(\"Select a login from 6 to 12 characters!\")\n\t\t} else {\n\t\t\tnotification.UpdateStateData(map[string]interface{}{\"login\": login})\n\t\t\tnotification.ActivateNextScene(PasswordScene{})\n\t\t\tnotification.AnswerWithText(\"Your login \" + notification.GetStateData()[\"login\"].(string) + \" - successfully saved.\\nCreate a password:\")\n\t\t}\n\t})\n}\n\ntype PasswordScene struct {\n}\n\nfunc (s PasswordScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(notification *chatbot.Notification) {\n\t\tpassword, err := notification.Text()\n\t\tif err != nil || len(password) \u003e 16 || len(password) \u003c 8 {\n\t\t\tnotification.AnswerWithText(\"Choose a password between 8 and 16 characters!\")\n\t\t} else {\n\t\t\tnotification.UpdateStateData(map[string]interface{}{\"password\": password})\n\t\t\tnotification.ActivateNextScene(StartScene{})\n\t\t\tnotification.AnswerWithText(\"Success! Your login: \" + notification.GetStateData()[\"login\"].(string) + \"\\nYour password: \" + notification.GetStateData()[\"password\"].(string))\n\t\t}\n\t})\n}\n```\n\nIf you need that when creating a new state, it already has some default values, you need to change the `InitData` field\nof the `StateManager` structure.\nIn the standard implementation of `MapStateManager` this is done like this:\n\n```go\npackage main\n\nimport (\n\t\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n\t\"github.com/green-api/whatsapp-chatbot-golang/examples/full\"\n)\n\nfunc main() {\n\tbot := chatbot.NewBot(\"INSTANCE_ID\", \"TOKEN\")\n\n\tbot.StateManager = chatbot.NewMapStateManager(\n\t\tmap[string]interface{}{\n\t\t\t\"defaultField1\": \"defaultValue1\",\n\t\t\t\"defaultField2\": \"defaultValue2\",\n\t\t\t\"defaultField3\": \"defaultValue3\",\n\t\t})\n\n\tbot.SetStartScene(full.StartScene{})\n\n\tbot.StartReceivingNotifications()\n}\n```\n\n### Bot example\n\nAs an example, a bot was created that demonstrates sending methods of the `Notification` structure.\n\nThe bot is started with the command - /start\nAfter launching, you need to select a method from the menu, and the bot will execute it.\n\nLink to example: [full.go](examples/full/main/full.go).\n\nThe start scene waits for the `/start` command, after which it sends the menu and activates the next `PickMethodScene`.\n`PickMethodScene` waits for the user's response and executes the selected method.\nIf the user selected `SendFileByUrl()`, then the bot will launch the `InputLinkScene` scene, in which it will ask for a\nlink to the file and send the file if the link is valid.\n\n```go\npackage full\n\nimport (\n\tgreenapi \"github.com/green-api/whatsapp-api-client-golang-v2\"\n\t\"github.com/green-api/whatsapp-chatbot-golang/chatbot\"\n)\n\ntype StartScene struct {\n}\n\nfunc (s StartScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(notification *chatbot.Notification) {\n\t\tif notification.Filter(map[string][]string{\"text\": {\"/start\"}}) {\n\t\t\tnotification.AnswerWithText(`Hi! This bot uses various API methods.\nPlease select a method:\n1. SendMessage()\n2. SendFileByUrl()\n3. SendPoll()\n4. SendContact()\n5. SendLocation()\nSend the item number in one digit.`)\n\t\t\tnotification.ActivateNextScene(PickMethodScene{})\n\t\t} else {\n\t\t\tnotification.AnswerWithText(\"Please enter the /start command.\")\n\t\t}\n\t})\n}\n\ntype PickMethodScene struct {\n}\n\nfunc (s PickMethodScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(message *chatbot.Notification) {\n\t\tif message.Filter(map[string][]string{\"text\": {\"1\"}}) {\n\t\t\tmessage.AnswerWithText(\"Hello world!\")\n\t\t}\n\n\t\tif message.Filter(map[string][]string{\"text\": {\"2\"}}) {\n\t\t\tmessage.AnswerWithText(\"Give me a link for a file, for example: https://th.bing.com/th/id/OIG.gq_uOPPdJc81e_v0XAei\")\n\t\t\tmessage.ActivateNextScene(InputLinkScene{})\n\t\t}\n\n\t\tif message.Filter(map[string][]string{\"text\": {\"3\"}}) {\n\t\t\tmessage.AnswerWithPoll(\"Please choose a color:\", false, []string{\n\t\t\t\t\"Red\",\n\t\t\t\t\"Green\",\n\t\t\t\t\"Blue\",\n\t\t\t})\n\t\t}\n\n\t\tif message.Filter(map[string][]string{\"text\": {\"4\"}}) {\n\t\t\tcontact := greenapi.Contact{\n\t\t\t\tPhoneContact: 79001234568,\n\t\t\t\tFirstName:    \"Artem\",\n\t\t\t\tMiddleName:   \"Petrovich\",\n\t\t\t\tLastName:     \"Evpatoria\",\n\t\t\t\tCompany:      \"Bicycle\",\n\t\t\t}\n\t\t\tmessage.AnswerWithContact(contact)\n\t\t}\n\n\t\tif message.Filter(map[string][]string{\"text\": {\"5\"}}) {\n\t\t\tmessage.AnswerWithLocation(\"House\", \"Cdad. de La Paz 2969, Buenos Aires\", -34.5553558, -58.4642510)\n\t\t}\n\n\t\tif !message.Filter(map[string][]string{\"text_regex\": {\"\\\\d+\"}}) {\n\t\t\tmessage.AnswerWithText(\"Answer must contain only numbers!\")\n\t\t}\n\t})\n}\n\ntype InputLinkScene struct {\n}\n\nfunc (s InputLinkScene) Start(bot *chatbot.Bot) {\n\tbot.IncomingMessageHandler(func(message *chatbot.Notification) {\n\t\tif message.Filter(map[string][]string{\"text_regex\": {\"^https://[^\\\\s]+$\"}}) {\n\t\t\ttext, _ := message.Text()\n\t\t\tmessage.AnswerWithUrlFile(text, \"testFile\", \"This is your file!\")\n\t\t\tmessage.ActivateNextScene(PickMethodScene{})\n\t\t} else {\n\t\t\tmessage.AnswerWithText(\"The link must not contain spaces and must begin with https://\")\n\t\t}\n\t})\n}\n```\n\n## Documentation on service methods\n\n[Documentation on service methods](https://greenapi.com/docs/api/)\n\n## License\n\nLicensed under [\nCreative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)\n](https://creativecommons.org/licenses/by-nd/4.0/).\n[LICENSE](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-chatbot-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-api%2Fwhatsapp-chatbot-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-chatbot-golang/lists"}