<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abdulahmed Abdulhakeem</title>
    <description>The latest articles on DEV Community by Abdulahmed Abdulhakeem (@abdulahmed_dev).</description>
    <link>https://dev.to/abdulahmed_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4135418%2F8f365422-6f68-4bb2-831a-4d15cf50564a.jpg</url>
      <title>DEV Community: Abdulahmed Abdulhakeem</title>
      <link>https://dev.to/abdulahmed_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdulahmed_dev"/>
    <language>en</language>
    <item>
      <title>Idempotent WhatsApp Webhooks in Laravel: How TalkAm Stops a Retry Moving Money Twice</title>
      <dc:creator>Abdulahmed Abdulhakeem</dc:creator>
      <pubDate>Tue, 01 Dec 2026 12:35:35 +0000</pubDate>
      <link>https://dev.to/abdulahmed_dev/idempotent-whatsapp-webhooks-in-laravel-how-talkam-stops-a-retry-moving-money-twice-58e0</link>
      <guid>https://dev.to/abdulahmed_dev/idempotent-whatsapp-webhooks-in-laravel-how-talkam-stops-a-retry-moving-money-twice-58e0</guid>
      <description>&lt;p&gt;TalkAm is a voice-banking app I built on WhatsApp. A user sends a voice note, something like "send 5,000 to my brother", TalkAm transcribes it, reads the transfer back, and moves the money once the user clears a PIN or a face check.&lt;/p&gt;

&lt;p&gt;Every one of those voice notes reaches TalkAm through a single endpoint: the WhatsApp Cloud API webhook. And that webhook has a property that's easy to miss on a first build: Meta retries any delivery it doesn't get a prompt 200 for.&lt;/p&gt;

&lt;p&gt;In most apps a retried webhook is a nuisance. In a banking app it's a second instruction to move money. This article walks through how TalkAm's webhook is built so that a retry, a race or a crash can never turn one voice note into two transfers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a slow webhook becomes a duplicate transfer
&lt;/h2&gt;

&lt;p&gt;The tempting first version does the work inside the request. The voice note arrives, you download the audio, send it to speech-to-text, ask the language model what the user wants, and reply. It works on your laptop.&lt;/p&gt;

&lt;p&gt;In production, speech-to-text can be slow. One slow transcription and the request outlives Meta's patience. Meta sees no 200, assumes the delivery failed, and sends the same message again. Now two requests are transcribing the same "send 5,000 to my brother".&lt;/p&gt;

&lt;p&gt;You might hope the bank's idempotency key saves you. It doesn't. That key is generated per transfer attempt, so a second run of the same voice note generates a fresh reference, and the bank sees two perfectly valid, different transfers. Two debits.&lt;/p&gt;

&lt;p&gt;The fix has to live at the boundary where the duplicate first appears: the webhook itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The handler does three things: record, queue, return
&lt;/h2&gt;

&lt;p&gt;TalkAm's webhook controller does exactly three things for each message in a delivery. It records the event, which is also where duplicates are caught. It queues the real work. And it returns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;receive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JsonResponse&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$events&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;translator&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nv"&gt;$queued&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$duplicates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$events&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;record&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$record&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$duplicates&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nc"&gt;ProcessInboundChannelEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$record&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$queued&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Always 200, even for a payload we made nothing of.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'received'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$events&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'queued'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$queued&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'duplicates'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$duplicates&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transcription, intent extraction and the transfer state machine all run in the queued job. The request never waits on a speech service, so it can answer promptly, and the most common cause of retries is gone.&lt;/p&gt;

&lt;p&gt;The translator in front of it turns Meta's payload into one normalised event per message. Meta can batch several messages into one delivery, so each one is recorded and queued on its own. A message with no id or no sender is dropped: without an id there's no deduplication key, without a sender there's nobody to act for, and guessing would be worse than dropping it.&lt;/p&gt;

&lt;p&gt;The signature check runs before any of this, as route middleware: no valid HMAC-SHA256 signature from Meta, no record. That's a story of its own; here I'll stay with what happens after a request is proven genuine.&lt;/p&gt;

&lt;h2&gt;
  
  
  The unique index is the real guarantee
&lt;/h2&gt;

&lt;p&gt;Moving the work to a queue makes retries rarer. It doesn't make them impossible: networks drop responses, and Meta will still redeliver now and then. So every inbound message is written to a &lt;code&gt;channel_events&lt;/code&gt; table first, keyed on the provider's own message id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'channel_events'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'channel'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'event_type'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'external_id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// the provider's own message id&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sender_ref'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;jsonb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'payload'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'processed_at'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'processing_outcome'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'channel'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'external_id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The table does two jobs. It's the start of the audit trail, so a transfer can be traced back to the exact message that asked for it. And the unique index on &lt;code&gt;(channel, external_id)&lt;/code&gt; is what makes a redelivery a no-op.&lt;/p&gt;

&lt;p&gt;Here's the method that writes to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;record&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;InboundEvent&lt;/span&gt; &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="nc"&gt;ChannelEvent&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$existing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChannelEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'channel'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'external_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;externalId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$existing&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;ChannelEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="cm"&gt;/* channel, type, external_id, sender, payload */&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;UniqueConstraintViolationException&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lookup handles the ordinary case: a redelivery that arrives after the first copy is safely stored. The try/catch handles the case the lookup can't. Two copies of the same message arrive at once, two requests both look, both see nothing, and both try to insert. Only one insert survives the unique index. The other gets a constraint violation, which the code treats as exactly what it is: a duplicate.&lt;/p&gt;

&lt;p&gt;A check-then-insert without the index looks correct and passes every test you'd think to write. It fails under concurrency, which is precisely when retries show up. The database is the only part of the system that sees both requests at once, so it's the part that gets the final say.&lt;/p&gt;

&lt;h2&gt;
  
  
  Always 200, even for nothing
&lt;/h2&gt;

&lt;p&gt;The controller returns 200 for every request that passes the signature check, including payloads it made nothing of. That covers delivery-status updates, which carry no messages, and message types TalkAm doesn't handle, which are recorded as unsupported and never treated as an instruction.&lt;/p&gt;

&lt;p&gt;It feels wrong to answer "OK" to something you didn't use. But a non-2xx tells Meta to retry, and retrying won't make an unsupported message type supported. It will just deliver the same thing again and again. The response body still says what happened (&lt;code&gt;received&lt;/code&gt;, &lt;code&gt;queued&lt;/code&gt;, &lt;code&gt;duplicates&lt;/code&gt;), so the information isn't lost; it's just not expressed as a failure Meta would act on.&lt;/p&gt;

&lt;h2&gt;
  
  
  The job checks again before it acts
&lt;/h2&gt;

&lt;p&gt;The queued job is the second line of defence. Before it does anything, it reloads the record and looks at &lt;code&gt;processed_at&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChannelEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;channelEventId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$record&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nv"&gt;$record&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;processed_at&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Already handled, or the record is gone. Either way, doing it&lt;/span&gt;
    &lt;span class="c1"&gt;// again is the one thing that must not happen.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$outcome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* audio, text, PIN entry, face capture, ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Throwable&lt;/span&gt; &lt;span class="nv"&gt;$exception&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$record&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;markProcessed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$startedAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nv"&gt;$exception&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$record&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;markProcessed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$outcome&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$startedAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each path through the job ends by stamping the record with a time and an outcome: a transfer started, an onboarding step advanced, an ignored type. That includes failure. If a turn throws, the record is marked &lt;code&gt;failed&lt;/code&gt; before the exception goes back to the queue, so when the queue retries the job, it finds &lt;code&gt;processed_at&lt;/code&gt; already set and stops.&lt;/p&gt;

&lt;p&gt;That's a deliberate trade-off. A turn that died halfway is not replayed automatically, so the user may have to send their voice note again. The alternative is a queue retry re-running a turn that may already have created a transaction. For instructions that move money, asking someone to repeat themselves is the cheaper failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proving it with tests
&lt;/h2&gt;

&lt;p&gt;The guarantees are pinned down in feature tests, so a refactor can't quietly undo them. One sends the same signed message twice and asserts that it was stored and queued once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'processes a redelivered message exactly once'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Bus&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;fake&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nf"&gt;signedPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;whatsAppBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'wamid.retried'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertOk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertJsonPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'queued'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;signedPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;whatsAppBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'wamid.retried'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertOk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertJsonPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'duplicates'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ChannelEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Bus&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;assertDispatchedTimes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ProcessInboundChannelEvent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Others check the rest of the contract: the request makes no outbound HTTP calls at all, the event is recorded before it's queued, every message in a batched delivery is queued, a genuinely different message is still accepted, and an empty payload still gets a 200.&lt;/p&gt;

