Keyword autosubscription in the Gamayun mailer in VK and a test of the “keyboard. Working with the library

In Vkontakte, for convenience, you can use special key combinations - hot keys, for sending messages, watching videos, photos, publishing posts, etc. Consider which key combinations are most often used.

When sending messages

To switch to newline in the text box use the combination .

In order to send a message to the addressee, you need to use the key Enter.

Or, by clicking on the arrow to the right, select another key combination:

- to send a message


Enter- to break a line

When posting to the wall

To move to a new line in a post or in a comment to a post, use the key Enter.

In order to post or leave a comment on it, use or .

When switching between dialogs

For the convenience of managing dialogs in Vkontakte, there is an option to use keyboard shortcuts Ctrl+number(from 1 to 0).


On the right there is a window of personal correspondence, which you can change with ease. Maximum amount dialogues is limited to ten. In order to write to other users, select the dialogue with the mouse.

When viewing photos

To make it easier to view images, you can use full screen mode. To do this, select the key combination Alt+Enter or Ctrl+Enter .

Alt+Enter or Esc .


When watching a video

Rewinding the video is done using the arrow keys. The rewind segments are about seven seconds long.

Pressing the space bar pauses the video or continues playing it.

To exit full screen mode, use Alt+Enter or Esc.

When scrolling the page

To scroll down the page use Page Down or end .


To scroll the page up - Page Up or Home .


The VKontakte social network introduced the ability to connect keyboards to chat bots to simplify navigation and speed up communication with subscribers. Now the user can choose one of the predefined interaction options and ask a question of interest - and the bot will return with an answer.

How to add a new feature?

For the buttons to work, you must click on "Enable API for bots" in the settings of community messages. Team "VKontakte" released detailed documentation for this feature.

Where to look?

New buttons can be tested:

  • in the official Comedy Club community;
  • with the "Maxim" bot, which converts text into an audio message;
  • with Callback API Bot tracking updates in selected communities.

What to expect in the next updates of VKontakte?

The developers promise to soon add support for chatbots in conversations. It is reported that any of their functions can be used without interrupting the dialogue and the need to forward messages from bots to friends.

Chatbots are gaining popularity among messenger users for their accessibility and ease of interaction. Another Russian technology company Just AI at the end of May 2018 is a constructor of embedded chatbots that understand natural language. And those who want to create their own bot for VKontakte can familiarize themselves with.

Today we will tell you what are the hot keys that work in social network VKontakte, we will provide a complete list of hotkeys and tell you how it is more convenient to use them.

Since the social network does not stand still and is constantly updated and developed, and if you know other hotkeys or we forgot to mention something, be sure to write comments and we will include your additions to our article.

In short, this is a special set of buttons on the keyboard, thanks to which each user will be able to quickly perform one or another action.

In today's article, we'll talk about where they are and how to use the VKontakte hotkeys.

Types of hot keys

In this part of the article, we will talk about the "Messages" section. Probably, most users use the mouse when sending a message. Sometimes it is not very convenient, and sometimes some people like it much more. However, there are a couple of special buttons on the keyboard, thanks to which you can send a message without using the mouse.

  • Enter - by clicking on this button you will send the text to the person you need;
  • Shift + Enter - by clicking on this combination you will simply transfer the text.

Another interesting feature is the ability to use one combination to go to some dialogue. Let's say you are talking to several people, to go directly to the one you want, just click on Ctrl+3. Three is the number of the dialogue.

If you are viewing someone's photos and it is inconvenient for you to switch from one photo to another with the mouse, then there is a combination for this "Alt+Enter". By clicking on these two buttons, you will be able to view the pictures in slide show mode.

Hotkeys for audio recordings

When listening to their favorite music, users use the mouse, although the keyboard has a number of special keys, thanks to which you can perform any action immediately.

  • Pause - by clicking on it you will stop the song;
  • Play - the music will turn on again;
  • Stop - the track will be stopped;
  • Previous - you will switch to the previous song;
  • Next - turn on the next track in the list;
  • Ctrl + mouse wheel up - increase track volume; Ctrl + mouse wheel down - decrease track volume.

