Iam working on Bot framework chatbot on msteams channel. In the waterfall dialogs, As a requirement in Adaptive cards i need to retain its values( in INPUT.text)in msteams once submit button is clicked. But msteams doesnt retain the values. As a workaround i tried to add the adaptive card in ActivityPrompt and when user clicks on submit button activityprompt validation ensures new values are send as an update activity in the old card.
Below code explains how i used ActivityPrompt in the waterfall step.
async W2_showCard(step) { //in the waterfall step
const card = CardFactory.adaptiveCard(Json_adaptivecard);
return await step.prompt('formPrompt', { prompt: MessageFactory.attachment(card) });
}
.addDialog(new ActivityPrompt('formPrompt', async prompt => { // validation involved in activityprompt
const recognizedValue = prompt.recognized.value;
console.log(prompt.recognized.value)
if (recognizedValue.type =='message') {
if (recognizedValue.value) {
const replyToId = recognizedValue.replyToId;
var oldCard = prompt.options.prompt.attachments[0];
console.log(oldCard)
var validated = true;
for(let i=0;i<oldCard.content.body[0].columns[0].items.length;++i){// replace values
if(oldCard.content.body[0].columns[0].items[i].type=="Input.Text"){
// preserve the user input
const newValue =
recognizedValue.value[oldCard.content.body[0].columns[0].items[i].id];
oldCard.content.body[0].columns[0].items[i].placeholder = newValue;
}
}
// update the card
const activity = prompt.context.activity;
activity.attachments = [oldCard];// issue due to attachment Multiple skyp act error.
activity.id = replyToId;
await prompt.context.updateActivity(activity); // issue is here
if (validated) {
// this is to make input available in next waterfall step
prompt.recognized.value = recognizedValue.value;
return true;
} else {
await prompt.context.sendActivity(`Please check the form. Some values are missing`);
}
} else {
await prompt.context.sendActivity(`Please fill out form and press *"submit"* button or type *"cancel"* to stop.`);
}
}
return false;
}))
My issue is the updateactivity gives the ERROR: Activity resulted into multiple skype activities. On analyzing i was able to pinpoint the error to activity.attachment=[oldcard].
Is there any way to add attachment to text activity without having that error? Or why is prompt.context.activity a text activity instead of an attachment,clearly iam sending an attachment in the activityprompt in the waterfallstep
Any help would be much appreciated.