&lt;p&gt;The "no outbound calls" test is the one I'd copy first. It fakes the HTTP client and asserts nothing was sent during the request. If someone later adds a "quick" API call to the webhook, that test fails before Meta's retries find it in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell anyone building a payment webhook
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Deduplicate at the boundary, on the provider's message id. Your own downstream keys are generated too late to recognise a repeat.&lt;/li&gt;
&lt;li&gt;Let a unique index make the final call. Application-level checks race; the database doesn't.&lt;/li&gt;
&lt;li&gt;Record, queue, return. Nothing slow belongs in the request, because slow is what triggers the retry.&lt;/li&gt;
&lt;li&gt;Return 200 for anything you've recorded or can't use. A failure status is an instruction to the sender to try again.&lt;/li&gt;
&lt;li&gt;Make the worker check again, and mark failures as processed if a replay could be worse than a repeat.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of this is specific to WhatsApp. Payment providers, SMS gateways and IVR platforms all retry, and all of them will eventually deliver the same thing twice.&lt;/p&gt;

&lt;p&gt;How does your system make sure a retried webhook can't do the same work twice?&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webhooks</category>
      <category>fintech</category>
    </item>
    <item>
      <title>Fraud Scoring in Laravel: How TalkAm Chooses Between a PIN and a Face Check</title>
      <dc:creator>Abdulahmed Abdulhakeem</dc:creator>
      <pubDate>Fri, 27 Nov 2026 19:46:00 +0000</pubDate>
      <link>https://dev.to/abdulahmed_dev/fraud-scoring-in-laravel-how-talkam-chooses-between-a-pin-and-a-face-check-b76</link>
      <guid>https://dev.to/abdulahmed_dev/fraud-scoring-in-laravel-how-talkam-chooses-between-a-pin-and-a-face-check-b76</guid>
      <description>&lt;p&gt;TalkAm is a voice-banking app I built on WhatsApp. A user sends a voice note, something like "send 20,000 to my sister", TalkAm reads the transfer back, and the money moves once the user clears one verification step: a four-digit PIN or a face check.&lt;/p&gt;

&lt;p&gt;Which of the two is the risk gate's call, made before any verification is offered. This article walks through how it decides, and the handful of decisions in the code that keep each decision explainable to the person on the other end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a score, not a list of triggers
&lt;/h2&gt;

&lt;p&gt;The obvious design is a list. New device: face check. Large amount: face check. It reads well and tests easily. It is also wrong, because most single risk signals are weak.&lt;/p&gt;

&lt;p&gt;A transfer at 2am is not suspicious; plenty of people work nights. A transfer at 2am, from a phone this account has never used, for more than this person has ever sent, is.&lt;/p&gt;

&lt;p&gt;A design where any one rule escalates on its own has to set every rule's bar high enough to stand alone, so each rule ends up missing the case it was written for. Scoring lets each rule be as sensitive as it honestly should be and puts the judgement in the combination.&lt;/p&gt;

&lt;p&gt;So TalkAm's gate runs nine transaction-monitoring rules, the kind a bank's monitoring engine runs, and adds up their points. At or above 50, the transaction needs a face check. Below it, a PIN.&lt;/p&gt;

&lt;p&gt;The weights live in one config file, not in nine classes, so tuning one is an edit rather than a code change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// config/talkam.php (trimmed)&lt;/span&gt;
&lt;span class="s1"&gt;'face_score_threshold'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'TALKAM_FACE_SCORE_THRESHOLD'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

&lt;span class="s1"&gt;'rules'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'odd_hour'&lt;/span&gt;           &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'from_hour'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'until_hour'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'tier_check'&lt;/span&gt;         &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;// refuses instead of scoring&lt;/span&gt;
    &lt;span class="s1"&gt;'round_tripping'&lt;/span&gt;     &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'window_minutes'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'customer_history'&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'minimum_account_age_days'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'high_amount'&lt;/span&gt;        &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'both_weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'velocity_check'&lt;/span&gt;     &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'window_minutes'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'geo_anomaly'&lt;/span&gt;        &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'device_fingerprint'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'ml_score'&lt;/span&gt;           &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'floor'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.50&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same file carries worked examples next to the numbers, so anyone changing a weight can see what it does to real cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;familiar device, normal amount, daytime, established account: 0, PIN&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;new device at 2am, small amount: 15 + 25 = 40, PIN&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;new device, and more than this user has ever sent: 25 + 25 = 50, face&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;brand-new account, and a large amount for them: 25 + 25 = 50, face&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;received money an hour ago and sending it straight on: 35, a face check only with another signal beside it&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few of the rules carry their own judgement. "Odd hour" is asked in the user's own timezone, so a trader in Kano sending money at 8pm doesn't look strange to a server set to another timezone. "High amount" fires on either of two bars: above an absolute ₦100,000, or above the user's own range, which is their largest settled transfer in the last 90 days times 1.5. The tolerance matters. Without it, someone who always sends ₦5,000 gets a face check for sending ₦5,001, and people learn the face check is noise. Clearing both bars scores 40 instead of 25, because large and out of character together is a stronger signal than either.&lt;/p&gt;

&lt;p&gt;What is deliberately not a rule: paying someone who isn't a saved payee. It is the most ordinary transfer there is, a trader paying a new supplier or a parent paying a school account read off a letter. Making it elevated by definition would put a face check in front of the commonest transfer in banking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Refusals come before scoring
&lt;/h2&gt;

&lt;p&gt;Some answers are not risk judgements. An account on hold. A transfer above the hard limits of ₦500,000 per transaction or ₦1,000,000 a day. An amount over the account's KYC tier cap. No verification raises any of those, so offering a face check would have the user pass it and then be refused anyway. It would also tell an attacker exactly where the limits sit.&lt;/p&gt;

&lt;p&gt;So refusals run first, and the tier check is the first rule in the list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;decide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RiskContext&lt;/span&gt; &lt;span class="nv"&gt;$context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RiskDecision&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$refusal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;refuseOutright&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// hold, hard limits&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$refusal&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$refusal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nv"&gt;$signals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;rules&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$rule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$signal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$rule&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$signals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$signal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$signal&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;isRefusal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// only TIER_CHECK&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RiskDecision&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;refuse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$signal&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;refusalReason&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signal&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nv"&gt;$score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nv"&gt;$signal&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;points&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RiskDecision&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;scored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'talkam.risk.face_score_threshold'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is one more refusal, after scoring. TalkAm also answers on an IVR line, so feature phones can do PIN-level work. A feature phone has no camera. When the score demands a face on that channel, the gate refuses and tells the user to come back on WhatsApp. It never quietly drops to a PIN, because then "call from a feature phone" becomes the cheapest way past a face check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four outcomes, not two
&lt;/h2&gt;

&lt;p&gt;Each rule answers with a &lt;code&gt;RuleSignal&lt;/code&gt;, and there are four kinds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;fired&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$rule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$points&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// saw what it looks for&lt;/span&gt;
&lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;quiet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$rule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$evidence&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// looked, saw nothing&lt;/span&gt;
&lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;refuse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$rule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;           &lt;span class="c1"&gt;// ends the request&lt;/span&gt;
&lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;noSignal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$rule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$why&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// could not look&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference between the last and the second is the one that matters most. Nothing in TalkAm captures a user's location today, so the location rule cannot run. If it returned &lt;code&gt;quiet&lt;/code&gt;, every transaction in the system would carry "nothing unusual about this location", a reassurance nobody measured and one that looks exactly like a real one.&lt;/p&gt;

&lt;p&gt;So it returns &lt;code&gt;noSignal&lt;/code&gt;, with the reason written into the audit row. The gap stays visible where someone can do something about it. The rule's weight of 25 is already in config for the day a location source exists, either one the user consents to or a feed from the bank side.&lt;/p&gt;

&lt;h2&gt;
  
  
  The model is one input, never the decision
&lt;/h2&gt;