It is worth noting that these are the most popular and sought-after hotkeys on the VKontakte social network. In fact, there are a lot of them, some of them may work, and some may not. Important to know: if you have a laptop, then during the steps in the audio recording section, you need to use the "Fn" key, that is, "Fn + Play". We hope that our article helped answer all your questions.

Learn more about what this feature is

It is nothing but a chatbot. To automate the operation of the buttons, they must be associated with a subscription to a newsletter by keyword. Specify a keyword (or phrase) on the button, then when you click on it, you will automatically subscribe to the newsletter and send the message. Or another action that you set in the auto funnel.

How did I do it?

Pre-created a new subscription topic for free lessons and in the settings I set the key phrase for subscribing to this newsletter - "I want lessons."

When a person enters this key phrase in a dialogue with my community, he automatically subscribes to this newsletter (topic) and receives lessons. These lessons come in the first automatic mailing message right away. Then, after 2 days, a second message arrives, where I ask if the person has looked at the lessons, how they are for him, if there are any questions, and I also offer to receive the full course and an additional gift at a discount. Automessages in Gamayun are configured in the "Autofunnel" section. I wrote more about the auto funnel

On one I wrote the text “No, thank you” - if the subscriber pressed this button, then in the community messages I saw that he was not interested.

If a person clicked on the “I want lessons” button, he automatically subscribed to the lessons and immediately received a message with a link. And I segmented the people who are interested in it, and then used the auto funnel.

So far, the keyboard function is available only when sending mailing lists manually, but they promised to implement it in auto funnels soon.

According to test results

In principle, everything went well, as I had planned. There were some hiccups - when the user clicked on the "I want lessons" button, the message with the lessons came with some delay, somewhere faster, somewhere longer.

When a person clicked on the “No, thanks” button, I saw this message in my community dialogs, looked through the profiles of these people. Someone just turned out to be not interested in this topic, but the target person. There were also several people whose profiles I saw that, in principle, we were not on the way - and unsubscribed them so as not to annoy them with my mailing lists.

If a person has not opened the correspondence for a long time, and I managed to send other messages during this time, then the keyboard continues to hang under the chat until you click on it (at the same time, it is important to check the “Hide when pressed” checkbox in the keyboard settings). Consequently, the message has already risen higher, and not everyone understood what exactly these buttons refer to

In general, the function works as it should - the keyboard performs the function of a chat bot and a subscription by a key phrase, thereby allowing you to segment active audience and make a more targeted auto-chain for the interest of people.

Let's take a look at the steps on how to set up a subscription by key and associate it with a keyboard

First, let's create a subscription topic and add a keyword.(this may be one word) for automatic subscription. To do this, go to the Gamayun application through the button in the group, go to the "Mailouts" - "Themes" tab. Click "Create Theme".

Specify the title and description of the topic. For example, I will create a theme "Gift for activity".

The created topic can be made invisible in the mailing application. Then they will be able to subscribe to it only by a keyword or by a link that you provide. To hide visibility, click on the eye icon and it will become crossed out.

You can also add an autosubscribe keyword to an already created topic by simply clicking on the pencil to edit it.

Now for the newly created theme set the first auto-message after subscription. So that when you click on the button - I want a gift, a person immediately receives this gift. This is done in the "Auto Funnel" tab.

In the first field, select the created theme, then click "Create Script".

Click on the pencil to edit the block.

Create a new action in the block - Send a message.

We write our message. For example, I will have a link to a gift. You can substitute the subscriber name variable in the message for a personalized message. Click "Save".

In the same way, you can continue the auto-chain of messages by creating new blocks and linking them together. To communicate, you need to go to the previous block, add the "Delayed call" action and specify the time after which the next block (action) in the funnel will be performed.

Now let's associate our keyword with the keyboard and check the autosubscription.

We select a topic (a group of subscribers) on which we want to make a newsletter. You can select multiple topics at the same time. If you do not select any, the newsletter will be sent to all your subscribers. For example, I choose a test group that I created purely for myself, in which I am the only subscriber. I also recommend that you do this for initial testing.

I am writing a message where I propose to receive a gift.

By the way, another novelty is the ability to disable link previews (that is, a picture that is pulled up by a link in a message). This is not always appropriate. This was introduced due to the fact that when adding an unsubscribe link, a clickable image was pulled up, which attracted all the attention. Now this can be turned off.

