poshbotio / PoshBot

Powershell-based bot framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Teams config fails with "parameter cannot be found that matches param access key"

jhealy opened this issue · comments

Poshbot with teams fails with parameter cannot be found that matches parameter AccessKey when New-PoshBotConfiguration is run.

**

Access key is not found in new-poshbotconfiguration file.

**

Following steps listed at

https://poshbot.readthedocs.io/en/latest/guides/backends/setup-teams-backend/

https://www.thelazyadministrator.com/2019/08/19/chatops-setting-up-poshbot-for-microsoft-teams/

Expected Behavior

Configuration should pass.

Current Behavior

Receive following error

New-PoshBotConfiguration : A parameter cannot be found that matches parameter name 'AccessKey'.
At C:\dev\psbot\teamswolframconfig.ps1:55 char:37
$backend = New-PoshBotConfiguration @backendConfig
CategoryInfo : InvalidArgument: (:) [New-PoshBotConfiguration], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,New-PoshBotConfiguration

Steps to Reproduce (for bugs)

Run this script. keys are changed from what I'm actually using.

$pbc = New-PoshBotConfiguration
$pbc.BotAdmins = @('jhealy@contoso.com')
$backendConfig = @{
    Name                = 'dfpshbot'
    BotName             = 'dfpshbot'
    TeamId              = '19:43d265bbb368efcc864@thread.tacv'
    ServiceBusNamespace = 'dfpshbot.servicebus.windows.net'
    QueueName           = 'messages'
    AccessKeyName       = 'receive'
    AccessKey           = 'gBkaSP31RWZC4M+5j3U05MvVaxaNz0=' | ConvertTo-SecureString -AsPlainText -Force
    Credential          = [pscredential]::new(
    '2f94917f-675c3fbf4ee6c1',
    ('FTf9@g.OeDyTYD:c@l' | ConvertTo-SecureString -AsPlainText -Force))
}
Write-Host 'dumping config for visual check'
Write-Host ($backendConfig | Format-Table | Out-String)
$backend = New-PoshBotConfiguration @backendConfig

Thanks for the issue @jhealy. Sorry I've been slow to respond. I'll take a look at this when I get the chance.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@jhealy Sorry it took me so long to respond. This one slipped through the cracks.

The last line (where you create the backend object) should be:

$backend = New-PoshBotTeamsBackend -Configuration $backendConfig

*NOT *

$backend = New-PoshBotConfiguration @backendConfig

You've already created the bot configuration object ($pbc) in the first line. After that, you need to create a backend configuration object with all the information required to connect to Teams. Once you have a bot configuration, and a backend configuration, you can create an instance of the bot and start it. Below is a complete example:

$pbc = New-PoshBotConfiguration
$pbc.BotAdmins = @('jhealy@contoso.com')
$backendConfig = @{
    Name                = 'dfpshbot'
    BotName             = 'dfpshbot'
    TeamId              = '19:43d265bbb368efcc864@thread.tacv'
    ServiceBusNamespace = 'dfpshbot.servicebus.windows.net'
    QueueName           = 'messages'
    AccessKeyName       = 'receive'
    AccessKey           = 'gBkaSP31RWZC4M+5j3U05MvVaxaNz0=' | ConvertTo-SecureString -AsPlainText -Force
    Credential          = [pscredential]::new(
    '2f94917f-675c3fbf4ee6c1',
    ('FTf9@g.OeDyTYD:c@l' | ConvertTo-SecureString -AsPlainText -Force))
}
Write-Host 'dumping config for visual check'
Write-Host ($backendConfig | Format-Table | Out-String)
$backend = New-PoshBotTeamsBackend -Configuration $backendConfig
$bot = New-PoshBotInstance -Configuration $pbc -Backend $backend
$bot.Start()

Hope that helps!