Connecting Slack to JAICF project
To connect the Slack channel to the JAICF project, please follow these steps:
Prepare the project
Before connecting the channel, prepare the JAICF project in advance:
- Specify the following in the dependencies of
build.gradle.kts
file:
dependencies {
// ...
implementation("com.just-ai.jaicf:jaicp:$jaicfVersion")
implementation("com.just-ai.jaicf:slack:$jaicfVersion")
}
$jaicfVersion
with the latest framework version.- Configure depending on the connection method to the platform:
long polling
— the bot will connect to the Just AI server when interacting with the platform. Simple solution, convenient for local development, and debugging.For this method, specify
SlackChannel
in theJaicpPoller.kt
file:
package com.just-ai.jaicf.template.connections
fun main() {
JaicpPollingConnector(
templateBot,
accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
SlackChannel
)
).runBlocking()
}
webhook
— the bot will receive messages from the platform using the specified link. Must be configured to connect JAICP Cloud.For this method, specify the channel
SlackChannel
in theJaicpServer.kt
file:
package com.just-ai.jaicf.template.connections
fun main() {
JaicpServer(
botApi = templateBot,
accessToken = accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
SlackChannel
)
).start(wait = true)
}
Create a channel
To create a channel please follow the instructions.
Testing the bot
Open the bot dialog window in Slack and select your bot from the list in the Apps subsection. Send it a welcome/activation phrase provided by your script. After that, your dialog with the bot should begin.