Where to use M91

It fits anywhere a URL fits. A send link is just a URL, so M91 goes in places a library never could. If it can make an HTTP request, it can reach a human.

WhereHow it connects
Monitoring: Grafana, Sentry, UptimeRobot, Better StackPaste the link into the webhook field
Automation: Zapier, Make, n8n, viaSocket, PipedreamOne HTTP step
CI/CDA curl guarded by if: failure()
A spreadsheetA formula that fires when a cell crosses a limit
A phoneA home-screen shortcut, so anyone has a panic button that wakes the team
A browserA bookmark
DevicesA smart button, a home-automation rule, a PLC with an HTTP block
Your own codeA curl, fetch or requests.post in the failure branch
An AI agentOne call at the point it must not decide alone

So the useful question is rarely “where does this go in the code?” It is: what would I want a person to know or decide, right now? In every example below, $M91_SEND_LINK is your channel’s send link from Quickstart.

Monitoring

Your monitor already detects the problem. Let it wake the person who can fix it. In Grafana, Sentry, UptimeRobot or Better Stack, add a webhook notification and paste the send link as the URL.

https://m91-api.msg91.com/s/<token>?title=API+health+check+failing&severity=HIGH&customId=api-health&respond=I+am+on+it,Seen
  • customId makes a check that fails every minute raise one alert, not sixty.
  • respond adds the buttons: the first is SHARED, the rest PERSONAL.

When the monitor recovers, close the alert so the next failure can alert again:

curl -X POST "$M91_SEND_LINK/close" -H "Content-Type: application/json" -d '{"customId":"api-health"}'

Automation

Add one step that calls the send link. Use it when a workflow fails, or reaches a step only a person can do.

viaSocket

viaSocket has a ready-made Send Channel Alert action. Paste your send link, write the title, and press Test. The response shows delivered, the number of phones reached.

The viaSocket Send Channel Alert action with a successful response
viaSocket: Send Channel Alert. The send link is masked here. Use your own.

Open Description, Severity, Custom Alert ID, Allow Response Options to add buttons and a customId.

Zapier, Make, n8n, Pipedream

Add one HTTP request step that calls the send link.

SettingValue
MethodPOST
URLYour send link
HeaderContent-Type: application/json
Body{"title":"Order {{order_id}} needs review","severity":"MEDIUM","customId":"order-{{order_id}}","responseOptions":[{"label":"I will review it","effect":"SHARED"},{"label":"Seen","effect":"PERSONAL"}]}

Put the thing the workflow is about into customId, so a retried run does not ring twice. Add a callbackUrl if a later step must wait for the answer.

CI/CD

Alert a person when a deploy fails or a release needs sign-off. Save the send link as a secret, and call it only on failure.

# GitHub Actions
- name: Alert on failure
  if: failure()
  run: |
    curl -X POST "${{ secrets.M91_SEND_LINK }}" \
      -H "Content-Type: application/json" \
      -d '{"title":"Deploy to prod failed","severity":"HIGH","customId":"deploy-prod",
           "responseOptions":[{"label":"I am on it","effect":"SHARED"},{"label":"Seen","effect":"PERSONAL"}]}'

For an approval gate, send two SHARED options (Approve and Reject) and wait for decision. See AI agents for the same pattern.

A spreadsheet

The sheet stays the source of data. M91 is the path to the person. In Google Sheets, a formula can call the link when a cell crosses a limit.

=IF(B2<10, IMPORTDATA("https://m91-api.msg91.com/s/<token>?title=Stock+below+10&severity=MEDIUM&customId=stock-low"), "")

Sheets recalculates often, so always set a customId. While that alert is open, repeats alert nobody.

A phone

Save the send link as a home-screen shortcut. Somebody non-technical gets a panic button that wakes the whole team, with no app to open and no workflow to build.

https://m91-api.msg91.com/s/<token>?title=Need+help+at+the+front+desk&severity=HIGH&respond=On+my+way,Seen

On iPhone, create a Shortcut with Get Contents of URL and add it to the Home Screen. On Android, add the link as a home-screen shortcut from your browser.

A browser

