Event
Conversations and other Vonage objects such as Members and Applications generate Events. When key activities occur an event is generated, which can be handled by the application. For example when a User joins a Conversation a member:joined event is fired. If a Vonage Application has rtc as a capability, it will receive the dispatched event on the rtc event_url webhook.
| Event type | Description |
|---|---|
| General | |
leg:status:update | |
| Audio | |
audio:dtmf | DTMF tone is received into the Leg. |
audio:earmuff:off | Leg is unearmuffed. |
audio:earmuff:on | Leg is earmuffed. |
audio:mute:off | Leg is unmuted. |
audio:mute:on | Leg is muted. |
audio:play:stop | Audio streamed into a Leg is stopped. |
audio:play:done | Audio streamed into a Leg stops playing, that is the audio data finishes. |
audio:play | Audio is streamed into a Leg. |
audio:record:stop | |
audio:record:done | |
audio:record | Call is being recorded. |
audio:asr:done | |
audio:asr:record:done | |
audio:say:stop | |
audio:say:done | |
audio:say | |
audio:speaking:on | |
audio:speaking:off | |
| Message | |
message | Message (replaces Text and Image events), have subtypes of Text, Image, Audio, Video, File, Template, Custom, VCard, Location, Random. See API Spec for more details |
message:rejected | Message has been rejected. |
message:submitted | Message has been submitted. |
message:undeliverable | Message can't be delivered. |
message:delivered | Message has been delivered. |
message:seen | Message has been seen. |
| Conversation | |
conversation:updated | Conversation object is updated. |
| Member | |
member:invited | Member is invited into a Conversation. |
member:joined | Member joins a Conversation. |
member:left | Member leaves a Conversation. |
member:media | |
member:message:status | |
| RTC | |
rtc:status | |
rtc:transfer | |
rtc:hangup | |
rtc:terminate | |
rtc:answered | |
rtc:ringing | |
rtc:answer | |
| SIP | |
sip:status | |
sip:answered | SIP call is answered. |
sip:machine | When the entity answering the SIP call is a machine. |
sip:hangup | User on a SIP Call hangs up. |
sip:ringing | SIP call starts ringing, such as when Vonage makes an Outbound Call. |
sip:amd_machine | |
| Custom | |
custom: | Custom event types, can be named anything that matches ^custom:[\w\-:]+ for example custom:test |
ephemeral | Ephemeral events that can be sent but cant be retrieved after they have been sent. |
| Event | |
event:delete | An event has been deleted |
Handling Events
The following code snippet shows that code can be executed based on the event fired:
...
events.forEach((value, key) => {
if (conversation.members[value.from]) {
const date = new Date(Date.parse(value.timestamp))
switch (value.type) {
case 'message:seen':
...
break;
case 'message:delivered':
...
break;
case 'message':
...
break;
case 'member:joined':
...
break;
case 'member:left':
...
break;
case 'member:invited':
...
break;
case 'member:media':
...
break;
default:
...
}
}
})
...