&lt;p&gt;The ninth rule is a model's opinion, and three properties keep it in its place:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RiskContext&lt;/span&gt; &lt;span class="nv"&gt;$context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RuleSignal&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;scorer&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Throwable&lt;/span&gt; &lt;span class="nv"&gt;$exception&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$exception&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;noSignal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"scorer_failed: {$this-&amp;gt;scorer-&amp;gt;name()}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$score&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;noSignal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"no_score_available: {$this-&amp;gt;scorer-&amp;gt;name()}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nv"&gt;$score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$score&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$score&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'talkam.risk.rules.ml_score.floor'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;quiet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'score'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$score&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RuleSignal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;fired&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'score'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$score&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;rule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;$score&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is capped. A score of 1.0 contributes 40 points and no more, and 40 is below the threshold of 50. The model can push a transfer over the line, but there is always a deterministic rule in any escalation that someone can explain to the user.&lt;/p&gt;

&lt;p&gt;It has a floor. Scores below 0.50 add nothing rather than a trickle. A model that is mildly suspicious of everything would otherwise raise the baseline for every transaction, and the other rules' weights would quietly stop meaning what they say.&lt;/p&gt;

&lt;p&gt;It fails to no signal. A scorer that throws or returns nothing reports that it could not look, never that it looked and was reassured.&lt;/p&gt;

&lt;p&gt;That last point is live today, because there is no trained model yet. The scorer bound in the container is a placeholder that returns &lt;code&gt;null&lt;/code&gt;. Returning &lt;code&gt;0.0&lt;/code&gt; would be a model asserting that every transaction is definitively safe, the most flattering lie a score can tell. The interface is deliberately narrow, &lt;code&gt;score(RiskContext $context): ?float&lt;/code&gt;, with no tier and no recommendation, so a real model can be swapped in without touching the gate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Every decision is logged, including the routine ones
&lt;/h2&gt;

&lt;p&gt;The gate writes to &lt;code&gt;risk_events&lt;/code&gt; on every evaluation: one row per rule that fired, so an escalation is itemised and queryable by rule name, plus one summary row with the score, the threshold, the outcome and the rules that stayed quiet or couldn't run. The summary row is what lets you audit the gate for what it let through, which after an incident is the question that matters.&lt;/p&gt;

&lt;p&gt;Refusals are logged as a warning, not as critical. Critical means "this may not be the account owner", and it is what raises a hold on the account. Being over a limit is an ordinary answer to an ordinary request: the user should hear no and be free to try a smaller amount straight away. An earlier version logged refusals as critical, and one over-limit request turned into a lockout that renewed itself on every retry.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd still change
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The weights are hand-set. The worked examples keep them sane, but real transaction data is what should tune them, and that doesn't exist yet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Round-tripping under-reports. The ledger only sees money that came in from other TalkAm users, which is why that rule sits at 35, strong but never enough alone.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On WhatsApp, the "device" is the sender's phone number. It identifies the account more than the handset, so it carries a moderate 25.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Two of the nine rules, location and the model, are wired but silent today. That is honest, and it also means the gate is working with seven rules until they're fed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this is exotic. It is a weighted sum, a threshold and an audit table. The value is in the rules about the rules: refuse before you score, never let "couldn't look" pass for "all clear", and never let a model be the whole reason someone is asked for their face.&lt;/p&gt;

&lt;p&gt;How does your system explain a risk decision to the person it challenged?&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>fintech</category>
      <category>security</category>
    </item>
    <item>
      <title>Voice Banking in Laravel: Never Trust the Transcript for the Payment Recipient</title>
      <dc:creator>Abdulahmed Abdulhakeem</dc:creator>
      <pubDate>Tue, 24 Nov 2026 09:29:20 +0000</pubDate>
      <link>https://dev.to/abdulahmed_dev/voice-banking-in-laravel-never-trust-the-transcript-for-the-payment-recipient-4b7p</link>
      <guid>https://dev.to/abdulahmed_dev/voice-banking-in-laravel-never-trust-the-transcript-for-the-payment-recipient-4b7p</guid>
      <description>&lt;p&gt;TalkAm is a voice-banking app I built on WhatsApp. A user sends a voice note, something like "send 5,000 to my brother", and the money moves after a read-back, a PIN and, when the risk rules call for it, a face check.&lt;/p&gt;

&lt;p&gt;Most of a voice instruction is easy to check. The amount gets read back. The intent is one of six, a closed set. The recipient is different. Speech-to-text is worst at exactly the part a transfer can't afford to get wrong: names. Nigerian names and nicknames are what automatic transcription mangles most. The user says "my brother"; the recogniser hears "my broda", "mai brother", or something unrecognisable.&lt;/p&gt;

&lt;p&gt;So one rule sits in the code, written as a comment above the call that enforces it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The recipient is resolved against the user's own saved payees, or against the bank by name enquiry — never trusted from the transcript. What comes back is a destination or a question.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This article walks through how that's built in Laravel, and the decisions behind it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The transcript holds a reference, not a destination
&lt;/h2&gt;

&lt;p&gt;The language model's job in TalkAm is to propose. It reads the transcript and returns an intent plus entities, one of which is a &lt;code&gt;recipient_reference&lt;/code&gt;: the words the user used for the person they want to pay. "My brother", or "7733992211".&lt;/p&gt;

&lt;p&gt;That string is never an account. It's a clue. A single class, &lt;code&gt;BeneficiaryResolver&lt;/code&gt;, turns it into one of four outcomes, and the design turns on the fact that only one of them is an error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RecipientResolution&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// "my brother" matched someone they have paid before&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;savedPayee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Beneficiary&lt;/span&gt; &lt;span class="nv"&gt;$b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;self&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// ten digits, and the bank's name enquiry says whose account it is&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;accountNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;self&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// "my brother" matched nobody: not a refusal, a question&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;unknownName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$spokenReference&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;self&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// ten digits that aren't an account: they almost certainly misspoke&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;accountNotFound&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;self&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isComplete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;beneficiary&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
            &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;accountNumber&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;accountNotFound&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only a complete resolution can open a transaction. Everything else turns into something the user hears and answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Digits first
&lt;/h2&gt;

&lt;p&gt;Order matters in the resolver. Ten digits are checked before any name matching:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;resolveRecipient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$reference&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecipientResolution&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$accountNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;asAccountNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$reference&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accountNumber&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;resolveAccountNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accountNumber&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nv"&gt;$beneficiary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$reference&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$beneficiary&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
        &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nc"&gt;RecipientResolution&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;savedPayee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$beneficiary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecipientResolution&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;unknownName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$reference&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Send 2,000 to 7733992211" is a complete instruction. It should not be run past a fuzzy name matcher that might find an 80% resemblance between a number and somebody's nickname.&lt;/p&gt;

&lt;p&gt;Spoken account numbers rarely arrive clean. They come spaced, grouped, or with words around them ("the number na 7733992211"), and sometimes as spoken numbers in Yoruba, Hausa or Pidgin. A digit parser lifts the ten digits out of whatever was said instead of requiring the whole string to look like a number. A NUBAN is ten digits, which is long enough not to collide with most other things a person says.&lt;/p&gt;

&lt;h2&gt;
  
  
  Matching the words the user actually says
&lt;/h2&gt;

&lt;p&gt;When there are no digits, the reference is matched against the user's saved payees. Not only against the name the bank holds, but against every alias saved for that payee, because the alias is the word the user actually says. Matching on "my brother" recovers the right payee from a transcript that got the spelling wrong.&lt;/p&gt;

&lt;p&gt;Two numbers decide whether a match counts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MINIMUM_SIMILARITY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;80.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MINIMUM_MARGIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;8.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// inside resolve(): score every payee by its best-matching term&lt;/span&gt;
&lt;span class="nf"&gt;usort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$scored&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'score'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'score'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$winner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$scored&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$winner&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'score'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;MINIMUM_SIMILARITY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$runnerUp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$scored&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'score'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$winner&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'score'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;$runnerUp&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;MINIMUM_MARGIN&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$scored&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$winner&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'beneficiary'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The threshold sits well above the midpoint because the two kinds of mistake don't cost the same. A false match sends money to the wrong saved payee, silently. Nobody catches that failure, because everything looked normal. A miss costs one extra question. Those aren't comparable, so the matcher is built to miss rather than guess.&lt;/p&gt;

