Sending message[DM] to slack user

unable to send message to slack user.

pipeline {
    agent any

    stages {
        stage('Hello') {
            steps {
                echo 'Hello World'
                script {
                    def userIds = slackUserIdsFromCommitters()
                    def tagString = userIds.collect { "<@$it>" }.join(' ')
                    // def userId = slackUserIdFromEmail("${currentBuild.getBuildCauses()[0].userId}")
                    // wrap([$class: 'BuildUser']) {
                    //     def user = User.getById(env.BUILD_USER_ID, false)
                    //     def slackUserProperty = user?.getProperty(jenkins.plugins.slack.user.SlackUserProperty.class)
                    //     def userId = slackUserProperty?.getUserId()
                    // }
                    echo userId
                    // slackSend(color: 'good', channel:'@$UserId', message: "Message from Jenkins Pipeline ${tagString},${userIds}")
                    // slackSend(color: 'good', channel:"@${userId}", message: "Message from Jenkins Pipeline ${tagString},${userIds}")
                    // slackSend(color: 'good', channel:"@${currentBuild.getBuildCauses()[0].userName}", message: "Message from Jenkins Pipeline ${tagString},${userIds}")
                    slackSend(color: 'good', channel:"@${currentBuild.getBuildCauses()[0].userId}", message: "Message from Jenkins Pipeline ${tagString},${userIds}")
                    // slackSend(color: 'good', channel:"@Vadirajks", message: "Message from Jenkins Pipeline ${tagString},${userIds}")
                    
                }
            }
        }
    }
}

App has all perm,jerkins configuration correct and i am able to print userid but not able to send message to user

slackSend(color: ‘good’, channel:’@$UserId’, message: “Message from Jenkins Pipeline ${tagString},${userIds}”)
Slack Send Pipeline step running, values are - baseUrl: , teamDomain: affle, channel: @$UserId, color: good, botUser: true, tokenCredentialId: slack-bot-token, notifyCommitters: false, iconEmoji: , username: , timestamp:
ERROR: Slack notification failed with exception: {“ok”:false,“error”:“channel_not_found”}
ERROR: Slack notification failed. See Jenkins logs for details.

slackSend(color: ‘good’, channel:"@${userId}", message: “Message from Jenkins Pipeline ${tagString},${userIds}”)
it is send slack app channel:
test-jenkins-workflow-integration APP 1:30 PM
Message from Jenkins Pipeline ,
Slack Send Pipeline step running, values are - baseUrl: , teamDomain: affle, channel: @U010XXXXXXX, color: good, botUser: true, tokenCredentialId: slack-bot-token, notifyCommitters: false, iconEmoji: , username: , timestamp:

slackSend(color: ‘good’, channel:"@${currentBuild.getBuildCauses()[0].userName}", message: “Message from Jenkins Pipeline ${tagString},${userIds}”)
Slack Send Pipeline step running, values are - baseUrl: , teamDomain: affle, channel: @Vadiraj K S, color: good, botUser: true, tokenCredentialId: slack-bot-token, notifyCommitters: false, iconEmoji: , username: , timestamp:
ERROR: Slack notification failed with exception: {“ok”:false,“error”:“channel_not_found”}
ERROR: Slack notification failed. See Jenkins logs for details.

slackSend(color: ‘good’, channel:"@Vadirajks", message: “Message from Jenkins Pipeline ${tagString},${userIds}”)

NOTE : it works if i send message to channel but not to the slack users

Please let know if anything needs to corrected.
Thanks!!

Hello @vadirajks and welcome to this community :wave:

Could you try to send a message to a user without using variables?
Could you please also try to send a messsage with the slack member id instead of the username?
Thanks.