The chat command allows your mini app to prompt users to share a message via World Chat. Users can send messages to individual contacts or groups.
Using the command
import { MiniKit } from '@worldcoin/minikit-js'
const handleChat = async () => {
if ( ! MiniKit . isInstalled ()) {
return
}
const { finalPayload } = await MiniKit . commandsAsync . chat ({
message: "Check out this awesome mini app!" , // Required
to: [ "username1" , "0x1234..." ], // Optional: usernames or addresses, pre-selects them in the modal
})
if ( finalPayload . status === "error" ) {
console . log ( "Error:" , finalPayload . error_code )
return
}
console . log ( `Message shared to ${ finalPayload . count } chats` )
}
Response
Success:
Upon success the user will be navigated to the chat tab and your mini app will be closed.
Thus, it’s advised to include a link to your mini app in the message so they can easily return.
Error payload:
type ChatErrorPayload = {
status : "error"
error_code : "user_rejected" | "send_failed" | "generic_error"
version : number
}
Error Codes
Code Description user_rejectedUser closed the modal send_failedSending message failed (user might not be on World Chat) generic_errorAny other error
Command Preview
Your browser does not support the video tag.
Universal Links to World Chat
You can create universal links to open World Chat from your mini app or any web page. These also work as deep links.
Open the chat tab in World App
Open a conversation with a specific user
Opens a user-specific page with an action:
https://world.org/profile?username=andy&action=chat
Query Param Values Description usernamee.g. andy Username of the user addresse.g. 0xdeadbeef Wallet address of the user actionchat | request | payAction to take with the user
Show Profile Card
Display a native profile card modal inside your app for social sharing and easy access to profiles.
MiniKit . showProfileCard ({
username: "andy" , // Optional
walletAddress: "0x1234..." // Optional
})
Adding profile cards anywhere you display usernames helps users discover and connect with each other, making your app feel more integrated with World App.
Your browser does not support the video tag.