Here it is important for the very first time to go to the link indicated in the hints and enable the features of bots in the settings, otherwise the keyboard will not work!

Also, check the box "Hide the keyboard when pressed" - this means that when you click on the button, it will disappear.

You can add one or more buttons by clicking on the plus sign. To change the color of the button and the text on it, just click on it with the mouse.

For example, I will make two buttons - blue and green. On one I will write the key phrase “I want a gift”, and on the second “No, thank you” (after all, there should always be a choice).

This is what this message looks like with a keyboard in a subscriber's personal account.

I click on the "I want a gift" button and I immediately receive it. That is, there was an auto-subscription to the topic, and the funnel was activated. That's how it works.

By the way, this can also be used like this - for example, we subscribe to one mailing list, and unsubscribe from another. To do this, simply add the appropriate action to the first block of the auto funnel.

You can also add several buttons (4-5) to segment subscribers into different topics (according to their preferences). That is, to conduct a survey ...

You can watch the visual lesson to the article:

Thank you for your attention and I will be glad to your comments!

Sincerely, Victoria Karpova

New functionality for VK bots - quick response buttons or keyboard.

IMPORTANT! More recent version of the article

Our team of "bot painters" immediately became interested in this innovation and began to study the official API to tell you and show you detailed instructions to create a bot using the keyboard. In the course of this article, you will get a bot, whose work you can see in our group GameTips in VK. You can also join the VK community conversation, where they can help you with a problem that has arisen.

Create and set up a community

After creating a community in VK, follow this path:
"Community Management" → "Messages" and turn on community dialogs. Now in the "Settings for Bot" submenu, enable "Bot Features" and the "Get Started" button.

We will write using Callback api (sends each action in the community separately to the server). Therefore, it should also be configured. Go to
“Community Management” → “Working with API”. For the bot to work, you need to register an access key. Click "Create Key" and select the necessary access rights, this bot only needs the rights to messages. We confirm the phone number and save the access key somewhere. Now go to the Callback API tab. Enter your server name and select latest version API(on this moment it is 5.80, and it is with it that the bot presented below will work 100%). In the "Types of requests" tab, select only incoming messages.

Server Tuning

Now you will need a server to host your bot. you can use free hosting, for example 000webhost.

If you use cheap/free hosting, then cURL will most likely be disabled on them (you will not be able to send media files to the bot, only text), and it cannot be enabled. Everything is fine with 000webhost, you can use it. If you have your own server or a good one bought, then you need to connect cURL for the bot from our example to work properly.

How the Callback API and keyboard work

I will spend brief digression how everything works. The callback API sends any event that occurs in a JSON group to your server. Full list events can be viewed in the “Callback API” tab → “Event types”. This is how the JSON request looks like when the user sends a message, in this case he clicked on the button:

("type":"message_new","object":("date":1529668584,"from_id":89846036,"id":1522,"out":1,"peer_id":89846036,"text":"Gold fish","conversation_message_id":305,"fwd_messages":,"important":false,"random_id":0,"attachments":,"payload":"(\"animals\":\"Goldfish\")" ,"is_hidden":false),"group_id":101461081)

There are several interesting fields that can be processed: user id, message text (text), payload of the button (payload).

Messages are sent to the user using the method messages.send. If you send a keyboard, then after all standard parameters you add parameter keyboard which contains json of buttons, this is what it looks like:

