References

Use the library

Include this javascript bundle in the html

<script src="https://static.iadvize.com/conversation-panel-app-lib/2.9.0/idzcpa.umd.production.min.js"></script>

Client

idzCpa

Global cariable used as the entry point of the CPA library, stored in window

init() : Promise

Client is obtained using idzCpa.init that returns a Promise

window.idzCpa.init().then(client => {
    //some code
})

context

Returns the client's information in the form of a Context object

 type Context = {
    conversationId: string;
    projectId: string;
    channel: Channel;
    language: string;
}

conversationId : id of the conversation between the client and the operator

projectId : Id of the project you launch the desk on

channel : Type of channel :

  AppleBusinessChat = 'APPLE_BUSINESS_CHAT',
  Call = 'CALL',
  Chat = 'CHAT',
  Facebook = 'FACEBOOK',
  FacebookBusinessOnMessenger = 'FACEBOOK_BUSINESS_ON_MESSENGER',
  MobileApp = 'MOBILE_APP',
  Sms = 'SMS',
  Video = 'VIDEO',
  Whatsapp = 'WHATSAPP',

language : language of the client

insertTextInComposeBox(string)

Insert the text passed in parameters into the compose box

pushCardInConversationThreat(Card)

Push the card passed in parameters into the conversation thread

type Action = {
  type: "LINK";
  title: string;
  url: string;
};

type Card = {
  title?: string;
  text?: string;
  actions: Action[];
  image?: {
      url: string;
      description: string;
  }
};

Push the card bundle passed in parameters in the conversation thread

type Carousel = {
  title?:string;
  cards: Card[]
}

getJWT() : string

Returns the JWT of the desk

ApplePay

pushApplePayPaymentRequestInConversationThread(ApplePayPaymentRequestType) : Promise

Insert an ApplePay payment request in the conversation, returns a promise. If the payment is successful => execute promise.then(()=>{ }) If there is an error in the payment => execute promise.catch((e : ActionError)=>{ })

type ApplePayPaymentRequestType = {
    requestIdentifier: UUID;
    payment: ApplePayPaymentRequest;
    receivedMessage: ApplePayReceivedMessage;
}

// Detail for payment field type
type ApplePayPaymentRequest {
  currencyCode: string;
  lineItems: PaymentItem[];
  requiredBillingContactFields: ApplePayContactField[];
  requiredShippingContactFields: ApplePayContactField[];
  shippingMethods: ShippingMethod[];
  total: PaymentItem;
}

type PaymentItem = {
  amount: string;
  label: string;
  type: ApplePayLineItemType;
};

enum ApplePayLineItemType {
  final,
  pending,
}

type ShippingMethod = {
  amount: string;
  detail: string;
  identifier: string;
  label: string;
};

enum ApplePayContactField {
  email = 'email',
  name = 'name',
  phone = 'phone',
  postalAddress = 'postalAddress',
  phoneticName = 'phoneticName',
}

// type for receivedMessage field
type ApplePayReceivedMessage {
  type: 'CARD';
  data: CardType;
}

type CardType = {
  title?: string;
  text?: string;
  image?: CardImage;
  actions: LinkAction[];
};

type CardImage = {
  url: string;
  description: string;
};

type LinkAction = {
  type: 'LINK';
  title: string;
  url: string;
};

// Error
type ActionError = {
    message: string;
    details?: string[];
}

client.pushApplePayPaymentRequestInConversationThread(applePayPaymentRequest: ApplePayPaymentRequestType): Promise

Last updated