Tracking the state of an instance#
Getting the state of an instance can be implemented in several ways:
-
Use the GetStateInstance method - request the state of the instance every minute and if the state of the instance changes perform actions:
authorized
- inform the operator that the instance is in a working state;notAuthorized
- inform the operator about the necessity to re-connect the account with the instance and stop requesting sending methods to the API (messages will not be delivered, they will be added to the queue and stored there for 24 hours);blocked
- inform the operator about the need to make a request to unblock the account and stop requesting sending methods to API (messages will not be delivered, they will be added to the queue and stored there for 24 hours);starting
- restart the instance using reboot method, wait for 2 minutes and repeat receiving the instance status, if the instance status has not changed, then inform the operator that the instance is currently in the startup mode and there may be a delay in sending messages;yellowCard
- inform the operator about receiving a warning on the account, it is required to follow the instructions specified in the article yellowCard. The account is partially or completely suspended from sending messages due to spammer activity. Messages sent after receiving the status are stored in the queue to be sent for 24 hours. To continue running the instance, you need to do a reboot of the instance.
-
Receive instance status using notifications.
To receive notifications you need to:- Enable the "Receive notifications when instance authorization status changes" setting (using the setSettings method or via console).
- Make a instance status notification handler and when one of the statuses is received, perform the actions specified in the previous paragraph.
Note
-
We recommend using a system based on the GetStateInstance method, when using instance receipt by notifications, allow the operator to manually check the instance status (by button) or use both methods simultaneously.
-
We recommend to independently implement a notification system when instance status changes to the statuses
notAuthorized
,blocked
,yellowCard
(send a letter to mail, send a notification to Telegram or WhatsApp).