← Developer guides

WhatsApp draft formatting

Paste a converted draft into WhatsApp when an LLM returns double asterisks around bold words. WhatsApp represents bold in the composer with single asterisks.

Installation guide · Examples tested with 0.3.1

Result

The draft contains *Ship* today. Pasting it into WhatsApp uses the app’s single-asterisk bold syntax. For Cloud API delivery, use toMessages and supply the recipient.

Code examples

  • TypeScript
  • Python
  • Go

TypeScript

import { convert } from "mdto-messages";

const draft = convert("**Ship** today", "whatsapp");
console.log(draft.text);

Python

from mdto_messages import convert

draft = convert("**Ship** today", "whatsapp")
print(draft.text)

Go

package main

import (
    "fmt"
    "log"

    "github.com/jmeinke/mdto-messages"
)

func main() {
    draft, err := mdto.Convert("**Ship** today", mdto.WhatsApp)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(draft.Text)
}

Format a draft for WhatsApp

References

  • Original example and platform reference
  • API reference and limits

Source: mdto-messages 0.3.1 · MIT license