Créer un événement

Dans cet extrait de code, vous apprendrez à créer un événement.

Product deprecation notice

Effective April 30th, 2026, Vonage In-App Messaging will no longer be available. Access for new users will be closed, and the service will be discontinued for all existing users.

If you have any questions regarding this product’s discontinuation, please contact your account manager or our support team.

Exemple

Veillez à ce que les variables suivantes soient réglées sur les valeurs souhaitées en utilisant toute méthode appropriée :

CléDescription
CONVERSATION_ID

The ID of the Conversation.

MEMBER_ID

The unique ID of the Member.

Conditions préalables

You will need to use an existing Application that contains a Conversation in order to be able to create an Event. See the Create Conversation code snippet for information on how to create an Application and some sample Conversations.

Rédiger le code

Ajouter ce qui suit à create-event.sh:

curl -X "POST" "https://api.nexmo.com/v1/conversations/$CONV_ID/events" \
     -H 'Authorization: Bearer '$JWT\
     -H 'Content-Type: application/json' \
     -d $'{
  "type": "'$CONV_EVENT_TYPE'",
  "from": "'$CONV_EVENT_FROM'"
  "body": {
      "message_type": "text",
      "text": "string"
   }
}'

Voir la source complète

Exécutez votre code

Enregistrez ce fichier sur votre machine et exécutez-le :

bash create-event.sh

Essayez-le

Lorsque vous exécutez le code, vous créez un nouvel événement.