Skip to content

ryangary321/voiceflow-slack

 
 

Repository files navigation

Voiceflow Slackbot

Use Voiceflow Dialog Manager API to run a Slack Bot

Updates

[v1.0]
- Fix for Socket Mode on Heroku
- Handle weblinks in Text step
- Translate text styling to Slack Markdown format

[v1.0.1]
- Handle choice/buttons
- Updated logic to translate slate text

[v1.0.2]
- Add createSession function
- Updated interact to save transcript
- Migrate from Heroku to Replit

Prerequisite

Setup

Slack logo

Create your Slack App

Go to to https://api.slack.com/apps?new_app=1 to create your Slack app

Select From an app manifest

Create a new Slack app

Select the workspace you want to publish the app to

Select a worksapce

Choose JSON on the next screen and replace evrything with the manifest bellow

Slack Manifest

{
    "display_information": {
        "name": "Voiceflow Slack Demo",
        "description": "Slack Assistant using Voiceflow Dialog Manager API",
        "background_color": "#37393d"
    },
    "features": {
        "app_home": {
            "home_tab_enabled": true,
            "messages_tab_enabled": true,
            "messages_tab_read_only_enabled": false
        },
        "bot_user": {
            "display_name": "Voiceflow Demo",
            "always_online": true
        }
    },
    "oauth_config": {
        "scopes": {
            "user": [
                "users:read"
            ],
            "bot": [
                "app_mentions:read",
                "channels:history",
                "chat:write",
                "im:history",
                "im:read",
                "im:write",
                "mpim:history",
                "mpim:read",
                "mpim:write",
                "users.profile:read",
                "users:read"
            ]
        }
    },
    "settings": {
        "event_subscriptions": {
            "user_events": [
                "message.app_home",
                "user_change"
            ],
            "bot_events": [
                "app_home_opened",
                "app_mention",
                "message.channels",
                "message.im",
                "message.mpim",
                "user_change"
            ]
        },
        "interactivity": {
            "is_enabled": true
        },
        "org_deploy_enabled": false,
        "socket_mode_enabled": true,
        "token_rotation_enabled": false
    }
}

Click Next at the bottom of the window

Next

Review the app details and comfirm by clicking on Create

Review Slack app

Install the newly created app on your workspace

Install Slack app

Click on Allow to finish to install the app on your Workspace

Allow Slack app

Generate a signin key and tokens

On the main screen, you want to copy the secret key and keep it for later

Slack app secret

Scroll down and click on Generate Token and Scopes

Slack app level tokens

Give this Token a name and add the connections:write scope to it. Then click on Generate

Slack app scope

Copy the app token and save it for later

Slack app token

Go to the OAuth & Permissions section, copy the Bot User OAuth Token from there and save it for later

Slack app bot token

You should now have: a secret key an app token a bot token

Voiceflow logo

Get your project Dialog API key

Go to Voiceflow Creator and open the Chat Assistant project you want to use

On your project, click on Integration from the left sidebar (or press the 6 key)

Voiceflow integration

Click Copy to copy your Voiceflow Dialog API Key and save it for later

Voiceflow API key

Voiceflow logo

Fork on Replit

Setup the Replit secrets

Set new Secrets with the following info

SLACK_APP_TOKEN Slack app secret (starting with xapp-)

SLACK_BOT_TOKEN Slack bot token (starting with xoxb-)

SLACK_SIGNING_SECRET Slack app signing secret

VOICEFLOW_VERSION_ID Voiceflow project version ID (Needed if you want to save transcripts, will default to 'production' otherwise)

VOICEFLOW_PROJECT_ID Voiceflow project ID (Needed if you want to save transcripts, will default to null otherwise)

VOICEFLOW_API_KEY Voiceflow project API key (from the Integration section)

In the Secrets tab, you can click on Edit as JSON button and paste the following JSON (do not forget to update the keys values):

{
  "VOICEFLOW_API_KEY":"VF.12345678",
  "VOICEFLOW_VERSION_ID":"12345678",
  "VOICEFLOW_PROJECT_ID":"12345678",
  "VOICEFLOW_RUNTIME_ENDPOINT":"general-runtime.voiceflow.com",
  "SLACK_APP_TOKEN":"XXXX",
  "SLACK_BOT_TOKEN":"XXXXX",
  "SLACK_SIGNING_SECRET":"XXXXXXX"
}

Set secrets

Set your App type

Set the App type to Background Worker

Set app type

Slack logo

Install your Slack App

On your Slack workspace, click on Apps > Add apps

Create a new Slack app

Search for 'Voiceflow Slack Demo' or the app name you've created earlier on Slack API website and click on it in the Search results list to install it

Create a new Slack app

The app is now available and you can click on Messages to start interacting with your bot.

Create a new Slack app

Create a new Slack app

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.1%
  • Nix 0.9%