&lt;p&gt;The margin handles a different problem. "My sister" and "my sitter" can both score 82. That isn't a strong match; it's an ambiguous reference, and picking the higher of two near-identical scores is a coin toss with someone's money. If the winner doesn't clear the runner-up by 8 points, there is no winner.&lt;/p&gt;

&lt;p&gt;Similarity is measured with PHP's &lt;code&gt;similar_text&lt;/code&gt; rather than &lt;code&gt;levenshtein&lt;/code&gt;. &lt;code&gt;similar_text&lt;/code&gt; scores on the longest common substrings, which is a better model for a recogniser that drops or doubles a syllable than an edit distance built around single-character substitutions. Case and surrounding whitespace are normalised away first, since neither survives transcription in any meaningful way.&lt;/p&gt;

&lt;h2&gt;
  
  
  A miss is a question, not a risk signal
&lt;/h2&gt;

&lt;p&gt;When the name matches nobody, two things don't happen.&lt;/p&gt;

&lt;p&gt;First, no transaction is opened. A transfer with no destination isn't a transaction yet, and opening one would put a half-specified request into the state machine that money is supposed to flow through. Instead, the question is written to the voice session: "That name isn't saved. What's the account number?" The next thing the user says answers it.&lt;/p&gt;

&lt;p&gt;When the question is asked, the intent and the amount are written down with it. When the account number arrives, the transfer is opened from what was written down, not from whatever a language model makes of a string of digits. A misheard second voice note can't change how much money moves.&lt;/p&gt;

&lt;p&gt;Second, nothing about this counts against the user. TalkAm's risk gate runs a closed set of named monitoring rules, things like odd hours, velocity, amount, device and location. "The payee isn't saved" is deliberately not one of them. Paying someone for the first time is the most ordinary thing in banking: a trader paying a new supplier, a parent paying a school account read off a letter. Treating it as risky by definition would put a face check in front of the most common transfer there is. Whether a payee is saved is a convenience. The monitoring rules decide whether a transfer needs more than a PIN.&lt;/p&gt;

&lt;h2&gt;
  
  
  The name is read back before the PIN
&lt;/h2&gt;

&lt;p&gt;For an account number, the bank's name enquiry runs when the recipient is resolved, not at settlement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;resolveAccountNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$accountNumber&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecipientResolution&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;bank&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;nameEnquiry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accountNumber&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
        &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nc"&gt;RecipientResolution&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;accountNotFound&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accountNumber&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RecipientResolution&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;accountNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accountNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That timing is the point. The read-back message says the amount and the recipient's name before the PIN prompt opens, as two separate messages, so the one sentence the user needs to check isn't buried behind a tap. Someone who transposed two digits is far more likely to notice the wrong name than the wrong number. And a user who can't read gets the same protection as one who can, because they hear it.&lt;/p&gt;

&lt;p&gt;If the digits aren't an account, TalkAm says so and asks again. If it heard too few or too many digits, the question stays open rather than being dropped, so the user isn't sent back to the start of a transfer they already described.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning the user's words
&lt;/h2&gt;

&lt;p&gt;After a transfer to a new account settles, TalkAm offers to save it, phrased in the user's own words: "Save this account as 'my brother'?" The new payee is stored with the bank's account name as its name and the user's words as its alias, because the alias is what they'll say next time. Next time, "send 5,000 to my brother" resolves straight to a saved payee.&lt;/p&gt;

&lt;p&gt;The offer only comes after the money has moved. Asking mid-transfer would put a filing question between a person and their money, and a user who ignores it loses nothing. It's answered with a button or a spoken yes, which is fine here. A tapped button posts its value into the chat thread, and "Yes" sitting in a thread is harmless. That's also exactly why a PIN never goes through a button.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd carry into any payments system
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A transcript, or a model's output, is a claim.&lt;/strong&gt; Resolve it against data you own (saved payees, the bank's own name enquiry) before money depends on it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make "I don't know" a first-class outcome.&lt;/strong&gt; A resolution that can come back as a question is easier to build safely than one that must always return an answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set thresholds from the cost of each mistake.&lt;/strong&gt; When a false match is silent and a miss costs one question, the threshold belongs well above the middle, and a winner should also have to beat the runner-up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put the checkable thing in front of the irreversible step.&lt;/strong&gt; The account name, read back before the PIN, is the cheapest fraud and error control in the flow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't treat novelty as risk.&lt;/strong&gt; Paying someone new is normal. Let named monitoring rules decide when to ask for more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this needs a better speech model. It needs the code to be honest about what a transcript can and can't tell you.&lt;/p&gt;

&lt;p&gt;I'm curious how others handle this: where in your systems does uncertainty turn into a question rather than a guess?&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>fintech</category>
      <category>security</category>
    </item>
    <item>
      <title>Speech-to-Text for Nigerian Languages: Routing Pidgin, Yoruba and Hausa Across Spitch, Intron and Gemini</title>
      <dc:creator>Abdulahmed Abdulhakeem</dc:creator>
      <pubDate>Mon, 23 Nov 2026 02:41:39 +0000</pubDate>
      <link>https://dev.to/abdulahmed_dev/speech-to-text-for-nigerian-languages-routing-pidgin-yoruba-and-hausa-across-spitch-intron-and-4jkn</link>
      <guid>https://dev.to/abdulahmed_dev/speech-to-text-for-nigerian-languages-routing-pidgin-yoruba-and-hausa-across-spitch-intron-and-4jkn</guid>
      <description>&lt;p&gt;TalkAm is a voice banking assistant on WhatsApp. You send a voice note in Pidgin, Yoruba or Hausa ("check my balance", "send 5,000 to my sister") and it answers by voice in the same language. Before any language model can understand that note, it has to become text. That step, speech-to-text, is where most voice products quietly fail Nigerian users.&lt;/p&gt;

&lt;p&gt;This article walks through how the speech service routes each voice note across three providers, Spitch, Intron and Google Gemini, and the rules that keep a bad transcript from ever touching someone's money. The service is Python (FastAPI); the banking core it reports to is Laravel.&lt;/p&gt;

&lt;h2&gt;
  
  
  The failure that shapes everything
&lt;/h2&gt;

&lt;p&gt;Speech recognition has a nasty failure mode. Send a Hausa voice note through a model built for Yoruba and you don't get an error. You get a fluent, confident transcript of words nobody said.&lt;/p&gt;

&lt;p&gt;For a chat app that's an annoyance. For banking it's dangerous, because that transcript flows straight into intent extraction looking like a perfectly normal input. So the whole design follows one rule: &lt;strong&gt;a wrong answer is worse than no answer.&lt;/strong&gt; Every decision below is that rule applied somewhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. One interface per vendor
&lt;/h2&gt;

&lt;p&gt;Each provider sits behind the same small interface. A provider declares which languages it supports and whether it claims to handle code-switched speech, and it implements two methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SpeechProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;ABC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"unnamed"&lt;/span&gt;
    &lt;span class="n"&gt;supported_languages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Language&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;supports_code_switching&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

    &lt;span class="nd"&gt;@abstractmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;transcribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;audio_ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Language&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Transcription&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

    &lt;span class="nd"&gt;@abstractmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;synthesize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Language&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Synthesis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spitch, Intron and Gemini each get one adapter. Swapping a provider is a configuration change, not a code change. Every transcript also records the slug of the provider that produced it, so an audit months later can still say which vendor heard what.&lt;/p&gt;

&lt;p&gt;The languages are a closed enum: Pidgin, Yoruba, Hausa. Igbo is on the backlog and deliberately absent. There is no placeholder for it, so any attempt to route Igbo fails loudly instead of half-working.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Refuse rather than attempt
&lt;/h2&gt;

&lt;p&gt;If a provider is asked for a language it doesn't claim, it raises instead of trying:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;assert_supports&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Language&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;supports&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;UnsupportedLanguageError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Provider {self.name!r} does not support {language.value!r}."&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks fussy until you remember the failure mode. Forcing a Hausa utterance through a model that doesn't support Hausa returns plausible text. An exception, on the other hand, can be handled.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Route per language, not per vendor
&lt;/h2&gt;

&lt;p&gt;The obvious design is to pick the "best" speech vendor and use it for everything. I didn't, because there's no reason to expect one vendor to win in every language. Each language gets its own route in configuration (&lt;code&gt;TALKAM_ASR_PIDGIN&lt;/code&gt;, &lt;code&gt;TALKAM_ASR_YORUBA&lt;/code&gt;, &lt;code&gt;TALKAM_ASR_HAUSA&lt;/code&gt;, plus one for mixed speech), and the same for text-to-speech.&lt;/p&gt;

