Veriqa.ChannelAdapter.Ru.Vk 0.7.3

Prefix Reserved
dotnet add package Veriqa.ChannelAdapter.Ru.Vk --version 0.7.3
                    
NuGet\Install-Package Veriqa.ChannelAdapter.Ru.Vk -Version 0.7.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Veriqa.ChannelAdapter.Ru.Vk" Version="0.7.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Veriqa.ChannelAdapter.Ru.Vk" Version="0.7.3" />
                    
Directory.Packages.props
<PackageReference Include="Veriqa.ChannelAdapter.Ru.Vk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Veriqa.ChannelAdapter.Ru.Vk --version 0.7.3
                    
#r "nuget: Veriqa.ChannelAdapter.Ru.Vk, 0.7.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Veriqa.ChannelAdapter.Ru.Vk@0.7.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Veriqa.ChannelAdapter.Ru.Vk&version=0.7.3
                    
Install as a Cake Addin
#tool nuget:?package=Veriqa.ChannelAdapter.Ru.Vk&version=0.7.3
                    
Install as a Cake Tool

VK channel adapter

The vk channel lets your users sign in and confirm operations through the bot of a VK community. The sign-in link opens the dialog with your community, the bot asks the question with two buttons, and the answer turns into a receipt in the same dialog. A message from a community is visible on vk.com, in the VK app and in VK Messenger, since they all use the same messaging system.

The adapter comes in two forms with the same behavior in VK:

Form What it is When to choose it
Package Veriqa.ChannelAdapter.Ru.Vk Registered in the .NET process that hosts Veriqa with AddVk() One community per installation
Container image The shared host of this repository with the VK package, connected to Veriqa as an HTTP channel Several communities, one per tenant, or VK secrets kept outside the Veriqa process

How sign-in works

  1. The sign-in page shows the VK button and a QR code. Both lead to https://vk.me/<short name>?ref=auth_<transaction>, or to https://vk.com/write-<community id>?ref=auth_<transaction> when the community has no short name.
  2. The user opens the dialog and taps Start, or writes any message in a dialog that already exists. VK delivers the message with the ref value, and the sign-in starts. After the first sign-in the dialog keeps a Sign in button under the input field, so the next time the user only taps it: VK attaches ref to the press as to a typed message.
  3. The bot sends the question with the Confirm and Decline buttons. The buttons carry the decision, the transaction and the language of the question; the adapter takes the sender from the event fields that VK sets.
  4. After the answer the progress indicator on the button goes out, and the question is edited into the receipt without buttons. When the edit is not possible (the question is too old, it was deleted, or Veriqa did not keep a reference to it), the receipt arrives as a new message. If your installation shows receipts as new messages, the question keeps its text but loses its buttons, and the receipt arrives below it.

If ref does not arrive, the sign-in page shows a fallback code. The user sends the code to the community as a message, digits only, and the sign-in goes on the same way. Spaces and dashes between the digits are allowed. The code also works in a dialog opened by another link.

Hint on the sign-in page. VK shows Start only in a new dialog, and Continue after the first sign-in, so the page says what to press. compose.yaml sets the text in two places: Veriqa:ChannelDisplay:Hints:vk for the panel of the channel and Veriqa:MessageTemplates:hop-channel-hint:BySurface:core-page:ByChannel:vk:Templates for hop mode. The package form sets the same keys in the configuration of your application.

A confirmation of an operation created by your backend goes the same way: the question goes to a user the channel already knows.

Consent of the user. A community can write to a user only after the user has written to it first or has allowed messages from it. Signing in by the link or by the code gives that consent. When VK refuses the question because the user has not allowed messages (error 901), has blocked the community (900) or forbids messages in the privacy settings (902), the transaction ends at once with that reason instead of waiting for its expiry.