Bookmark a link that has a title. Opening it raises the alert. You get a small result page back, not JSON.

https://m91-api.msg91.com/s/<token>?title=Server+room+door+open&severity=HIGH

Devices

Any device that can send an HTTP request can use M91. Set a smart button, a home-automation rule or a PLC’s HTTP block to call the link. The device does not need to understand M91.

GET /s/<token>?title=Freezer+3+above+limit&severity=CRITICAL&customId=freezer-3 HTTP/1.1
Host: m91-api.msg91.com

Backend code and scripts

Alert from the exact place something goes wrong: a webhook handler that catches and logs, a job that did not run, a refund that failed. Read the link from your secret store and post from the failure branch.

curl -X POST "$M91_SEND_LINK" -H "Content-Type: application/json" -d '{
  "title": "Disk 94% on db-1", "severity": "HIGH", "customId": "disk-db-1",
  "responseOptions": [{"label": "I am on it", "effect": "SHARED"},
                      {"label": "Seen", "effect": "PERSONAL"}]}'
await fetch(process.env.M91_SEND_LINK, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    title: 'Payments webhook failing',
    description: `${count} failures since ${since.toISOString()}`,
    severity: 'CRITICAL',
    customId: 'payments-webhook-failing',
    responseOptions: [
      { label: "I'll handle it", effect: 'SHARED' },
      { label: 'Seen', effect: 'PERSONAL' },
    ],
  }),
});
requests.post(os.environ["M91_SEND_LINK"], json={
    "title": "Nightly export did not run",
    "severity": "HIGH",
    "customId": "nightly-export",
    "responseOptions": [
        {"label": "I'll handle it", "effect": "SHARED"},
        {"label": "Seen", "effect": "PERSONAL"},
    ],
})

AI agents that pause for a human

Every agent framework has a point where the run stops for a person: LangChain’s approval tools, LangGraph’s interrupt(), a Vercel AI SDK tool that needs approval. None of them says how that person is reached, and the default is a web page somebody has to be watching. M91 is the other half: the run stops, a phone rings until somebody answers, and the answer is what the run continues with.

Agent pauses  →  M91 rings a phone  →  a person taps Approve or Reject  →  agent continues or stops

The pattern

  1. Ask. Raise an alert whose answers are SHARED options. Two SHARED options make a question with two answers: whoever answers first decides, and nobody else is asked.
  2. Get the answer. Use a callbackUrl (best), or poll GET <link>/alerts/<customId> until decision is set.
  3. Own the timeout. There is no server-side expiry. Decide what silence means, treat it as the safe outcome (usually “no”), and close the alert yourself.

LangChain

createM91ApprovalTool is a tool the agent calls itself. It blocks until somebody answers on their phone.

import { M91Client } from '@msg91comm/m91';
import { createM91ApprovalTool } from '@msg91comm/m91/integrations/langchain';

const client = new M91Client(process.env.M91_SEND_LINK);

const approval = await createM91ApprovalTool(client, {
  approveLabel: 'Refund',
  rejectLabel: 'Hold',
  timeoutSeconds: 600,
});

const agent = createAgent({            // from 'langchain'
  model: 'anthropic:claude-sonnet-5',
  tools: [approval, ...yourTools],
  systemPrompt:
    'Before any refund, payment, deletion or deploy, call m91_request_approval ' +
    "and wait. Only the exact string 'approved' lets you continue.",
});

LangGraph

LangGraph already knows how to stop a graph and resume it. M91InterruptNotifier tells a person it stopped, and returns their decision.

import { Command } from '@langchain/langgraph';
import { M91InterruptNotifier } from '@msg91comm/m91/integrations/langgraph';

const notifier = new M91InterruptNotifier(client, { timeoutMs: 600_000 });

let result = await graph.invoke(state, config);

if (result.__interrupt__) {
  const data = result.__interrupt__[0].value;
  const decision = await notifier.notify({ title: data.question, customId: data.customId });
  result = await graph.invoke(new Command({ resume: decision }), config);
}

Vercel AI SDK

createM91ApprovalTool is a tool inside generateText, next to the rest.