&lt;p&gt;The routes are meant to be filled from evidence. The repo includes a small benchmark harness that measures word error rate per provider per language over self-recorded audio, about 50 utterances per language covering all six banking intents plus off-topic ones. Its README is blunt about recording conditions: market noise, the street, a bad phone mic. A benchmark recorded in a quiet room picks the wrong provider, because it measures a situation users are never in.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Identify the language first, and let the user's choice win
&lt;/h2&gt;

&lt;p&gt;Language identification is its own step, before transcription, behind its own interface. It returns a language and a confidence, not a transcript. Doing it as a side effect of transcription would mean the audio had already gone through some model's assumptions before anyone decided which model was right for it.&lt;/p&gt;

&lt;p&gt;The routing rule is deliberately lopsided. At onboarding, the user picks their language. Automatic detection can only override that choice at 0.85 confidence or above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;identification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_threshold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RoutingDecision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;identification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                           &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"detection_above_threshold"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RoutingDecision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;preferred_language&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"detection_below_threshold"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A user who chose Hausa has told us something reliable. A detector that is 60% sure the audio is Yoruba has told us very little. Each decision also stores its reason, the detection confidence and the threshold, because when a transcript comes back as nonsense the first question is which model it went through and why. That answer has to be recorded at the time, not reconstructed afterwards.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Code-switching goes only to providers that claim it
&lt;/h2&gt;

&lt;p&gt;Most urban Nigerian speech mixes languages mid-sentence. "Abeg send 2k to Tunde" is Pidgin, English and a Yoruba name in five words. When identification says an utterance is code-switched, there is no single-language model that fits.&lt;/p&gt;

&lt;p&gt;In TalkAm, the Intron and Gemini adapters declare code-switch support and the Spitch adapter doesn't. The registry checks that claim at the point of use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;for_code_switched_audio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;SpeechProvider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_asr_routes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MIXED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"code-switch ASR"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;supports_code_switching&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ProviderNotConfiguredError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Provider {provider.name!r} is routed for code-switched audio "&lt;/span&gt;
            &lt;span class="s2"&gt;"but does not claim code-switch support."&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A route pointing mixed speech at a single-language provider is a misconfiguration, and it surfaces as an error instead of a stream of confidently wrong transcripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. A fallback chain, with one deliberate reorder
&lt;/h2&gt;

&lt;p&gt;Providers fail: timeouts, outages, a 500 at the worst moment. So the pipeline builds an ordered list: the configured primary first, then the fallbacks from &lt;code&gt;TALKAM_ASR_FALLBACKS&lt;/code&gt;, skipping any that don't support the language (or, for mixed speech, don't claim code-switching). It tries them in order, and an empty transcript counts as a failure, not a success.&lt;/p&gt;

&lt;p&gt;There's one reorder. When the conversation is waiting for digits, an account number or a PIN prompt, the chain moves Spitch to the front:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;awaiting_account_number&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;awaiting_pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;providers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"spitch"&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If every provider fails, the result is &lt;code&gt;transcription_unavailable&lt;/code&gt;, and the user gets an in-language prompt to try again. Nobody's money moves on a guess.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What happens to the transcript next
&lt;/h2&gt;

&lt;p&gt;Getting text back is not the end of the speech service's job. The order of the next steps matters as much as the routing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;PIN guard, immediately.&lt;/strong&gt; If the session was waiting for a PIN, or the utterance is nothing but digits and nothing asked for digits, the transcript is replaced with a fixed marker before anything else reads it. Placing this check after extraction would mean the digits had already been sent to an LLM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Confidence floor.&lt;/strong&gt; Transcripts below the floor never go to extraction, because an intent extracted from a transcript the recogniser itself doubts is a confident answer built on a guess, and it costs an LLM call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intent extraction.&lt;/strong&gt; Claude maps the text to one of six closed intents with a schema. Low confidence takes the in-language fallback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A proposal, not a command.&lt;/strong&gt; The speech service never moves money. It returns an intent and entities; the Laravel core re-validates every field, including the amount.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What each provider owns, and what it never decides
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spitch, Intron, Gemini&lt;/strong&gt; own one thing: turning audio into text (and text into speech) in a language they claim to support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They never decide&lt;/strong&gt; which language the user speaks, whether a transcript is trustworthy enough to act on, or anything about money.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The router&lt;/strong&gt; decides the language. &lt;strong&gt;The pipeline&lt;/strong&gt; decides whether text is safe to read. &lt;strong&gt;The core&lt;/strong&gt; decides what happens to an account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The trade-offs
&lt;/h2&gt;

&lt;p&gt;This is more code than a single vendor SDK call. Three adapters, a registry, a router and a benchmark harness is a lot to maintain for one feature, and every new vendor has to fit the interface.&lt;/p&gt;

&lt;p&gt;There's also an honest gap. Today the adapters report a fixed confidence per vendor rather than a score that comes back with each transcript. That makes the confidence floor more of a seam waiting for benchmark numbers than a live filter. I'd rather have the seam in place, documented as such, than bolt it on after the first bad transcript.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell anyone building voice for Nigerian languages
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Treat a wrong-language transcript as the main risk, not an edge case.&lt;/li&gt;
&lt;li&gt;Route per language from measurements, and measure in noise.&lt;/li&gt;
&lt;li&gt;Let the user's own language choice beat a low-confidence detector.&lt;/li&gt;
&lt;li&gt;Send code-switched speech only to providers that claim to handle it.&lt;/li&gt;
&lt;li&gt;Keep the speech layer out of every decision that touches money.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you've shipped speech features for African languages, how do you pick a provider per language, and what did your benchmark show that the vendor's docs didn't?&lt;/p&gt;

</description>
      <category>speechrecognition</category>
      <category>python</category>
      <category>fastapi</category>
      <category>ai</category>
    </item>
    <item>
      <title>Building Kaabo: A WhatsApp AI Concierge for Lagos Hospitality (and the Pivot We Made on Hackathon Day)</title>
      <dc:creator>Abdulahmed Abdulhakeem</dc:creator>
      <pubDate>Wed, 18 Nov 2026 06:08:09 +0000</pubDate>
      <link>https://dev.to/abdulahmed_dev/building-kaabo-a-whatsapp-ai-concierge-for-lagos-hospitality-and-the-pivot-we-made-on-hackathon-5b85</link>
      <guid>https://dev.to/abdulahmed_dev/building-kaabo-a-whatsapp-ai-concierge-for-lagos-hospitality-and-the-pivot-we-made-on-hackathon-5b85</guid>
      <description>&lt;p&gt;Last weekend I spent two days at the Workpeg Lagos Hospitality Hackathon with my teammates Faruk Amoo and Emmanuel Falode. Ten teams pitched. We finished 4th, 2.2 points off the podium.&lt;/p&gt;

&lt;p&gt;We didn't win the cheque. But the product we built, and the decisions we made building it, taught me more than most quarters of regular work do. This post covers what we built, how it works, the pivot we made on day one, and what I'm taking into the next one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: hospitality in Lagos runs on chat, but booking doesn't
&lt;/h2&gt;

&lt;p&gt;Think about how people actually book things in Lagos. You find a hotel or lounge on Instagram. You send a DM. You wait. Someone sends a price list as an image. You ask whether a room is free on Friday. You wait again. Then you're told to "send the transfer and the receipt", and you hope the booking is real when you show up.&lt;/p&gt;

&lt;p&gt;Everybody is already on WhatsApp. Guests are comfortable there and so are the businesses. What's missing is something on the other end that can answer straight away, check real availability, take payment, and confirm the booking without a human copying details between five places.&lt;/p&gt;

&lt;p&gt;That was the gap we went after.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Kaabo does
&lt;/h2&gt;

&lt;p&gt;Kaabo (Yoruba for "welcome") is an AI hospitality concierge that lives on WhatsApp.&lt;/p&gt;

