Program.cs
samples/dotnet/custom-channel — an adapter library plus a
host that wires it up.
Not writing .NET, or running the standard Veriqa image you do not rebuild? Write the adapter as a
service of its own in any language and plug it in by configuration — see
Build a channel in any language. An external adapter written in .NET is
samples/dotnet/custom-channel-id-providers — sign-in with Google, Apple and HUAWEI ID accounts.
1. The adapter project
Reference the contracts package:Acme.Chat.Adapter.csproj
Veriqa.Core.Contracts is MIT-licensed and is the free SPI. An adapter that only implements
IChannelAdapter needs no other Veriqa package; samples/dotnet/custom-channel/adapter is one. The
sections on templates from the core,
polling and working per tenant also need the server
core package Veriqa.Core.ChannelAdapter (MPL-2.0) in the adapter project. What each package
contains is listed in its README (also shown on its NuGet page).
The NoWarn line is needed because two types are marked [Experimental("VERIQAEXP0001")]:
ChannelInboundResult, the return type of ProcessInboundEventAsync, and
ConfirmationPromptContext, the type of a parameter of SendConfirmationPromptAsync. Such a type may change in
a minor version, and the compiler reports its use as an error until your project accepts that. The
contracts package README explains the marker.
2. Implement IChannelAdapter
Three members carry the flow; the rest are outbound helpers your platform may or may not have.
ValidateWebhookAsync — the security gate
Runs before your processing code — though not before everything: the request first passes through
the tenant demultiplexer, which answers 403 on an unknown tenant segment without calling your
adapter at all, and only then does Veriqa read the body and build the envelope. Return false and the request is answered with 403 and never
reaches your processing code; an exception thrown here is treated exactly like a rejection (logged,
answered 403), so a broken signature parser can never surface as a 500. Verify the platform’s
signature here, in fixed time, and reject by default:
Declare the inbound verification level of your channel — and document it
YourValidateWebhookAsync returning success tells the core only that “a check ran and passed”.
What the check was, the core does not know and cannot derive: it holds no closed list of
channels, and a statement the adapter makes about itself would guarantee nothing — the declaration
comes from whoever carries the risk: the integrator.
So your channel’s section carries the same required InboundVerification key the shipped
channels do:
appsettings.json
signature (the body is signed with a platform key), shared_secret (a secret
presented by the incoming request), outbound_fetch (there are no incoming requests, an outgoing
one fetches the events) and none (authenticity is not verified); the full description is in the
configuration reference.
For a channel plugged in the way this guide shows, the key is required but not checked at
startup. The check that refuses to start a host when an enabled channel has no value
walks the channels declared at core level — the very set the core builds its enabled channel list
from. An
AddChannel call registers the adapter and its route, not a core-level declaration, so
such a channel is not in that set — until you register one yourself, which
working per tenant has you do, and from that point the check covers your
channel like a shipped one. The value is still read by the same resolver and still reaches
the audit record, so a missing declaration shows up as an empty attribute in the audit log rather
than as a refusal to start.shared_secret because the
validation shown above compares a header with a configured secret; a channel that fetches its events
with an outgoing request of its own declares outbound_fetch.
ProcessInboundEventAsync — the raw body in, an intent out
Both methods receive the same envelope, ChannelInboundRequest: the HTTP method, the raw
bytes of the body, the headers and the query parameters (names compared case-insensitively,
repeated values joined with ", "). Bytes really are bytes: a signature is computed over exactly
those, with no decoding step standing between the platform and your HMAC. Veriqa does not interpret
the body format — JSON, form-encoded, XML, whatever your platform sends; parsing it with your own
serializer options is your job.
ChannelAuthStartResult (the user reached your platform from the deep link),
ChannelAuthStartByCodeResult (they sent the code shown on the sign-in page — see
Start by a code),
ChannelAuthConfirmResult / ChannelAuthDeclineResult (they pressed a button in your channel),
ChannelPhoneSharedResult / ChannelPhoneStepActionResult (answers to a
phone number request), ChannelUnaddressedResult or
ChannelUnrelatedResult.
The last two are close and easy to confuse. ChannelUnaddressedResult is a direct message to your
bot from a sender you have already vetted — a bare start command, free text — that names no
transaction; it carries the sender, so Veriqa can answer it when the registration declares a reply
(UnaddressedReplyText below). ChannelUnrelatedResult is everything Veriqa has no business
answering: a group chat, a callback of somebody else’s button, an event that failed your own sender
check. It carries no sender, and nothing is sent back.
Next to it sits a synchronous bool OwnsInboundEvent(ChannelInboundRequest request) — a cheap
answer to “is this a Veriqa update?” before anything is parsed. You need it when you own the
channel transport and hand updates out between your own bot and Veriqa: no event gets parsed twice
(this and the other ways to share a bot — You already have a bot).
A default implementation is already provided — it looks for any CallbackDataPrefixes marker (vq_confirm_,
vq_decline_, vq_phone_skip_, vq_phone_cancel_, vq_menu_, auth_) in the raw bytes of the
body — so implementing the member is optional. vq_menu_ marks a button of the
post-completion menu: what follows it is a value
from the deployment’s configuration, not a transaction identifier. The
answer is one-sided: an event from a Veriqa button or deep link always answers true, but true
on its own does not promise the event is actionable — the search is substring-based and auth_
carries no vendor prefix, so the word oauth_ in a user’s message answers true as well. Override
the member with a precise check of your own wire format if a false positive costs you something.
Capabilities — what your channel can do
A channel declares what it can do as a fact, not as a stubbed-out operation: one
ChannelCapabilities object states whether the channel can confirm a sign-in inside itself
(SupportsInChannelConfirmation), which content kinds it accepts, whether it can update its own
message (SupportsMessageUpdate), whether it shows the user where a transaction stands
(DeliversOutcomeNotice), whether it supplies the recipient’s locale (ProvidesRecipientLocale)
and whether it renders emoji (RendersEmoji). Veriqa never calls what a channel has not declared —
so “cannot” is written once, in one place:
About confirmation you state exactly one fact: your own ability to ask the question and receive the
answer inside the channel. How you do that (inline buttons, a web view inside the messaging app,
anything) is your business — the core neither knows nor asks. An adapter never names a surface of
the core: whether a confirmation is needed at all is the core’s policy, and the page that asks
the question when the channel cannot is the core’s own. The fact defaults to “cannot”: an already
compiled adapter that knows nothing about it will not be handed a confirmation
it cannot display.
RendersEmoji decides which of the two in-channel wordings a terminal receipt is addressed with, and
that is the channel’s rule rather than the render point’s. true gets the wording with emoji;
false and leaving it out get the plain one. The core keeps no list of channels for this: the
messaging app adapters it ships declare true the same way.
Outbound operations
SendMessageAsync(ChannelMessage) delivers a message and returns a reference to what was sent
(ChannelMessageRef) — or null on success when the channel has no addressable reference.
SendConfirmationPromptAsync sends the confirmation prompt and returns the same kind of reference;
Veriqa stores it, not you. ReportOutcomeAsync(TransactionOutcomeNotice) states the intent “show
the user where this transaction stands” — which platform calls that takes is your decision,
and it is called only if your channel declared DeliversOutcomeNotice. The notice also carries
DisplayIntent — where the deployment wants the receipt to appear: in place of the message that
asked the question (ReplacePrompt, the shipped value) or as a message of its own (NewMessage).
Honoring it is optional: your platform may have nothing editable to replace, and showing the outcome
the only way it allows is not a failure — nothing is logged as an error and the result you return
does not change.
The notice is terminal in every case but one. Outcome is confirmed, declined, expired or
failed when the transaction has ended, and awaiting_claims when the sign-in is confirmed and
waits for the details your application still asks for; IsTerminal tells the two apart. Show that
state the way you show a receipt: answer the press, put StatusText where the question was. A
sign-in that then ends confirmed, declined or failed is reported again, always as a new message.
The state is reported for the press that confirmed the sign-in. A press made later, while the
sign-in is still waiting, brings the same notice only to a channel that declared
SupportsMessageUpdate. A channel that cannot edit its messages is not called for it: the state
would arrive as a new message under the request of the step in progress and could take that
request’s buttons away. Instead, while the sign-in waits for the phone number, such a channel is sent
the phone number request once more: on many platforms the press itself lands in the chat as a
message from the user and removes the buttons of the request, and the repeated request brings them
back. If your platform expects an answer to every button press, give that answer yourself when you
receive the event.
An expiry is reported for every transaction started from your channel, whether the question was
asked in the chat or not. PromptMessage is set only when the question went into the chat, your
channel declared SupportsMessageUpdate and returned a reference from the prompt. Without it —
the question was asked on the web page, the sign-in needed no question, or there was no reference
to keep — show StatusText as a new message. The only expiry that goes unreported is one whose
record Veriqa no longer has: by default it is kept in the memory of the instance that handled the
start (channel stores).
Honoring NewMessage is two steps rather than one, and the second is the one easy to miss:
deliver the receipt as a new message and take the buttons off the message that asked the question,
leaving its wording alone. Skip it and the user is left looking at a settled transaction with a live
button under it — a question that answers nothing and still invites a press. Take the buttons away
with whatever operation changes a message’s buttons without rewriting its text; if your platform has
no such operation, leave the question untouched rather than blanking its text — an unhonored intent
is not a failure, a question that lost its wording is one. Whether the buttons came off decides
nothing about the result you return: the delivery of the receipt does.
Prompt and link text — take the templates from the core
The integrator sets the wording of messages in Veriqa:MessageTemplates for the installation, a tenant or an application. Your adapter gets that wording from the core throughIChannelMessageTemplates. It needs two templates: the confirmation prompt
(MessageKinds.ConfirmationPrompt) and the text a deep link pre-fills in the user’s message
(MessageKinds.DeeplinkPrefill). You need the second one only if your platform can carry text in a
link. If your adapter does not ask the core for the template, users see your default text even when
the integrator has set a different one.
The core registers two services: IChannelMessageTemplates and IConfirmationPromptLocalizer,
which translates texts into the recipient’s language. With AddChannel<TAdapter>("acme-chat") the
container injects both into your adapter’s constructor. If you register the adapter with a factory,
pass them to the constructor along with its other parameters:
Program.cs
this), the message kind and the transaction id to ResolveAsync, and
for the link text, the request its GetDeepLinkAsync received. The core works out the rest: it takes the channel from the ChannelType of the adapter you passed, sets
the surface to in-channel, and takes the configuration level (installation, tenant or application),
language, time zone and application name from the transaction. Your adapter still builds the message: it renders the
template, adds buttons and markup, and keeps within the platform’s limits.
AcmeChatChannelAdapter.cs
- The prompt.
ConfirmationPromptRendererrenders it in the recipient’s language taken frompromptContext. - The link text. To get its template, pass
ResolveAsyncthe request yourGetDeepLinkAsyncreceived:ResolveAsync(this, MessageKinds.DeeplinkPrefill, request, cancellationToken). The core then takes the purpose of the link into account as well: it returns the wording the integrator set for that purpose, or the wording of the channel if there is none. Render the text withMessageTextRenderer.RenderinMessageRenderMode.PlainTextmode and passLocaleandTimeZonefrom theResolveAsyncresult. PutApplicationNameinto theSlotNames.Appslot when it is set. The result also carriesBrandName, the brand name of the sign-in page. The channels built into Veriqa put it into the{brand_name}slot translated into the recipient’s language; an adapter of your own can put it intoSlotNames.BrandNameonly as it is, untranslated. Put whateverProcessInboundEventAsyncuses to recognize the transaction into theSlotNames.Codeslot. The shipped template for a channel of your own isSend this message to sign in., orSend this message to continue.for a confirmation, and has no{code}slot, so keep the transaction id in the link itself. The integrator can still declare a template with{code}for your channel (deeplink-prefill:BySurface:in-channel:ByChannel:acme-chat, or…:ByLinkPurpose:hop-qrfor a single purpose), and the same address underByType:confirmationfor a confirmation. If no step of the template states thePlainedition,Renderreturnsnull. - Failure. The template may be unavailable: the message kind is not configured, or the
transaction store did not respond.
ResolveAsyncthen returns an error with themessage_send_failedcode, and the core has already logged it at theErrorlevel and counted it inveriqa.channel.template.failures(metrics). Return that error fromSendConfirmationPromptAsyncand do not send the prompt. What to do with the link is up to you: the built-in WhatsApp channel, for example, leaves only the sign-in code in the text.
Phone number on request
A channel that can give the user’s phone number declares it inCapabilities.PhoneNumber: how it
gets the number and whether the platform proves that the number belongs to the sender. What the
core does with the number — when it asks, how long it waits, what the token carries — is described
in Phone number.
PhoneNumber out means PhoneNumberCapability.None: the channel gives no number, and a
sign-in that requires one does not offer the channel.
With Automatic you put the number, in E.164, into the snapshot’s PhoneNumber and say whether it
is proven in PhoneNumberVerified (left null, the claim goes out as false).
With OnRequest the core calls SendMessageAsync with a message of kind PhoneNumberRequest:
Text is the request, and PhoneNumberRequest carries the label of the share button
(ShareButtonLabel), the second action (SecondaryAction — Skip or CancelSignIn) with its label
(SecondaryButtonLabel) and the TransactionId. The texts arrive localized. Show the platform’s
“share contact” button and the second button next to it: a button with a payload carries
CallbackDataPrefixes.PhoneSkip or CallbackDataPrefixes.PhoneCancel followed by the transaction
identifier, and a keyboard button that can only send text sends its label. Return the answers as:
- a shared contact —
ChannelPhoneSharedResultwith the number in E.164 with the leading plus and the sender’s snapshot. Normalizing the number to E.164 is the adapter’s job: platforms rarely promise that format, and the core counts a number outside it as absent.E164PhoneNumber.TryNormalizefromVeriqa.Core.Contractsdoes that. When the contact fails your platform’s ownership check, setOwnershipRejected = true: the core does not take the number and asks again. A contact names no transaction — the core finds the request by the chat; - the second button with a payload —
ChannelPhoneStepActionResultwith the parsedTransactionIdandAction; an identifier that does not parse makes the eventChannelUnrelatedResult; - the second button as plain text —
ChannelUnaddressedResultwithText: the core compares it with the label it sent into that chat.
ReportOutcomeAsync
carries PhoneRequestMessage —
the reference your SendMessageAsync returned for the request. Take down what the request offered,
its buttons or its input keyboard, by the means of your platform. The reference is absent when you
returned none, and a notice of awaiting_claims never carries it: the step is still running.
If you route updates with OwnsInboundEvent, override it: the default recognizes the button
markers, but a shared contact carries none. Answer true for a contact event and keep the marker
check with CallbackDataPrefixes.ContainsAnyMarker(request.Body.Span) — the default body of an
interface member cannot be called from your class. A button that sends plain text carries no marker
at all, so in this mode its press reaches your own bot: an Optional number is then skipped when
its window runs out, and a Required one waits until the transaction expires. The built-in Telegram
adapter has the same limitation.
Claim names — which are yours and which belong to the core
Everything you know about the user goes into the typed fields of the snapshot: name, username, locale, phone and whether it is proven (PhoneNumberVerified), email and whether it is verified
(EmailVerified) — each has its own field. The core issues the claims from them; email_verified
goes out only next to a non-empty email, phone_number_verified only next to a non-empty phone
number. Free-form
names live in AdditionalClaims, and there the name groups of the registry VeriqaClaimTypes
apply:
A standard profile claim reaches the tokens the way any claim of an adapter does: declared by a row
of
Veriqa:ScopesClaims under a scope, it goes to
both tokens when that scope is granted; without a row, to the access token only. nickname belongs
to the standard set of the profile scope and needs no row.
A key that breaks the rule is dropped with a warning in the log — authentication does not fail.
So you cannot claim email or locale with a string of your own: put the value in the snapshot
field. Names are compared case-insensitively — Email_Verified is the same name as
email_verified, so re-casing a letter does not get around the reservation. Prefixing with your own
channel type makes collisions between adapters impossible.
Letter case decides whose name it is, but grants no freedom in writing it: a claim of your own is
taken only in the declared spelling. With ChannelType = "acme-chat" the key ACME-CHAT_workspace
is dropped — write the prefix the way the channel type is written (veriqa_channel likewise, as the
registry spells it). What follows the prefix is yours: acme-chat_Workspace goes through. But two
keys of your own differing only in letter case are one claim: one of them is taken, the other
goes to the log as a warning. Which spelling survives is not defined: the set reaches the check
frozen, and its enumeration follows the layout rather than the order you wrote it in. Send one
spelling — a case-variant pair means losing one of the values.
Error codes — from the declared registry, not strings of your own
You return a failure asResult<T>.Failure(code, message), and code comes from
VeriqaErrorCodes — the code registry declared in the same MIT package. A string of your own looks
like it works, but the core does not understand it: it branches on declared codes and tags
telemetry with them, while an unknown code stays a line in a log. A body in an unrecognized format is
UnsupportedEventType; a body without the identity fields is IdentityExtractionFailed. The meaning
of each code is in the XML documentation of VeriqaErrorCodes.
One code stands apart: ChannelCannotContinue — “I cannot carry this confirmation out”. Return
it from SendConfirmationPromptAsync when your channel physically cannot ask the question for this
transaction, and the core ends the transaction in failure with that same reason code instead of
waiting for its TTL. The user sees the error in the browser right away, and
nothing reaches them in the channel. Any other failure code means “it did not work right now”: the
transaction stays waiting for a retry or its TTL. You report no reason and do not pick what happens
next — you declare your own inability, the core decides.
GetDeepLinkAsync — where the button and the QR code lead
The link you return is where your channel takes the user. The core asks for it with a
DeepLinkRequest: the transaction (TransactionId) and the purpose of the link (Purpose), that is,
where the link is going to be used.
In hop mode (it applies only to a channel
declared in the host), the QR code carries a short one-time hop link
to your Veriqa server, and opening it on the phone leads to the link your method returned for
HopQr. The core wraps the link in the hop link, so your adapter does nothing for hop mode.
You may ignore the purpose and return the same link for all three. If your platform can carry text in
a link, pass the request to ResolveAsync, as described for the link text above: the link then gets
the wording the integrator set for its purpose. This way a QR code with a hop link can lead to a longer
text than fits into a QR code that carries the link itself.
Return the DirectQr link in the same form as the Button link: either both are an address of your
channel, or both are a path to a Veriqa page. The core uses the form of the button link to decide
how to show the channel on the page, for example whether to wrap the QR code in a hop link. If the
DirectQr link is empty or in the other form, the core puts the button link into the QR code and logs
this at the Debug level.
Carry the transaction id in the link so your platform can post it back on the webhook:
Start by a code — when the link cannot be relied on
Two kinds of platform need more than a link. One has no link that both opens the chat with the bot and carries a payload, so the transaction cannot ride in it at all. The other has such a link but does not always deliver what it carries. A channel on either declares a start by code: the core gives the transaction a short code of decimal digits, shows it on its own pages, the user sends it to your bot as a message, and you hand it to the core.LinkCarriesTransaction is a fact about your link, and the core decides the rest from it:
The two conditions of a hop link stay in force for the first column: the channel is
declared in the host, and the issuer is an absolute HTTPS URL. Where
either is missing, the QR code carries your link — it opens the chat, and the user reads the code off
the sign-in page. A host where such a channel is declared and enabled maps the hop route even with
hop mode off.
Whatever the user sent comes back to you on the webhook. Strip your command and hand over the rest:
ChannelAuthStartResult.
What belongs to whom:
- The format of the message is yours. The core substitutes the code into
MessageTemplateand shows the result; it does not interpret the wording. A template that is blank, longer than 64 characters (ChannelCodeStart.MaxMessageTemplateLength) or does not hold{code}exactly once cannot be used: a channel withLinkCarriesTransaction = falseis then left out of the page, like a channel that failed to build its link, and a channel withtrueis shown without the block. - The code is the core’s. Do not normalize it and do not check its length: the page shows it in
groups of three digits, the user may send it with spaces or dashes, and the core drops both. The
length is one setting of the installation,
Veriqa:CodeStart:CodeLength— an integer from 6 to 10, 6 by default; a value outside the range stops the host at startup. One code serves the transaction on every channel that declares the start, works once and lives exactly as long as the transaction. - The attempt limit is the core’s. An event with a code is charged to the same per-user
budget as a start by the link, before the code is looked up. A code that names no live
transaction — unknown, expired, already used — is counted like a start whose transaction cannot be
served and answered with the text the registration declares for it,
UnmatchedCodeReplyText: one text for every reason, so the answer does not tell whether the code ever existed. A registration that declares none answers withStaleLinkReplyText, or with silence when it declares neither. At a tenant’s webhook address the per-user budget does not stop guessing: whoever holds the tenant’s webhook secret can sign an event from any user. So codes that match nothing also spend a budget of that tenant and channel type:Veriqa:CodeStart:UnmatchedCodePermitLimitcodes (10 by default) perVeriqa:CodeStart:UnmatchedCodeWindowSecondsseconds (60 by default). Once it is spent, every code event of that tenant and channel type goes unanswered until the window ends, even with a valid code. A matched code spends nothing, and the address without a tenant segment has no such budget. - A message with a code carries no Veriqa marker, so the default
OwnsInboundEventdoes not claim it. Override the member if you route updates by it.
A code is unique among all live codes of the installation, whichever tenant the sign-in belongs to.
At the webhook address without a tenant segment it is found for a sign-in of any tenant. At a
tenant’s address only codes of that tenant’s sign-ins are accepted; another tenant’s code gets the
reply to an unmatched code and stays valid. All tenants draw from one space of codes, so an
installation with many sign-ins in progress at the same time should raise
Veriqa:CodeStart:CodeLength.samples/dotnet/custom-channel: its README walks through the start by
code (AcmeChat:StartByCode) and the fallback (AcmeChat:CodeFallback).
3. Name your channel
The channel type is a contract, not a display string. It must match:kakaotalk, acme-chat, zalo. The
value is matched ordinally against acr_values and becomes a URL path segment, so anything else
(KakaoTalk, my_channel, an empty string, a value with a trailing newline read from configuration)
fails the startup with a message naming the allowed format. The same fail-fast applies to a
duplicate registration of a type — which covers a type a shipped channel already claimed, because
the shipped channels are registered through this very AddChannel and live in the same registry —
and to the type passed to AddChannel differing from the one your adapter returns from
ChannelType — the two must be equal,
because everything downstream matches the channel by the adapter’s ChannelType. That last check
runs on host start, not on the webhook mapping, so an outbound/polling-only channel registered with
mapWebhook: false is diagnosed just as strictly.
That last check has one boundary: a cross-wired swap — one channel’s adapter registered under
another channel’s type — is caught by cross-checking the adapters’ runtime types. If your host
layers a sweeping decorator over every
IChannelAdapter (Scrutor
Decorate<IChannelAdapter, …>() or a Castle proxy over the whole set), every adapter shares the
decorator’s single runtime type and the wrapped types are hidden behind it: such a swap becomes
indistinguishable from a legitimate decorator and is not rejected — swap detection is
best-effort in that configuration. It stays exact for native adapters and for per-adapter class
proxies. The plain case — the type passed to AddChannel is declared by no adapter at all — is
always rejected, decorators or not.4. The webhook endpoint
Registering a channel mapstelegram or whatsapp.
Answer semantics:
That last row is absolute: a
Failure result and even an unhandled exception from
your adapter are logged and still answered 200 with an empty body. The rule is the same for every
channel: the routes of the shipped channels are served by the same handler, so an adapter exception
does not turn into a 500 there either. Messaging platforms disable webhooks or storm retries on
non-2xx, and the response body never leaks error details.
The 1 MB limit belongs to the request body: Veriqa reads the body itself, once and entirely into
memory, while building the envelope — after the tenant demultiplexer and before validation. An
over-limit body aborts that read as it arrives, without being read to the end; a failed read is not
a rejection verdict, so the answer is 200 plus a Warning log entry, the same on the generic
route and on the built-in ones. The over-limit update is lost, but the platform is not pushed into
endless redelivery; the symptom is the log entry, not the status code.
If your channel is outbound-only or polls the platform itself, register it without a route:
ChannelInboundResult
and passes it to ChannelInboundProcessor, the processing that the webhook route and the shipped
polling channels use. It is a scoped service of Veriqa.Core.ChannelAdapter, so open a scope for
each update:
ChannelReplyTexts yourself.
asksInChannelPrompt: true sends the confirmation question into the chat, as the webhook route does.
Run each tenant’s loop inside ChannelTenantContext.BeginScope(tenantId), as in
Working per tenant: the processor takes the tenant of the event from that
scope. This holds from 0.7.3: in 0.7.1 the scope does not restrict the event, and an
event from the loop can act on a transaction of any tenant. Declare outbound_fetch as the channel’s
inbound verification level.
Registration settings
mapWebhook is the one setting the short overloads spell out. Everything a registration can state
lives in ChannelRegistrationOptions, which both overloads accept in place of the flag — the
adapter type and the factory form alike:
An empty or blank string means the same as
null: the channel stays silent.
The shipped channels take this very path: their status wording and their handshake are declared
here as well.
Telegram declares a StaleLinkReplyText, WhatsApp does not: a message outside an approved
template is chargeable there, so answering every stale link would cost the installation money. For a
channel of your own, decide by its platform’s pricing. UnaddressedReplyText is declared by
Instagram and Messenger: a first tap there may arrive without the transaction, and the reply tells
the user to send the code shown on the sign-in page or to scan the QR code again. Their adapters
hand over only a tapped button as ChannelUnaddressedResult — a typed message that concerns no
sign-in is ChannelUnrelatedResult and gets no answer — and each has a setting that switches the
reply off (Instagram, Messenger). The
other shipped channels leave it null and send nothing. UnmatchedCodeReplyText is declared by the
same two channels, the ones that start a sign-in by a code.
The platform’s verification handshake (GET)
Platforms of the Meta family confirm ownership of a webhook by sending a GET to the same path with a challenge to echo back. Declare the query parameter that carries it, and Veriqa maps the GET route beside the POST one:ValidateWebhookAsync as a POST, so the verify token, the spelling it arrives under and the mode
check are your adapter’s business. Veriqa only knows which query parameter holds the value it has to
echo. The route is fail-closed, exactly like the POST one:
Declare nothing and the GET route is not mapped at all — the path answers
405, which is the
behavior a channel whose platform has no handshake wants.
5. Show the channel in the sign-in window
A registered channel already appears as a button — by default labeled with its raw channel type and without an icon. Implement the optionalIChannelDisplayMetadata to give it a name and a glyph:
DisplayName is the name of the channel on the button, on the tab and in the instruction, and the base
text of the localization key <DisplayName> | channel — here, Acme Chat | channel. With no
translation, the name is shown as declared. A host locale file translates it by that key, an
AuthPage:Texts entry for
that key replaces it, and entries for Sign in with Acme Chat and Confirm in Acme Chat reword
its button. A name containing : can be translated but not replaced by an entry. The length of the name is yours,
so a name too long for the tab or the button is cut off there, and a tooltip shows it in full. A blank
label — or one longer than 32 characters, which would break the window layout — degrades to the raw
channel type. IconSvgPath is the inner markup of a
24×24 viewBox and is embedded into the page, so it must be static markup you own — never user input.
It is checked against an allowlist before rendering: plain shape elements only (path, circle,
ellipse, rect, line, polyline, polygon, g) with double-quoted attributes, no style and
no on* handlers, and at most 4096 characters. Anything else is dropped with a warning in the log
and the channel renders without an icon. A channel without a brand color renders with the
neutral primary color of the window; ChannelButtonColors
gives its button and its icon a color of your choice.
If the user sees your channel’s chat under a name of its own — a bot username, an account
handle — implement the optional IChannelBotName as well:
bot_name slot (message templates). The method is
called under the tenant of the transaction, as GetDeepLinkAsync is. null, a blank
value, a value longer than 32 characters or an exception produces the same texts, worded
without a name — the channel name is never put in its place.
A configured name comes first. The BotName key in the
section of the channel is read before your
adapter is asked, and a name stated there is shown instead of the one GetBotNameAsync returns —
the method is then not called at all. So a channel that does not implement IChannelBotName still
gets a name on the pages and in the confirmation question when the integrator states one.
Status messages your channel sends back to the user come from Veriqa’s own localized defaults —
you do not have to supply them. For a sign-in these are “Sign-in confirmed” — or “Sign-in
confirmed. Tap Back to return to the sign-in page.” when the sign-in was started on a phone or a
tablet — and “Sign-in declined”; for a confirmed action they are the neutral outcome receipts “Confirmed ✅”,
“Declined ❌” and “Time expired ⌛”. The error text for a failure while handling the answer —
“Something went wrong. Go back to the sign-in page and start again.” — is the channel’s own and does not depend on the transaction type.
QR code size
The sign-in window draws every channel’s QR in a box sized by the--veriqa-qr-size CSS token
(220px by default). You override it from your own stylesheet, whose path goes into
Veriqa:AuthPageDesign:CustomCssPath:
#veriqa-panel-acme-chat .veriqa-qr img { width: … } gets the same result by bypassing the
token and is therefore forbidden: the next change to the window layout will drift it out of step
with the other sizes.
You may not shrink the QR below either of two thresholds:
- 200×200px — the minimum physical target size for a camera;
- 2.86px per module — the density:
box size ÷ the QR's total module count including the quiet zone.
PixelsPerModule default of 6 is sized for
the deep links the core ships: the most compact of those QRs is 45 modules, and 45 × 6 = 270px
covers the box. In a 220px box the default suffices from ⌈220 ÷ 6⌉ = 37 modules up. A QR only gets
sparser than that from a very short link: acme://c/8f3k9d — 33 modules, 33 × 6 = 198px,
already stretched in the shipped box. The link from §2, the one that carries the transaction id
(43 characters), does not fall into that case — it comes out at 45 modules and the default covers it.
So you need the entry below only if you keep a short code of your own with your own mapping to the
transaction. The host starts either way: the value is inside the allowed range, and your QR’s module
count is unknown to the core — you are the only one who can check the rule.
If that is your case, the fix is an entry for your own channel:
appsettings.json
⌈220 ÷ 29⌉: 29 modules is the most compact QR that can exist at all (version 1 with
the quiet zone), so 8 covers the shipped box whatever the length of your deep link. If you enlarge
the box, recompute this value with the same formula.
The allowed range is 5…35. The upper bound is that same formula applied to a 1000px box and the
same 29 modules, so the range covers any box that fits on a screen, for any channel. A value outside
it stops the host at startup — but the reverse does not hold: landing inside the range confirms
nothing, and satisfying the formula is still up to you.
6. Register it in the host
The host is the application that embeds Veriqa, so it references the server core:Program.cs
appsettings.json.
Use AddChannel<TAdapter>("acme-chat") instead of the factory overload when the adapter’s
dependencies can be resolved from the container.
Declare the channel next to AddChannel. AddChannel registers the adapter and its route, not
the channel’s core-level declaration (CoreChannelDeclaration) — that is a separate step, the same
one the shipped channels take. The declaration is what puts your channel into channels_enabled,
the set of channels available at core level, and everything that reads that set skips a channel
missing from it: hop mode never wraps its QR code, polling
never gets a tenant to run for, and the startup check of inbound verification stays off it. The host
still starts — with a warning in the log naming the channel that has an adapter but no declaration. How to declare
it is shown in Working per tenant.
7. Add the channel to the supported list
An adapter that ships as part of Veriqa gets registered in one more place: the Supported messaging apps catalog and its version on the site (veriqa.app/channels). That list is maintained by hand — a channel missing from it is not a
supported channel, however many other places mention it.
An entry states the same three things as every other one: which claims the channel adds on top of
the mandatory ones, whether confirmation happens inside the channel, and whether the user sends a
secret message — or the messaging app hands the code to the bot by itself. A channel still in progress goes
under the in-development or planned groups, not the built-in one.
None of this applies to an adapter of your own that stays with you — the list describes what Veriqa
ships. Still, keep an entry like it in your own documentation: people ask the same questions
about any new channel.
Working per tenant
Multi-tenancy is inside this SPI, not outside it. A channel of your own reads a tenant’s credentials, texts and limits the same way the shipped ones do — through the same public pieces, and under the same one rule: the tenant is stated by whoever legitimately knows it, and stated once. The set of tenants comes fromIPollingTenantSource. Resolve it from the container and ask it
which tenants your channel is active for; a null element is the default implicit tenant of a
self-hosted installation. It has one precondition: the set is built from the core-level
declarations of the registered channels, and AddChannel does not register one — it registers
the adapter and its route. So declare your channel in the host, next to the AddChannel call:
Program.cs
isEnabled is asked again every time the available set is built, so it has to read a
source that survives a re-read of the configuration: a monitor, not an options object bound once —
that one would freeze a deployment-side edit out of the answer. usesPolling is a startup
decision, and IOptions is what the shipped channels read it through. Both need the section in the
container (builder.Services.Configure<AcmeChatOptions>(builder.Configuration.GetSection("AcmeChat"))),
which is one line more than the manual binding in §6 does for the adapter itself.
That isEnabled is also what puts your channel into channels_enabled at core level. Without the
declaration the tenant set comes back empty and no polling starts — and the startup check the note
in §2 describes stays off your channel; with it, an enabled channel without an InboundVerification
value stops the host exactly like a shipped one.
State the tenant with a scope, around the processing, on your own background path:
ChannelTenantContext.BeginScope(null) — rather than by
omission: a credential read with no scope open at all is indistinguishable from a path that forgot
to state its tenant, and nothing downstream can tell the two apart for you.
On the webhook you do not open a scope. The tenant of an incoming request is already stated —
by the route (/api/channels/{channelType}/webhook/{tenant}), before your adapter is called. One of
your own opened there would repoint every credential read below it, the core’s included, at a tenant
of your choosing instead of the one the host named.
You resolve your own credentials; you do not receive them. Declare your key and resolve it
through the public IConfigurationResolver with ResolutionContext.ForTenant(tenantId) — the same
canonical resolver and the same level order the shipped channels go through. The public client factory
IChannelClientFactory is not needed for that: it builds and caches a client per
(channel, tenant), which is a different job. How a key of your own is declared — the catalog, the
address on each level, the registration — is in
Declare your own configuration keys.