import { M91Client } from '@msg91comm/m91';
import { createM91ApprovalTool } from 'm91/integrations/vercel-ai';

const m91 = new M91Client(process.env.M91_SEND_LINK!);

const { text } = await generateText({
  model: openai('gpt-4o'),
  tools: {
    m91_request_approval: await createM91ApprovalTool(m91, {
      severity: 'HIGH',
      approveLabel: 'Refund',
      rejectLabel: 'Hold',
      timeoutSeconds: 600,
    }),
  },
  stopWhen: stepCountIs(10),
  prompt: 'Refund order ORD-40122 if it checks out.',
});

Not in TypeScript? The same gate over HTTP

Any language can make the same calls with plain HTTP.

# ask
curl -s "$M91_SEND_LINK" -H 'Content-Type: application/json' -d '{
  "title": "Refund 48,000 on ORD-40122?", "severity": "HIGH",
  "customId": "refund-ORD-40122",
  "responseOptions": [{"label":"Refund","effect":"SHARED"},
                      {"label":"Hold","effect":"SHARED"}]}'

# then poll until `decision` is set
curl -s "$M91_SEND_LINK/alerts/refund-ORD-40122" | jq .data.decision

Three things to get right

Each of these fails silently, so they matter.

  • Only “approved” continues. The tool returns approved, rejected or error:…. A rejection, a timeout and an unreachable channel all mean do not proceed. Never write if decision:, because every value is truthy.
  • customId names the condition, not the moment. refund-ORD-40122, never a timestamp. A timestamp makes a new alert every time and nothing collapses.
  • Only a SHARED response sets decision. A PERSONAL one is an acknowledgement, so “Seen” can never read as “Approved”.
The TypeScript SDK is on npm: npm i @msg91comm/m91. Any other language uses the send link over HTTP, as above. If the agent already knows exactly which person must act, use the Platform API to alert that person by phone number.

Look for places where failures go unnoticed

The useful question is not “add alerting”. It is: where in this project does something fail and nobody currently finds out? Look for these:

In the codeWhy it earns an alert
A webhook handler that catches and logsPayments and signups fail here, and the log is read tomorrow
A scheduled job with a deadlineNothing reports a job that simply did not run
A queue or backlog past a thresholdThe system is degrading while everything still returns 200
A dead-letter queue receiving anythingBy definition nothing else will retry it
A payment, refund or payout failingMoney, and a customer already waiting
A health check that failed N timesThe difference between a blip and an outage
A deploy or migration needing a human gateThe pipeline is blocked until a person decides
An agent or automation about to do something irreversibleSee AI agents above
Auth or security: repeated failures, a new admin, a key used from nowhereNobody is watching the log at 2am
A third-party integration returning errors in a rowYour code is fine and your product is broken

Then decide, for each one: should it wake somebody at 3am, or wait until morning?

Send an alert only when a person can act now

The test is not “is this bad?” but “is there something a specific person can do about it right now?” All three must hold:

  1. A person is needed. Not a retry, not a dashboard, not a log line.
  2. Now matters. Waiting until morning makes it worse.
  3. Somebody can act. There is a thing to do, and the alert says what.

If one fails, it is a log, a metric or a daily digest. The common failure is volume, not accuracy. Never wire M91 into a generic error handler or a logger. Alert on named conditions you chose on purpose.

Give each problem a name so repeats collapse

Any check that runs on a schedule needs a customId: the name of the condition, not the run. Closing is what re-arms it, so close the alert when the condition clears.

customId: "payments-webhook-failing"      ✓  the condition
customId: "alert-2026-10-01T03:14:22Z"    ✗  the run: rings every minute
curl -X POST "$M91_SEND_LINK/close" -H "Content-Type: application/json" -d '{"customId":"payments-webhook-failing"}'

Before you say it works

  • The bare link returns the right channel.
  • One real alert was sent and a real phone rang. You read the response.
  • Every alert has two or more response options, or an explicit [] with isAutoClose: true.
  • Every recurring condition has a customId, and something closes it.
  • Severity is deliberate. Nothing is CRITICAL that could wait.
  • The link is in configuration, not in source, and not logged.
  • You reported what actually came back, not what the code should do.