&lt;p&gt;For guests, there is nothing to download and no menu of numbered options. You just talk to it: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Natural conversation, any language.&lt;/strong&gt; You write the way you'd text a friend, in whatever language you speak, and Kaabo replies in that same language. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Voice in, voice out.&lt;/strong&gt; Send a voice note and you get a voice note back (plus the text). Type a message and you get text. A lot of people would rather talk than type, and the reply should match how they spoke. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Find, check, book.&lt;/strong&gt; Hotels and short-lets near you, with rooms and prices. Lounges and restaurants. Car and luxury car hire. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pay upfront, with a hold.&lt;/strong&gt; When you pick something, Kaabo holds it for 30 minutes while you pay. When the payment lands, the booking is confirmed. If it doesn't, the hold expires and the slot goes back on sale. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Order once you're there.&lt;/strong&gt; At a partner restaurant or lounge, you can order from its menu in the same chat, for dine-in or takeout. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No hotel stay required.&lt;/strong&gt; Someone who lives in Lekki can use Kaabo just to book a lounge or a car for the night.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For venues, every hotel, lounge, restaurant or car-hire partner is its own business on Workpeg, with a guest desk where its bookings, guest contacts and conversations live. That was important to us: the guest relationship belongs to the venue, not to us. Kaabo is the channel, and the venue owns the customer.&lt;/p&gt;

&lt;p&gt;For the platform, payments are split automatically. The guest pays once, each venue receives its share, and Kaabo's fee is deducted at that point. Nobody has to reconcile it by hand afterwards.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it fits together
&lt;/h2&gt;

&lt;p&gt;At a high level there are three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The conversation layer (WhatsApp).&lt;/strong&gt; This layer takes text or voice, works out the language and what the guest wants, and decides how to reply: a voice note for a voice note, text for text. It never shows the guest a rigid menu. The guest says what they want and the system works out which action to take.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;One generic booking engine.&lt;/strong&gt; This was the most important design decision of the weekend. Rooms, tables, lounge sections and cars all go through a single booking model: something bookable, belonging to a venue, for a time window, at a price, with a hold and a payment. We didn't build a separate flow for each venue type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The venue's own workspace on Workpeg.&lt;/strong&gt; Each partner venue is a separate business built on Workpeg's building blocks ("pegs"). Confirmed bookings, guest contacts and follow-ups land in that venue's guest desk, where its staff already work.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The hold-then-pay flow sits in the middle. A booking starts as a hold with an expiry. Payment turns it into a confirmed booking and triggers the split. If the expiry passes first, the hold is released. That one state machine handles a hotel room on Friday night and a car at 7pm on Saturday the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pivot: reading the room on day one
&lt;/h2&gt;

&lt;p&gt;We came in with Kaabo as a guest-desk product for hotels and short-lets: a WhatsApp concierge for booking rooms, plus a front-desk dashboard for the hotel.&lt;/p&gt;

&lt;p&gt;On the first morning we realised at least two other teams were also building hotel front-desk products. Three teams pitching the same idea to the same judges is a bad position, however good your execution is.&lt;/p&gt;

&lt;p&gt;So we widened the scope. Kaabo stopped being "book a hotel room on WhatsApp" and became "book hospitality in Lagos": everything a guest needs around a stay (eating out, lounges, nightlife, car hire), from the hotel itself or from places nearby.&lt;/p&gt;

&lt;p&gt;Two things made that possible within a hackathon:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The generic booking engine.&lt;/strong&gt; A widened scope only works if every new venue type doesn't need its own code path. Once a lounge table and a car were just "bookable things" like a room, adding them meant adding data, not rewriting flows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Saying no out loud.&lt;/strong&gt; We explicitly cut flights and timeshare. Both fit the "around a stay" story, but neither would have been solid by demo time. A smaller scope that works beats a bigger one that breaks on stage.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We also added one small but high-value touch: after a guest pays for a room, Kaabo makes a single offer of extras (a table, a car, a lounge) from the hotel or nearby partners. It's one offer, not a stream of upsells.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm taking away
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Look at the field early. The most valuable thing we did on day one wasn't writing code. It was seeing what everyone else was building and changing course before it was too late.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generic building blocks pay for themselves. A booking engine that doesn't care whether it's booking a room or a car is the reason the pivot fit into a weekend. Build the primitive, then configure it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build deep on the host's platform. Workpeg's pitch is "AI that doesn't just answer, it takes action." Making every venue a real business on Workpeg, with real guest desks, meant our demo was also a demo of their platform. Sponsors want to see their product used well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cuts are features. Every item we cut gave the remaining ones more time to actually work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fourth is data, not a verdict. We were 2.2 points off third. That gap is small enough to learn from and close next time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Thank you
&lt;/h2&gt;

&lt;p&gt;A big thank you to the Workpeg team for a really well-run event. They looked after every participant, from the food to the mentoring to the energy in the room, and I learnt a lot about building on a platform designed for AI that takes action.&lt;/p&gt;

&lt;p&gt;Congratulations to ClearTab on the win, and to Roomay and HotelOp for second and third. You earned it.&lt;/p&gt;

&lt;p&gt;And to Faruk and Emmanuel: we built something real in a week. We're not done with Kaabo.&lt;/p&gt;

&lt;p&gt;If you're working on hospitality, conversational commerce or AI agents in Nigeria, I'd love to compare notes. Find me as &lt;a class="mentioned-user" href="https://dev.to/abdulahmed_dev"&gt;@abdulahmed_dev&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>whatsapp</category>
      <category>ai</category>
      <category>hackathon</category>
      <category>buildinpublic</category>
    </item>
    <item>
      <title>Laravel HTTP Client Retry: Retry the Network, Never the Verdict</title>
      <dc:creator>Abdulahmed Abdulhakeem</dc:creator>
      <pubDate>Fri, 13 Nov 2026 11:05:19 +0000</pubDate>
      <link>https://dev.to/abdulahmed_dev/laravel-http-client-retry-retry-the-network-never-the-verdict-44b6</link>
      <guid>https://dev.to/abdulahmed_dev/laravel-http-client-retry-retry-the-network-never-the-verdict-44b6</guid>
      <description>&lt;p&gt;TrustScreen is a KYC document-fraud pre-screen I built. A Laravel 13 app receives batches of up to 10 ID documents or selfies, sends each one to a Python forensics microservice, and turns the per-layer scores that come back into a risk score and a recommendation. The service measures; Laravel decides.&lt;/p&gt;

&lt;p&gt;That split puts one HTTP call at the centre of every verification. And the most dangerous line in that call isn't the URL or the payload. It's &lt;code&gt;-&amp;gt;retry()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Retries feel like free reliability. Add &lt;code&gt;-&amp;gt;retry(3, 100)&lt;/code&gt; and transient failures go away. But a retry is a claim: "if I ask again, the answer might be different." For some failures that's true. For others it's false, and acting on it costs money, time and, in a fraud tool, the honesty of the result.&lt;/p&gt;

&lt;p&gt;Here's how I decided which failures get retried, who retries them, and why the caller's timeout sits above the service's own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two kinds of failure
&lt;/h2&gt;

&lt;p&gt;When Laravel calls the forensics service, a request can fail in two very different ways.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The network failed.&lt;/strong&gt; The service was restarting, a connection was refused, DNS hiccuped. The item never got analysed, so nothing about the document is known. Asking again a moment later has a real chance of working.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The service answered, and the answer was a failure.&lt;/strong&gt; The classifier ran out of time, the file couldn't be decoded, the payload was too large. The service did its job: it looked at this specific item and reported what happened. That's a verdict about the item, not a blip.&lt;/p&gt;

&lt;p&gt;Retrying the second kind is where the cost hides. The AI-generation classifier is a paid inference call. Retrying a classifier failure spends another call to get, most of the time, the same answer. And a file that couldn't be decoded the first time won't decode the second time.&lt;/p&gt;

&lt;p&gt;So the rule is: retry the network, never the verdict.&lt;/p&gt;

&lt;h2&gt;
  
  
  The retry, in code
&lt;/h2&gt;

&lt;p&gt;Laravel's HTTP client takes a &lt;code&gt;when&lt;/code&gt; callback that decides, per exception, whether to try again. That callback is where the rule lives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'base_url'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'timeout'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;connectTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'connect_timeout'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'retry_times'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'retry_sleep_ms'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;\&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nc"&gt;ConnectionException&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;asJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/v1/forensics/analyze'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things are doing the work here.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;when&lt;/code&gt; callback only says yes to &lt;code&gt;ConnectionException&lt;/code&gt;. When the service returns an error response, Laravel hands the callback a &lt;code&gt;RequestException&lt;/code&gt;, the callback says no, and there's no second attempt.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;throw: false&lt;/code&gt; means a failed response comes back as a response instead of an exception. That matters, because the error body carries a contract error code and I want to keep it.&lt;/p&gt;