Identity and claims. The sub of the user is vk:<VK user id>. The adapter reads the profile with users.get only when a sign-in starts. The profile gives name, given_name, family_name, preferred_username and picture. If the profile cannot be read, the sign-in goes on with the user id as the name. Confirm and Decline do not read the profile again: Veriqa uses the one read at the start. VK sends the language of the client with a message, and it picks the language of the question. The channel passes as the locale claim the language of the client at the start, or the language of the question carried by the buttons if the start gave none, when it is one of ru, uk, be, en, es, fi, de and it. The bot of a community receives no email and no phone number verified by the platform, and the adapter writes no RawMetadata, so the channel passes no personal data beyond the claims above.

After the sign-in

Once a sign-in is confirmed, the channel can send the user a welcome message, a menu or a link to continue with — the WelcomeMessage, Menu and Redirect actions. Both forms of the adapter perform them. You choose the action that follows a sign-in in the Veriqa:CompletionBehavior section of the Veriqa settings.

  • WelcomeMessage is a plain text greeting.
  • Menu and Redirect are a message with an inline keyboard under its text. Redirect has one link button, and Menu has the menu items. A link item opens its address; a callback item passes its value to the IMenuItemPressHandler registered in the application that hosts Veriqa. Without such a handler, Veriqa leaves the callback items out and still sends the link items of the same menu.
  • The adapter answers a press of a callback item itself, so the progress indicator on the button goes out.

The adapter checks the VK limits before sending. A keyboard holds up to 10 buttons, and the rest are left out; up to 6 buttons go one per row, and 7 to 10 go two per row. A label longer than 40 characters is cut and ends with "…". A callback item is drawn only when its payload fits in 255 characters. That leaves 238 characters for the value of the item if it consists of Latin letters, digits, - and _. Some other characters take more room: a letter outside ASCII takes six, and most emoji take twelve. Keep callback item values short and use Latin letters. A message left with no buttons is not sent. Every item left out and every label cut is logged as a warning.

Setting up the community

In the management of your VK community:

  1. Turn on Community messages and, under Bot features, turn on the bot features and the Start button.
  2. Create an access key with the messages right (Working with API → Access keys).
  3. Choose how the community delivers events:
    • Long Poll API (no public address needed): turn it on, choose API version 5.103 or later, and enable the message_new and message_event events;
    • Callback API: add the server address, set a secret key, note the confirmation string, choose API version 5.103 or later, and enable the message_new and message_event events. The server address is the route of the adapter (see below).

The adapter does not change these settings itself.

Community settings

Key Secret Required Meaning
AccessToken yes yes Access key of the community with the messages right
GroupId no yes Numeric id of the community
ScreenName no no Short name of the community: the vk.me link and the chat name shown on the sign-in page (@<short name>)
ApiVersion no no, 5.131 VK API version of the method calls, 5.103 or later
ApiBaseUrl no no, https://api.vk.ru/method/ VK API address; change it only to point at a test double
UpdateMode no no, LongPoll LongPoll or CallbackApi
CallbackConfirmationCode no with CallbackApi Confirmation string from the Callback API settings
CallbackSecret yes with CallbackApi Secret key from the Callback API settings
SignInButton no no, true Whether the receipt and the plain replies of the bot carry the persistent keyboard with the sign-in button. Turn it off when a bot of your own works in the community: the dialog holds one keyboard, and ours would replace yours. The button reads Continue in the language the adapter last learned from the user: from a message, a button press or a question sent to them. The adapter keeps it in memory, so after a restart, or a day with no events from the user, the label is in English until the user writes again

A missing required key or a malformed value stops the host at start. The message names the channel, the tenant and the key, never the value. Keep AccessToken and CallbackSecret in environment variables or a secret store, not in appsettings.json.

Package form

dotnet add package Veriqa.ChannelAdapter.Ru.Vk
using Veriqa.ChannelAdapter.Ru.Vk;

authServer.AddChannelAdapters(adapters => adapters.AddVk());

The settings live in the section Veriqa:Channels:vk, together with two keys every channel has:

Veriqa__Channels__vk__Enabled=true
Veriqa__Channels__vk__InboundVerification=outbound_fetch
Veriqa__Channels__vk__AccessToken=<access key>
Veriqa__Channels__vk__GroupId=<community id>
Veriqa__Channels__vk__ScreenName=<short name>
  • Enabled is false by default. While it is false, the Long Poll loop does not run, the Callback API route answers 404, and the community settings are not checked.
  • InboundVerification follows the update mode:
