Envoyer l'indicateur de réponse
Dans cet extrait de code, vous apprendrez comment envoyer un indicateur de réponse dans un message WhatsApp à l'aide de l'API Messages.
Exemple
Vous trouverez ci-dessous la description de toutes les variables utilisées dans chaque extrait de code :
| Clé | Description |
|---|---|
JWT | Used to authenticate your request. See Authentication for more information, including how to generate a JWT. |
GEOSPECIFIC_MESSAGES_API_URL | The URL for the Geo-specific Messages API endpoint. One of |
MESSAGES_MESSAGE_ID | The UUID of the specific message to mark as read. |
Conditions préalables
Si vous n'avez pas de demande, vous pouvez créer un. Veillez également à configurer vos webhooks.
Rédiger le code
Ajouter ce qui suit à send-replying-indicator.sh:
curl -X PATCH "${GEOSPECIFIC_MESSAGES_API_URL}/${MESSAGES_MESSAGE_ID}" \
-H "Authorization: Bearer "$JWT\
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"status": "read",
"replying_indicator": {
"show": true,
"type": "text"
}
}'Exécutez votre code
Enregistrez ce fichier sur votre machine et exécutez-le :
Conditions préalables
Si vous n'avez pas de demande, vous pouvez créer un. Veillez également à configurer vos webhooks.
Install-Package VonageRédiger le code
Ajouter ce qui suit à MarkAsReadWithStatusIndicator.cs:
var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH);
var vonageClient = new VonageClient(credentials);
await vonageClient.MessagesClient.UpdateAsync(WhatsAppUpdateMessageRequest.Build(MESSAGES_MESSAGE_ID, new WhatsAppReplyingIndicator(true)));