SDK API Reference

Use the React Native SDK settings and actions to customize the behavior of your bot.

Settings

For the React Native SDK, AdaEmbedView takes various props that you can use to customize the behavior of your chatbot.

cluster

cluster?: string;

Specifies the Kubernetes cluster to be used. Do not change this value unless directed by an Ada team member.

greeting

greeting?: string;

Use this prop to customize the greeting that new chatters see. This is useful for setting view-specific greetings across your app. The greeting should correspond to the ID of the Answer you would like to use, which you can find in the URL of the corresponding Answer in the dashboard.

Example

handle

handle: string;

The handle for your bot. This is a required field.

language

language?: string;

Takes in a language code to programatically set the bot language. You must first turn languages on in your Ada dashboard.

Language codes use the ISO 639-1 language format.

metaFields

metaFields?: object;

Use metaFields to pass information about a chatter to Ada. This can be useful for tracking information about your customers, as well as personalizing their experience. For example, you may wish to track the phone_number and name for conversation attribution. (See Variables for more information.)

Once set, you can access this information:

  • in the email attachment from Handoff Form submissions
  • via the Meta variables modal in the Conversations page of your Ada dashboard
JSX
1metaFields={{
2 name: "Some name",
3 age: 30
4}}

To change these values after bot setup, use the setMetaFields action.

sensitiveMetaFields

sensitiveMetaFields?: object;

Use sensitiveMetaFields to pass sensitive meta information about a chatter to Ada. This works like metafields, but provides an added layer of security.

Once set, you can access this information:

  • in the email attachment from Handoff Form submissions
  • via the Meta variables modal in the Conversations page of your Ada dashboard
JSX
1sensitiveMetaFields={{
2 token: "your_jwt_token"
3}}

To change these values after bot setup, use the setSensitiveMetaFields action.

thirdPartyCookiesEnabled (Android)

thirdPartyCookiesEnabled?: boolean;

Set the thirdPartyCookies prop to enable third-party cookies in AdaEmbedView. This feature is only available in Android. The default value is false.

zdChatterAuthCallback

zdChatterAuthCallback?(callback: (token: string) => void): void;

Use the zdChatterAuthCallback to request a JWT token from your API, then pass it to Ada. This creates shared trust between Ada and Zendesk, and in turn allows for verifiable chatter identity.

JSX
1zdChatterAuthCallback={callback => {
2 const token = getTokenFromAPI(); // Get a fresh JWT token from your API
3 callback(token);
4}}

zdChatterAuthCallback is available only for Zendesk Chat. It is not available for Zendesk Messaging.

endConversationCallback

endConversationCallback?(callback: (event?: { [key]: string | object }) => void): void;

Use endConversationCallback to specify a callback function to be called when a chatter ends a conversation. The callback will receive an event object containing conversation metadata.

JSX
1endConversationCallback={(event) => {
2 // perform action after conversation has been ended by the chatter
3}}

Actions

Call actions directly from the AdaEmbedView ref. This allows you to modify Ada chat without using state/props to trigger a re-render of the entire subtree.

JSX
1import AdaEmbedView from '@ada-support/react-native-sdk';
2// ...
3
4class MyComponent extends React.Component {
5 render() {
6 return <AdaEmbedView
7 handle="ada-example"
8 ref={ref => (this.adaEmbedView = ref)}/>;
9 }
10}

deleteHistory

Deletes the chatter used to fetch conversation logs for a chatter from storage. When a user opens a new chat window, a new chatter is generated.

JSX
1this.adaEmbedView.deleteHistory();

reset

Creates a new chatter and refreshes the Chat window. reset can take an optional object allowing language, metaFields, and greeting to be changed for the new chatter.

JSX
1this.adaEmbedView.reset();
2
3// With options
4this.adaEmbedView.reset({
5 metaFields: {
6 name: "Some name",
7 age: 30
8 }
9});

setLanguage

setLanguage(languageCode: string)

Changes the language in chat programatically. Use this action, rather than the language setting, to change the chat language without clearing the chat history. Language codes must use a lowercase, two-letter code, in ISO 639-1 language format. For example, en, fr, ca, ar, and so on.

this.adaEmbedView.setLanguage(languageCode: "fr")

Before using setLanguage:

setMetaFields

Used to set metaFields for a chatter after instantiation. This is useful if you need to update user data after Ada chat has already launched.

JSX
1this.adaEmbedView.setMetaFields({
2 name: "Some name",
3 age: 30
4});

setSensitiveMetaFields

Used to set sensitiveMetaFields for a chatter after instantiation. This is useful if you need to update user data after Ada chat has already launched.

JSX
1this.adaEmbedView.setSensitiveMetaFields({
2 token: "your_jwt_token"
3});

triggerAnswer

this.adaEmbedView.triggerAnswer()

Triggers an answer in chat. Include the Answer ID, which you can find in the URL of the corresponding Answer in the dashboard.

Example

this.adaEmbedView.triggerAnswer("627d28a9bd9ca9e5337b9763")

The chat window must be opened at least once before this method can be used.