Rate this page:

Avatar

Methods

getResponseData

Copy URL
getResponseData(): 

AvatarMessageObject

|

null

Gets response data from an avatar.

const kit = new VoximplantKit(context);
if (kit.isAvatar()) {
  const avatarResponse = kit.avatar.getResponseData();
  console.log(avatarResponse);
  // ... do something
}// End of function
 callback(200, kit.getResponseBody());

Returns

sendMessageToAvatar

Copy URL
sendMessageToAvatar(config: 

AvatarConfig

):

Promise<void>

Send a message to a Voximplant avatar.

const kit = new VoximplantKit(context);if (kit.isMessage()) {
  try {
    const conversationId = kit.getConversationUuid();
    const callbackUri = kit.getFunctionUriById(33);
    const {text} = kit.getIncomingMessage();

    // These variables must be added to the environment variables yourself
    const avatarId = kit.getEnvVariable('avatarId');
    const voxAccountId = kit.getEnvVariable('voxAccountId');
    const avatarLogin = kit.getEnvVariable('avatarLogin');
    const avatarPass = kit.getEnvVariable('avatarPass');

    await kit.avatar.sendMessageToAvatar({
      callbackUri,
      voxAccountId,
      avatarLogin,
      avatarPass,
      avatarId,
      conversationId,
      utterance: text,
      customData: {}
    })
  } catch (err) {
    console.error(err);
  }
}

// End of function
callback(200, kit.getResponseBody());

Parameters

Returns

  • type:

    Promise<void>

sendMessageToConversation

Copy URL
sendMessageToConversation(conversationUuid: 

string

,
message:

ChannelDataObject

):

Promise<void>

Send the avatar's reply to the conversation.

const kit = new VoximplantKit(context);
if (kit.isAvatar()) {
 const conversationUuid = kit.getConversationUuid();
 const message = kit.getMessageObject();
 try {
   await kit.avatar.sendMessageToConversation(conversationUuid, message);
 } catch(err) {
   console.error(err)
 }
}// End of function
 callback(200, kit.getResponseBody());

Parameters

Returns

  • type:

    Promise<void>

setAvatarApiUrl

Copy URL
setAvatarApiUrl(url: 

string

):

void

Parameters

  • url:

    string

Returns

  • type:

    void