UpdateMode InboundVerification Why
CallbackApi shared_secret The secret field of every event is compared with CallbackSecret in constant time
LongPoll outbound_fetch There are no inbound requests: the adapter fetches the events itself

With CallbackApi, set the server address in VK to https://<your Veriqa host>/api/channels/vk/webhook. The route answers the address check with the confirmation string and every authentic event with ok, as VK expects.

The channel answers in the dialog when a sign-in link has expired and when a code does not match any sign-in. It does not answer a message that names no sign-in: a bot of your own may work in the same community, and such messages are for it.

Container image

The image runs the shared host with the VK package. Veriqa connects to it as an HTTP channel named vk, and the VK secrets stay in the host. The host listens on two ports: calls from Veriqa on one, VK traffic (the Callback API) on the other. Publish only the platform port; keep the calls port inside your private network.

Host settings

Key Required Default Meaning
ChannelHost:VeriqaBaseUrl yes — Absolute address of Veriqa, where the host posts events
ChannelHost:Channels:vk:TransportSecret yes — Transport secret, equal to Http:TransportSecret of the Veriqa registration
ChannelHost:Channels:vk:PreviousTransportSecret no — Previous secret while a rotation is in progress
ChannelHost:CallsPort / ChannelHost:PlatformPort no 8080 / 8081 Port of the calls from Veriqa / port of the VK traffic
ChannelHost:IdempotencyRetention no 01:00:00 How long the answer to a call is kept for a repeated call
ChannelHost:TransactionRetention no 01:00:00 How long the host remembers which tenant a transaction belongs to
ChannelHost:EventDeliveryBudget no 00:00:10 Time budget of the retries when an event is posted to Veriqa
ChannelHost:PlatformRateLimit:PermitLimit / :Window no 100 / 00:00:01 Request limit of the platform routes
Channels:vk:* yes — Community settings of the default tenant (see the table above)
Tenants:{tenant}:Channels:vk:* no — Community settings of a tenant; they replace the default section as a whole

The host has no Enabled key for VK: the channel works while the host runs. To turn it off, set Veriqa__Channels__vk__Enabled=false on the Veriqa side or stop the container.

A tenant without its own section uses the default community. With CallbackApi, the server address in VK is https://<public address of the platform port>/api/channels/vk/webhook for the default section and …/api/channels/vk/webhook/<tenant> for a tenant with its own section.

Veriqa settings