&lt;p&gt;The numbers come from config, not from the call site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s1"&gt;'forensics'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'base_url'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'FORENSICS_BASE_URL'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'http://localhost:8001'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'timeout'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'FORENSICS_TIMEOUT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;30.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'connect_timeout'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'FORENSICS_CONNECT_TIMEOUT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'retry_times'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'FORENSICS_RETRY_TIMES'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'retry_sleep_ms'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'FORENSICS_RETRY_SLEEP_MS'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Laravel the first argument to &lt;code&gt;retry()&lt;/code&gt; is the total number of attempts, so &lt;code&gt;2&lt;/code&gt; means one retry, 200 ms after the first failure. A connection that can't be opened within 5 seconds counts as down. The numbers are small on purpose: the batch API is synchronous, so every retry is time a caller spends waiting with the request held open.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the cause the service reported
&lt;/h2&gt;

&lt;p&gt;When the service answers with a failure, the client reads the error code from the body and turns it into a typed exception:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;failed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nc"&gt;ForensicsException&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;fromResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nv"&gt;$body&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'error_code'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nv"&gt;$body&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'error_message'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;fromResponse&lt;/code&gt; maps the string onto an &lt;code&gt;ErrorCode&lt;/code&gt; enum. Per-item codes pass through from the microservice unchanged, so the reviewer sees the same cause the pipeline saw: &lt;code&gt;CLASSIFIER_TIMEOUT&lt;/code&gt;, &lt;code&gt;DECODE_FAILED&lt;/code&gt;, &lt;code&gt;PAYLOAD_TOO_LARGE&lt;/code&gt;. A code the app doesn't recognise becomes &lt;code&gt;INTERNAL_ERROR&lt;/code&gt; instead of crashing the batch.&lt;/p&gt;

&lt;p&gt;A connection that still fails after its retry becomes &lt;code&gt;FORENSICS_UNREACHABLE&lt;/code&gt;. Whatever the kind of failure, it ends up as an exception that carries a code.&lt;/p&gt;

&lt;p&gt;The orchestrator catches it per item. A failing document gets status &lt;code&gt;error&lt;/code&gt;, no score and no recommendation, while the rest of the batch is still scored. An item that couldn't be checked must never look like one that was checked and passed. A failure that quietly defaulted to "forward" would be a fraud tool telling a lie.&lt;/p&gt;

&lt;h2&gt;
  
  
  Machine retries and human retries
&lt;/h2&gt;

&lt;p&gt;Not retrying automatically doesn't make a failure final. It moves the retry decision to the person who can judge it.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ErrorCode&lt;/code&gt; enum carries that decision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isRetryable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;ClassifierTimeout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;ClassifierUnavailable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;ForensicsUnreachable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;SourceUnreachable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;InternalError&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The HTTP client never calls this method. It exists for the reviewer. A classifier timeout might clear later, so they can re-submit the item. A file that couldn't be decoded, is too large or is the wrong type won't get better by trying again: the reviewer needs a new file from the customer, so it's marked not retryable.&lt;/p&gt;

&lt;p&gt;That gives two retry policies, on purpose:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure&lt;/th&gt;
&lt;th&gt;Who retries&lt;/th&gt;
&lt;th&gt;When&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Transport failure&lt;/td&gt;
&lt;td&gt;The HTTP client, automatically&lt;/td&gt;
&lt;td&gt;Once, after 200 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retryable item error&lt;/td&gt;
&lt;td&gt;A human reviewer&lt;/td&gt;
&lt;td&gt;When they choose to re-submit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Non-retryable item error&lt;/td&gt;
&lt;td&gt;Nobody&lt;/td&gt;
&lt;td&gt;The input has to change&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The machine only retries what it can judge without context. Everything else goes to a person, with a reason attached.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the caller's timeout is 30 seconds
&lt;/h2&gt;

&lt;p&gt;The last decision is the easiest to get wrong. It's one line of config with a comment above it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Must exceed the microservice's own classifier timeout, or Laravel&lt;/span&gt;
&lt;span class="c1"&gt;// gives up while the service is still working and reports a misleading&lt;/span&gt;
&lt;span class="c1"&gt;// cause. The service budgets 10s for the classifier alone.&lt;/span&gt;
&lt;span class="s1"&gt;'timeout'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'FORENSICS_TIMEOUT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;30.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The forensics service gives the classifier 10 seconds. If the classifier runs over, the service reports &lt;code&gt;CLASSIFIER_TIMEOUT&lt;/code&gt;, which is an accurate account of what went wrong.&lt;/p&gt;

&lt;p&gt;Now imagine the caller's timeout were shorter than that budget, say 8 seconds. On a slow item, Laravel would give up first. Laravel's HTTP client reports its own timeout as a &lt;code&gt;ConnectionException&lt;/code&gt;, the same type as a refused connection. So three things go wrong at once:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The reviewer sees "the analysis service could not be reached", when the service was up and working.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;when&lt;/code&gt; callback sees a &lt;code&gt;ConnectionException&lt;/code&gt; and retries, sending the same slow item through the paid classifier again.&lt;/li&gt;
&lt;li&gt;The service may well finish the first request anyway, so that work is paid for and thrown away.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Setting the caller's timeout well above the service's budget keeps the inner timeout in charge. The service reports what happened, and only a real network failure triggers a retry. The rule I follow: &lt;strong&gt;the timeout closest to the work should fire first.&lt;/strong&gt; Each layer further out gets a bigger budget than the layer inside it.&lt;/p&gt;

&lt;p&gt;The generous outer timeout has a cost. If the service hangs completely, a caller waits 30 seconds for that item. I accepted that, because a hung service is rare and loud, while a misreported cause is quiet and erodes trust in every result.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell my past self
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write down what a retry claims. "Asking again might give a different answer" is true for a dropped connection and false for a verdict.&lt;/li&gt;
&lt;li&gt;Put the retry rule in the &lt;code&gt;when&lt;/code&gt; callback, next to the call it governs, not in a catch block somewhere else.&lt;/li&gt;
&lt;li&gt;Keep machine retries and human retries apart. One is a policy; the other is information you give a reviewer.&lt;/li&gt;
&lt;li&gt;Nest your timeouts: smaller budgets inside, larger ones outside, so the layer that knows the cause is the one that reports it.&lt;/li&gt;
&lt;li&gt;Make the numbers config. Timeouts and retry counts are environment variables here, so tuning them needs no deploy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this is exotic. It's about a dozen lines of code and a few comments. But those lines decide whether a slow model costs one call or two, and whether a reviewer sees the real cause or a misleading one.&lt;/p&gt;

&lt;p&gt;How do you split retries between your HTTP client and the people using your system?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://abdulahmed.hashnode.dev/laravel-http-client-retry-retry-the-network-never-the-verdict" rel="noopener noreferrer"&gt;my blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>microservices</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>HMAC Request Signing in Laravel: Make the Signature Format Explicit</title>
      <dc:creator>Abdulahmed Abdulhakeem</dc:creator>
      <pubDate>Tue, 10 Nov 2026 12:10:42 +0000</pubDate>
      <link>https://dev.to/abdulahmed_dev/hmac-request-signing-in-laravel-make-the-signature-format-explicit-3346</link>
      <guid>https://dev.to/abdulahmed_dev/hmac-request-signing-in-laravel-make-the-signature-format-explicit-3346</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9gqnvctmp6cp3m1zjfwv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9gqnvctmp6cp3m1zjfwv.png" alt="HMAC signing contract: exact input, explicit encoding and shared fixture" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The integration bug hiding behind a valid algorithm
&lt;/h2&gt;

&lt;p&gt;One of the easiest ways to break a signed integration is to let two services mean different things by “the signature.”&lt;/p&gt;

&lt;p&gt;In a B2B fraud-detection platform I worked on, HMAC request signing connected a Laravel application, its SDKs and an ML service. A signature-format mismatch nearly shipped. That is the engineering lesson I want to share, without exposing the employer, its code or its internal API contract.&lt;/p&gt;

&lt;p&gt;The question I now ask during review is simple: can two independent implementations produce exactly the same authenticated message and the same transmitted signature representation?&lt;/p&gt;

