Skip to content

Commit

Permalink
Merge pull request #51 from tarkalabs/feat/report-message
Browse files Browse the repository at this point in the history
feat/report message
  • Loading branch information
akshaymayekar authored Apr 16, 2024
2 parents f364cc7 + d184024 commit de129c8
Show file tree
Hide file tree
Showing 7 changed files with 736 additions and 17 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ where,
]
```

- [Optional] **reportMessage** Set this config when you want to report any incoming messages.

Config:
```
{
reportType: "REPORT_MESSAGE_TYPE",
handle: (messsageId, payload, feedbackMessage) => {
// messageId: unique message id generated by tarka chat
// payload: It's the same response payload being shown in tarka chat.
// feedbackMessage: The feedback message.
// TODO: YOUR_BUSINESS_LOGIC
},
}
```

where,
- Available report types are:
ALL: To report any incoming message
ONLY_LAST_MESSAGE: To report only last message


## Demo

Demo is deployed from the application code in `demo/` folder.
Expand Down
11 changes: 11 additions & 0 deletions dev/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ async function sendMessage(message, optionalFiles) {
},
};
let arrayResponse = [
{ requestId: "request-id" },
{ type: "text", message: "Message **One**" },
{ type: "text", message: "Message 2" },
{ type: "text", message: "Message 3" },
];
return Promise.resolve(arrayResponse);
}

async function reportMessage(messageId, payload, message) {
console.log("messageId " + messageId);
console.log("message " + message);
console.log("payload :>> ", JSON.parse(payload));
}

const chat = TarkaChat.init({
title: "Stocks Advisor",
botName: "Stad",
Expand All @@ -115,6 +122,10 @@ const chat = TarkaChat.init({
generateUploadPreview: generateImageThumbnail,
preChatRenderer: getPreChatScreen,
submitHandler: sendMessage,
reportMessage: {
reportType: "ONLY_LAST_MESSAGE",
handle: reportMessage,
},
expand: true,
});

Expand Down
Loading

0 comments on commit de129c8

Please sign in to comment.