-
Notifications
You must be signed in to change notification settings - Fork 42
updated example working with botkit slack adapter? #42
Comments
I see I should use: https://www.npmjs.com/package/botbuilder-storage-mongodb |
Actually, it does not support tables features 😢 |
@Casz yes, this project is going to be deprecated soon, or at least marked as for legacy Botkit only. For conversation state persistence, use the |
@benbrown it would be great with more examples of how to use userstate with mongodb storage. Sadly, I don't have any conversations in my current bot. |
Examples of using the Bot Framework userstate? |
I guess I don't know what I am asking for 😰 |
Gotcha. To be honest, if this module works for you, just use it -- it can be plonked into the new Botkit using the addPluginExtension() method. Something like this:
|
Neat, that should at least allow me to migrate quickly and then, later on, remove the usage of this module. |
@Casz let me know how that goes! :) |
@Casz did this work out? |
I haven't had a chance yet. Hopefully sometime during the weekend 😓 |
Migrating is not easy. Lots of things that have to be rewritten and readjusted 😢 |
I wonder why you chose memory example for bot access/user token and why this was not built into the adapter 🤔 This should do the trick controller.webserver.get('/install/auth', async (req, res) => {
try {
const results = await controller.adapter.validateOauthCode(req.query.code)
console.log('FULL OAUTH DETAILS', results)
// Store token by team in bot state.
storage.write({
[results.team_id]: {
bot_access_token: results.bot.bot_access_token,
bot_user_id: results.bot.bot_user_id,
},
})
res.json('Success! Bot installed.')
} catch (err) {
console.error('OAUTH ERROR:', err)
res.status(401)
res.send(err.message)
}
})
async function getTokenForTeam(teamId: string): Promise<string> {
const team = await storage.read([teamId]);
if (team && team.bot_access_token) {
return team.bot_access_token
} else {
console.error('Team not found in tokenCache: ', teamId);
}
}
async function getBotUserByTeam(teamId: string): Promise<string> {
const team = await storage.read([teamId]);
if (team && team.bot_user_id) {
return team.bot_user_id
} else {
console.error('Team not found in userCache: ', teamId);
}
} |
Yes, that works. I am trying to avoid any sort of prescription on using external databases, as every app is different. |
FWIW, and for others Googling, I received the following error after attempting to install
This issue was helpful for understanding what was going on. |
I am also getting the same error TypeError: this.storage.read is not a function |
@benbrown I would like to know what changes are required for this to continue to work 😓 SlackAdapter does not accept
.storage
The text was updated successfully, but these errors were encountered: