Holder messaging via DIDComm
Example use case
Technical implementation
Prerequisites
Encrypted message dispatch
const axios = require("axios").default;
const API_KEY = ;//Your Truvera API key//
const API_URL = "https://api-testnet.truvera.io";//for production https://api.truvera.io
const WALLET_DID = ;//Holders wallet DID//
const apiClient = axios.create({
baseURL: API_URL,
headers: {
"Content-Type": "application/json",
"User-Agent": "insomnia/9.3.2",
Authorization: `Bearer ${API_KEY}`,
},
});
async function sendYesNoMessage() {
const payload = {
type: "text",
payload: {
senderName: , //Name of the message sender DID//
senderDid: , //Message sender DID//
senderLogo: , //Logo of the message sender DID//
title: "Are you currently speaking with our customer support team?",
question:
"This confirms you initiated the call and helps prevent fraud. Your personal information will not be shared.",
yesText: "Yes",
noText: "No",
expirationDate: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(),
messageId: 'Internal-message-1234'//add a message ID to track the message
},
type: "https://schema.truvera.io/yes-no-payload-V1.json",
senderDid: ,//the message sender DID//
algorithm: "ECDH-1PU+A256KW",
recipientDids: [WALLET_DID],
};
const { data: encryptedMessage } = await apiClient.post(
"/messaging/encrypt",
payload
);
console.log("Message encrypted successfully:", encryptedMessage);
const sendPayload = {
to: WALLET_DID,
message: encryptedMessage.jwe,
};
const { data: sentMessage } = await apiClient.post(
"/messaging/send",
sendPayload
);
console.log("Message sent successfully:", sentMessage);
}
sendYesNoMessage();Response payload from the wallet
Response notification and retrieval
How many items to offset by for pagination
0How many items to return at one time (max 64)
64DID as fully qualified, typically. did:cheqd:
did:cheqd:testnet:ac2b9027-ec1a-4ee2-aad1-1e316e7d6f59Filter messages by type (e.g., 'https://didcomm.org/basicmessage/2.0/basic-message')
A paged array of DIDComm messages
Total number of messages available
150Current offset for pagination
0Current limit for pagination
64Invalid request parameters
Authentication required
The unique identifier of the message
msg_1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdefPattern: ^[a-f0-9]{64}$The requested DIDComm message
A DIDComm message with metadata
Unique identifier for the message
msg_1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdefThe DID that received this message
did:cheqd:testnet:ac2b9027-ec1a-4ee2-aad1-1e316e7d6f59The type of the message (from the message content)
https://didcomm.org/basicmessage/2.0/basic-messageThe DID of the message sender (if available)
did:example:senderWhen the message was received
2024-01-15T10:30:01ZInvalid message ID format
Authentication required
Message not found or not owned by user
Last updated
Was this helpful?