I have a use case where i would like to send a slack user a message of which i know the id of a notification once and a while using the bot framework.
Right now i have the following:
server.get("/api/notify", async (req, res) => {
await adapter.createConversation(conversationReference, async turnContext => {
await turnContext.sendActivity("proactive hello");
});
res.setHeader("Content-Type", "text/html");
res.writeHead(200);
res.write(
"<html><body><h1>Proactive messages have been sent.</h1></body></html>"
);
res.end();
});
where a conversation reference looks like:
const conversationReference = {
user: { id: "ID3:ID2", name: "user1" },
bot: { id: "ID1:ID2", name: "bot1" },
conversation: {
isGroup: false,
id: "ID1:ID2:ID3",
conversationType: "slack",
tenantId: "",
name: ""
},
channelId: "slack",
serviceUrl: "https://slack.botframework.com/"
};
But it only works if the user has talked to the bot since the bot has booted. But after a restart this won't work anymore until the user initiates a conversation.
When I try to send a pro active message after the bot rebooted and the user hasn't started a conversation after that i get the following exception:
UnhandledPromiseRejectionWarning: Error
at new RestError (/usr/app/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1397:28)
at /usr/app/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1849:37
at process._tickCallback (internal/process/next_tick.js:68:7)
My question is: How can i persist this state, so i can still send pro active messages after a reboot?