Veriqa__Channels__vk__Enabled=true
Veriqa__Channels__vk__InboundVerification=outbound_fetch
Veriqa__Channels__vk__Http__BaseUrl=http://vk-adapter:8080/
Veriqa__Channels__vk__Http__AllowInsecureHttp=true
Veriqa__Channels__vk__Http__TransportSecret=whsec_<base64 of 24 to 64 random bytes>
Veriqa__Channels__vk__Http__DisplayName=VK
Veriqa__Channels__vk__Http__Capabilities__SupportsInChannelConfirmation=true
Veriqa__Channels__vk__Http__Capabilities__SupportedMessageKinds__0=plain_text
Veriqa__Channels__vk__Http__Capabilities__SupportedMessageKinds__1=claim_form_link
Veriqa__Channels__vk__Http__Capabilities__SupportedMessageKinds__2=action_buttons
Veriqa__Channels__vk__Http__Capabilities__SupportsMessageUpdate=true
Veriqa__Channels__vk__Http__Capabilities__DeliversOutcomeNotice=true
Veriqa__Channels__vk__Http__Capabilities__ProvidesRecipientLocale=true
Veriqa__Channels__vk__Http__Capabilities__RendersEmoji=true
Veriqa__Channels__vk__Http__Capabilities__SupportedCompletionBehaviorActions__0=WelcomeMessage
Veriqa__Channels__vk__Http__Capabilities__SupportedCompletionBehaviorActions__1=Menu
Veriqa__Channels__vk__Http__Capabilities__SupportedCompletionBehaviorActions__2=Redirect
Veriqa__Channels__vk__Http__Capabilities__CodeStart__LinkCarriesTransaction=true
Veriqa__Channels__vk__Http__StaleLinkReplyText="This sign-in link has expired or is no longer valid. Return to the application and start the sign-in again."
Veriqa__Channels__vk__Http__UnmatchedCodeReplyText="This code did not work. Check the code shown on the sign-in page and send it again, or open the sign-in page again to get a new one."
Veriqa__Channels__vk__Http__UnaddressedReplyText="To keep sign-ins secure, this chat answers only a sign-in started from the sign-in page. Send the code shown on that page here, or scan its QR code again."
  • InboundVerification follows UpdateMode of the host, as in the package form: shared_secret for CallbackApi, outbound_fetch for LongPoll.
  • SupportedMessageKinds and SupportedCompletionBehaviorActions repeat what the package declares in code: the button of the claim completion form, messages with buttons and the three actions after a sign-in. Veriqa adds None to the actions itself. If Menu or Redirect is listed without action_buttons, Veriqa does not start.
  • The three reply texts are Natural Keys of the core, so Veriqa translates them into the language of the user. UnaddressedReplyText answers only a press of the sign-in button without a link. Any other message that names no sign-in stays unanswered and is left to your own bot.
  • The host translates the label of the sign-in button with the locale files of the image, locales/<language>.json; the image ships the Russian file. In other languages the label stays in English.
  • Http:BaseUrl points at the calls port of the host. It must be an https address unless Http:AllowInsecureHttp is true, which is meant for a private network such as a Compose network, as in the example.
  • Leave Http:Tenant unset: the fallback code works only for a registration without an owner tenant.

Limitations

  • The package form serves one community. It serves the default tenant only. To serve a community per tenant, use the container image.
  • The container image does not pass the community name. The chat name on the sign-in page is not shown; the name of the channel button comes from Http:DisplayName.
  • The fallback code needs a registration without an owner tenant in the container image.
  • The channel does not ask for a phone number. VK keyboards have no button that shares a contact. VK returns the mobile_phone field of users.get to Standalone apps only. home_phone is an optional profile field: the user fills it in and may hide it, and the platform does not verify that number. If your application needs a phone number, Veriqa asks for it in the steps that collect missing claims, outside the channel.
  • A community token allows up to 20 requests per second. When VK asks for a captcha or reports too many requests, sending fails and the core retries; a captcha cannot be solved on a server, so plan the load on the community.

Live run findings

The adapter was run against a test VK community in the Long Poll and Callback API modes, with the VK app on a phone and vk.com on a desktop.

  1. ref arrives in full in a dialog that already exists, but only with the user's next message. VK shows the Start button only in a new dialog. That is why the dialog keeps a Continue button after the first sign-in: VK attaches ref to a press of it, so a repeated sign-in needs no typing.
  2. client_info.lang_id uses the same numbering as the lang parameter of VK API requests. A client in English sends 3, and the question is asked in English. The VK mobile app applies a language change in full only after a restart.
  3. A press of a callback button arrives as message_event from the VK app and from vk.com on a desktop. The m.vk.com and VK Messenger clients were not checked.

What to keep in mind when setting up:

  • A dialog that is already open. Opening a sign-in link while the dialog with the bot is open may not show the Continue button. The adapter cannot affect this. Any message the user writes carries the ref and starts the sign-in.
  • The button on vk.com. vk.com may collapse the keyboard: the Continue button then opens with the icon next to the emoji button in the message box. A message the user writes starts the sign-in too.
  • Callback API with no event types. VK confirms the server address and shows it as working even when no event type is switched on. No events then arrive, and the sign-in expires. Make sure message_new and message_event are switched on.
  • https with an untrusted certificate outside Compose. If the host sends events to Veriqa over https with a certificate its process does not trust (the localhost dev certificate, for example), delivery fails with UntrustedRoot. After four attempts the event is lost, and the sign-in page waits until it expires. Use a Veriqa address with a trusted certificate, or http in a private network as compose.yaml does.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.3 86 11/10/2026