&lt;p&gt;Saying “we both use HMAC” does not answer that question. The algorithm is one part of the agreement. The message bytes, key handling and representation also need an explicit contract.&lt;/p&gt;

&lt;p&gt;The examples and review process below are general guidance. They are not a reconstruction of that private implementation or a claim about the exact mismatch we encountered.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a contract someone else can implement
&lt;/h2&gt;

&lt;p&gt;Before reviewing a signing function, I want a short document that another engineer can implement without asking what the original author intended.&lt;/p&gt;

&lt;p&gt;I would give that document an owner and review it with the people responsible for each caller. For this kind of integration, that means application engineers, SDK maintainers and the team operating the receiving service. Each group should be able to point to the same agreed input and expected output.&lt;/p&gt;

&lt;p&gt;My review questions would include: which fields are authenticated, where those fields come from, how their bytes are constructed, which key identifier is sent, and what representation the receiver accepts. I would also ask how a change becomes a new contract version.&lt;/p&gt;

&lt;p&gt;A useful review ends with fewer interpretations. If the document says “sign the request” but two engineers can reasonably produce different inputs, I would consider the interface unfinished. That is a documentation and compatibility problem before it becomes a deployment problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agree on the message bytes
&lt;/h2&gt;

&lt;p&gt;HMAC authenticates a message using a shared secret. It does not understand the business meaning of a request. The same key and message under the same algorithm produce the same authentication value; changing the input changes what is being authenticated. [1]&lt;/p&gt;

&lt;p&gt;For an HTTP integration, the design therefore needs to identify the covered request components and define how they form the signature input. RFC 9421 provides a standardized approach to HTTP message signatures, including explicit covered components and signature parameters. I would evaluate a standard before inventing a private format. [2]&lt;/p&gt;

&lt;p&gt;In a design discussion, I would put the request the sender actually transmits beside the input the receiver actually verifies. Then I would ask the team to explain every transformation between them. This makes assumptions visible while the system is still easy to change.&lt;/p&gt;

&lt;p&gt;I would avoid resolving uncertainty by guessing which transformation is harmless. The decision belongs in the contract, with a fixture that demonstrates it. A reviewer should be able to answer “why is this input correct?” by reading the specification and the test case together.&lt;/p&gt;

&lt;h2&gt;
  
  
  Treat encoding as part of the public interface
&lt;/h2&gt;

&lt;p&gt;PHP provides a concrete example of why representation needs attention. Its &lt;code&gt;hash_hmac&lt;/code&gt; function returns lowercase hexadecimal by default; its binary option returns raw digest bytes instead. Those are different representations of the calculated value. [3]&lt;/p&gt;

&lt;p&gt;A caller that encodes raw digest bytes as Base64 will send a different string from a caller that Base64-encodes the hexadecimal text. Neither function name tells the receiving service which representation it is getting. Agreement must be explicit.&lt;/p&gt;

&lt;p&gt;I would write down the accepted encoding, any prefix, and how the value is carried. I would give SDK authors one expected transmitted value alongside the original fixture inputs. I would also name the example clearly so nobody mistakes an illustration for a production credential.&lt;/p&gt;

&lt;p&gt;During review, I would ask someone outside the original implementation to explain the format back to me. If their explanation requires opening three source files and interpreting defaults, I would move those decisions into the interface documentation. Cross-language integrations deserve a contract that survives a change of library.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use a shared fixture as the meeting point
&lt;/h2&gt;

&lt;p&gt;My preferred review artifact is a small fixture with a deliberately synthetic payload, a public test-only key and an expected result. It should contain no customer data, internal endpoint or production secret.&lt;/p&gt;

&lt;p&gt;I would have each implementation consume that fixture independently. The Laravel side, the SDK and the receiving service should agree on the intermediate signing input as well as the final transmitted representation. That gives reviewers a common reference when they investigate a difference.&lt;/p&gt;

&lt;p&gt;I would keep fixtures close to the interface specification and review their changes together. A pull request that changes expected output should explain whether it corrects a test or changes the contract. Those are different decisions, and a reviewer needs enough context to tell which one is happening.&lt;/p&gt;

&lt;p&gt;The test suite I would propose also contains intentional disagreements. One case alters a covered field. Another supplies a malformed representation. Another uses a different test key. Each should have an explicit expected outcome. These are recommended tests for this pattern, not results from a test run against the employer's system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make failures useful without making them revealing
&lt;/h2&gt;

&lt;p&gt;When investigating a mismatch, I want to identify the stage where agreement ended. Did the request parse correctly? Was the expected key configuration available? Did the representation decode as specified? Did authentication fail after those steps?&lt;/p&gt;

&lt;p&gt;I would use internal diagnostic categories for those stages and decide separately what the public response should disclose. That helps an on-call engineer investigate the failure without turning an external error message into a detailed account of the server's internals.&lt;/p&gt;

&lt;p&gt;I would review logging alongside the signing code. A debugging change should not copy secrets, sensitive request bodies or reusable authentication material into logs. For a reproduction, I would first build a sanitized fixture that demonstrates the same disagreement using synthetic inputs.&lt;/p&gt;

&lt;p&gt;For comparing authentication values in PHP, &lt;code&gt;hash_equals&lt;/code&gt; is the documented timing-attack-safe comparison function. Its known value belongs first and the user-supplied value second. The documentation also notes that inputs of different lengths return false immediately. [4]&lt;/p&gt;

&lt;p&gt;That detail belongs in a code review, but it does not replace the earlier interface review. A comparison function can only compare the values the implementation actually constructed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review freshness and retries as separate requirements
&lt;/h2&gt;

&lt;p&gt;A valid message authentication value does not, by itself, establish that a request is fresh. A previously valid signed message can be presented again. HTTP Message Signatures discusses replay considerations and parameters such as creation time, expiry and nonce values. What an application must enforce depends on its protocol and threat model. [2]&lt;/p&gt;

&lt;p&gt;I would put that question on the design agenda before rollout. What should happen if a legitimate caller retries? What should happen if an old authenticated request is replayed? Which component owns the decision? What happens during clock drift or a temporary dependency failure?&lt;/p&gt;

&lt;p&gt;I would ask the product and service owners to agree on expected behavior rather than allow each SDK to choose independently. A retry policy is an observable part of the integration, and it needs documentation that the support team can use too.&lt;/p&gt;

&lt;p&gt;I would then make those agreed cases part of the release checklist. This article does not claim that the private platform implemented a particular replay window, nonce store or idempotency mechanism; those details are outside the information I can share.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review the rollout with the same care as the code
&lt;/h2&gt;

&lt;p&gt;For a future change to a signing contract, I would want an inventory of callers, the versions they run and the team responsible for upgrading each one. I would review that inventory before approving a switch in the receiving service.&lt;/p&gt;

&lt;p&gt;My rollout plan would state what changes, how compatibility is evaluated and what evidence permits the next step. I would ask for a clear rollback decision and a way to distinguish a contract mismatch from an unrelated service failure.&lt;/p&gt;

&lt;p&gt;That plan should be understandable to someone who did not write the signing implementation. If the deployment depends on one engineer remembering an undocumented exception, I would treat that as unfinished work.&lt;/p&gt;

&lt;p&gt;The lesson I take from the near miss is to make agreement reviewable. I want a written format, synthetic fixtures and independently checked implementations before an integration is called ready. “Both sides use HMAC” is a starting point; the contract explains whether they actually agree.&lt;/p&gt;

&lt;p&gt;What do you use to keep signing behavior consistent across your application, SDKs and downstream services?&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://www.rfc-editor.org/rfc/rfc2104.html" rel="noopener noreferrer"&gt;RFC 2104: HMAC&lt;/a&gt; — message authentication with shared keys.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.rfc-editor.org/rfc/rfc9421.html" rel="noopener noreferrer"&gt;RFC 9421: HTTP Message Signatures&lt;/a&gt; — covered components, signature parameters and replay considerations. This article does not claim the private integration implements RFC 9421.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.php.net/manual/en/function.hash-hmac.php" rel="noopener noreferrer"&gt;PHP hash_hmac&lt;/a&gt; — digest output representation.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.php.net/manual/en/function.hash-equals.php" rel="noopener noreferrer"&gt;PHP hash_equals&lt;/a&gt; — comparison behavior and argument order.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>laravel</category>
      <category>security</category>
      <category>backend</category>
      <category>api</category>
    </item>
  </channel>
</rss>
