This article introduces how to retrieve record data from Kintone Apps using Slack's
Slash Commands
. AWS Lambda is used to facilitate the integration.
Prepare the Slash Command on Slack
Navigate to
https://api.slack.com/apps
and click Create New App. Enter the required fields, and click Create App as shown below.
On the next page select Slash Commands, and then Create New Command.
Enter the following values:
Field
Value
Command
/mytodo
Request URL
(Enter a dummy URL for now)
Short Description
List your todos
An API Gateway URL will be entered in the Request URL field later on, but for now a dummy URL can be set. Once the Slash Command has been created, navigate to Settings and then Basic Information and take note of the Signing Secret found in App Credentials.
Prepare the App on Kintone
Create the app
Create an App
named "To do" with the following fields and settings.
Field Type
Field Name
Field Code
Text
To Do
name
Drop-down
Status
status
Date
Due date
due_date
User selection
Assignee
assignee
Generate an API Token
Generate an API Token for the App and set the View records permissions for it. For more information on API Tokens, refer to the
API Tokens
article.
Make note of the API token as it will be used later.
Click Save and then Update App to save the changes made to the App.
Prepare the Lambda Function and API Gateway on AWS
Set up the Lambda function
Log into an AWS account, open the AWS Web Console and navigate to Lambda.
Select Author from scratch and set the Function name and Runtime settings as follows. Click Create function.
Prepare the following code for the Lambda function code. Replace the following variables with the information of the Kintone and Slack environments set up earlier.
Variable Name
Value
kintoneHost
The Kintone domain name
appId
The App ID of the To do app
slackSigningSecret
The Slack Signing Secret
apiToken
The Kintone API token
Attention
In order to protect the token and the API token, encrypt these tokens using AWS Key Management System when in a production environment. Refer to the
Creating Keys
documentation of KMS for more information.
On the settings page, set the configurations as follows. Click Add once the settings are complete.
The API endpoint is displayed under the name of the Lambda function. Copy the URL to add to the Slack settings.
Test the Slash Command on Slack
On the Slack API Applications settings page, set the endpoint URL of the API Gateway that was created. Navigate to the Basic Information settings page. Under Building Apps for Slack, click Install App to Workspace.
On the next page, allow the App to access the workspace.
Navigate to the created channel within Slack. Typing in the Slash command /mytodo should run the Lambda function and the incomplete To Dos in Kintone for the current user should be displayed in the channel.
Note
Note: Records are retrieved by matching the Slack login name with the Kintone login name, so only Kintone records assigned to the current logged in Slack user are displayed.