Keyboard: ( "one_time": false, "buttons": [ [( "action": ( "type": "text", "payload": "(\"button\": \"1\")", " label": "Red" ), "color": "negative" ), ( "action": ( "type": "text", "payload": "(\"button\": \"2\")" , "label": "Green" ), "color": "positive" )]

Working with the library

For the bot to work, we use a self-written PHP library. (If the link does not work, then here is the archive) you can find the documentation for the library and download the library itself. Here is a short listing ready-made functions to write a bot, look for more details at the link above. If you want to know about changes in the library, then write at least one message to our bot in VK, through which we will notify you of changes.

$vk = new vk_api(vk_key, version_api) — bot initialization. Parameters: community key (vk_key), API version (version_api).

sendMessage(id, text) - function for sending messages to the user. Parameters: user id(id), message text(text).

sendImage(id, patch) is a function to send images. Parameters: user id (id), path to the image (patch).

sendButton(id, text, buttons, one_time) — function for sending a message with buttons. Parameters: user id (id), message text (cannot be empty) (text), array with buttons (buttons), optional one_time parameter, false by default, if set to true, the keyboard will hide after pressing any button.

request(method, array_arguments) is a universal function for working with methods. Parameters: method is the name of the method from the official api, array_arguments is an array of parameters.

sendOK() - Beta function. Used instead of echo "ok", it helps in cases where the script runs for a long time, and the bot starts repeating messages several times.
IMPORTANT: if you use this function, you will not see any error output. During debug, replace with echo "ok"

Full bot code in PHP

Now let's move on to the actual code, where almost every line is commented.
This code is supported on PHP 5.6+
In the CONFIG block, specify your community access key, server confirmation key, and the API version of your choice.

"Fish"], "What are they?", "blue"]; //Code for the "Fish" button const BTN_BACK = [["command" => "start"], "<< Назад", "red"]; // Код кнопки "<< Назад" const BTN_SALMON = [["animals" =>"Pink_salmon"], "Pink salmon", "white"]; // Code for the "Pink salmon" button const BTN_GOLDFISH = [["animals" => "Goldfish"], "Goldfish", "blue"]; // Code for the "Goldfish" button const BTN_PLOTVA = [["animals" => "Plotva"], "Roach", "green"]; // Code for the "Roach" button $vk = new vk_api(VK_KEY, VERSION); // creating an instance of the api class, accepting the api key and version $data = json_decode(file_get_contents("php://input")); //Receives and decodes JSON coming from VK if ($data->type == "confirmation") ( //If vk asks for a key exit(ACCESS_KEY); //End the script by sending the key ) $vk->sendOK(); //Tell vk we received a callback if (isset($data->type) and $data->type == "message_new") ( //Check if this is a message from a user $id = $data->object- >from_id; //Get the id of the user who wrote the message $message = $data->object->text; if (isset($data->object->peer_id)) $peer_id = $data->object->peer_id; // Get the peer_id of the chat where the message came from else $peer_id = $id; if (isset($data->object->payload))( //get the payload $payload = json_decode($data->object->payload, True ); ) else ( $payload = null; ) if (isset($payload["command"]) or mb_strtolower($message) == "start") ( //If the start button is pressed or<< назад $vk->sendButton($peer_id, "Do you want to see the fish?", []); //Send the button to the user ) else ( if ($payload != null) ( // if payload exists switch ($payload["animals"]) ( //See what's in the payload buttons case "Fish": //If it's a Fish $vk->sendButton($peer_id, "Here you go, choose", [ //Send buttons to user , ]); break; case "Pink_salmon": //If it's Pink salmon $vk->sendMessage($peer_id, "Keep your pink salmon!"); //send the message $vk->sendImage($peer_id, "img/pink_salmon.jpg"); //send the picture break; case "Goldfish": //If it's a Goldfish $vk->sendMessage( $peer_id, "She will grant your wishes..."); $vk->sendImage($peer_id, "img/goldfish.jpg"); break; case "Plotva": //If it's a Roach $vk->sendMessage( $peer_id, "Oops, looks like the picture got mixed up)"); $vk->sendImage($peer_id, "img/plotva.jpg"); break; default: break; ) ) ) ) ?>

Now you know how the code works, and you can customize it for yourself.

Let's start!

Upload your script and library to the server. Now go to the settings in the Callback API tab, enter the path to your script in the address field and click confirm. If you did everything right, a green check mark will appear next to the address.

FAQ:

Question: Nothing works at all!
Answer: It means they screwed up somewhere. Re-read the article carefully again, and check if you have done everything. Any step to the left can lead to an error...

Question: Everything works for me, but pictures are not sent.
Answer: Check if you have added the img folder with images. Also, you may be using a server where cURL is not supported.

Question: I changed the version to 5.78 or whatever. Nothing works for me.
Answer: Use other api versions than 5.80 at your own risk. For example, on version 5.78, other variable names come from VK (for example, instead of object-> text, object-> body goes), so the script crashes. Look for all api changes



Loading...
Top