Convokraft JS SDK methods

The ConvoKraft JS SDK exposes the following methods to the web application to perform a set of basic operations:

  • sendMessage()
  • pushTranscript()

sendMessage()

The sendMessage() method is used to configure your client application to send a chat message to the ConvoKraft server. That is when a user clicks an option displayed in the chat window, the configured message corresponding to the option will be displayed to the user in the chat window instantly.

The arguments for this method include a string containing the message that will be displayed in the chat conversation, which is mandatory and another string that contains the option_id, which is the id of the chosen option in case of array params. The option_id argument is optional.

    
copy
{ convokraft.sendMessage(messageString,option_id); }

pushTranscript()

This method can be used to push a custom transcript (an individual message in the user conversation) for a user while conversing with the ConvoKraft bot. The message will be displayed only in the chatbot for that particular session. A transcript data as mentioned below should be passed on to the function. This method is useful in scenarios of pushing a remainder.

    
copy
{ "message": "Reminder to call Bob at 11am", "id": "1", "sender": "user", "time": "1523356878103" } convokraft.pushTranscript(transcriptObject);

Here, transcriptObject is the message object that will be displayed in the conversation.

Last Updated 2023-07-26 17:07:45 +0530 +0530